diff --git a/Cargo.lock b/Cargo.lock index 2b22d58e4..5cff87e79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3250,6 +3250,54 @@ dependencies = [ "url", ] +[[package]] +name = "openstack-sdk-block-storage" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-compute" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-container-infrastructure-management" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + [[package]] name = "openstack-sdk-core" version = "0.22.5" @@ -3286,6 +3334,122 @@ dependencies = [ "url", ] +[[package]] +name = "openstack-sdk-dns" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-identity" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "secrecy", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-image" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "json-patch", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-load-balancer" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-network" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-object-store" +version = "0.1.0" +dependencies = [ + "async-trait", + "bytes", + "derive_builder", + "futures", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + +[[package]] +name = "openstack-sdk-placement" +version = "0.1.0" +dependencies = [ + "bytes", + "derive_builder", + "http", + "httpmock", + "openstack-sdk-core", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-test", +] + [[package]] name = "openstack_cli" version = "0.13.5" @@ -3329,17 +3493,14 @@ name = "openstack_sdk" version = "0.22.5" dependencies = [ "async-trait", - "base64 0.22.1", "bytes", "chrono", "derive_builder", - "dialoguer", "futures", "futures-util", "http", "httpmock", "inventory", - "json-patch", "openstack-sdk-auth-applicationcredential", "openstack-sdk-auth-core", "openstack-sdk-auth-federation", @@ -3351,7 +3512,17 @@ dependencies = [ "openstack-sdk-auth-token", "openstack-sdk-auth-totp", "openstack-sdk-auth-websso", + "openstack-sdk-block-storage", + "openstack-sdk-compute", + "openstack-sdk-container-infrastructure-management", "openstack-sdk-core", + "openstack-sdk-dns", + "openstack-sdk-identity", + "openstack-sdk-image", + "openstack-sdk-load-balancer", + "openstack-sdk-network", + "openstack-sdk-object-store", + "openstack-sdk-placement", "reqwest", "secrecy", "serde", diff --git a/Cargo.toml b/Cargo.toml index 66b020b4f..0c03e1fe3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,18 +1,6 @@ [workspace] resolver = "3" members = [ - "auth-core", - "auth-application-credential", - "auth-federation", - "auth-jwt", - "auth-multifactor", - "auth-oidcaccesstoken", - "auth-passkey", - "auth-password", - "auth-receipt", - "auth-token", - "auth-totp", - "auth-websso", "cli-core", "cli-cmd/api", "cli-cmd/auth", @@ -31,15 +19,57 @@ members = [ "openstack_cli", "openstack_tui", "openstack_types", - "sdk-core", + "sdk/auth-core", + "sdk/auth-application-credential", + "sdk/auth-federation", + "sdk/auth-jwt", + "sdk/auth-multifactor", + "sdk/auth-oidcaccesstoken", + "sdk/auth-passkey", + "sdk/auth-password", + "sdk/auth-receipt", + "sdk/auth-token", + "sdk/auth-totp", + "sdk/auth-websso", + "sdk/core", + "sdk/block-storage", + "sdk/container-infrastructure-management", + "sdk/compute", + "sdk/dns", + "sdk/identity", + "sdk/image", + "sdk/load-balancer", + "sdk/network", + "sdk/object-store", + "sdk/placement", "xtask", "fuzz", ] # webauthn-rs should not land in the default members since it pulls openssl that # is not available for alpine -default-members = ["auth-core", "auth-application-credential", - "auth-multifactor", "auth-oidcaccesstoken", "auth-password", "auth-receipt", - "auth-totp", "auth-websso", "cli-core", "cli-cmd/*", "sdk-*", "openstack_*"] +default-members = [ + "sdk/auth-core", + "sdk/auth-application-credential", + "sdk/auth-multifactor", + "sdk/auth-oidcaccesstoken", + "sdk/auth-password", + "sdk/auth-receipt", + "sdk/auth-totp", + "sdk/auth-websso", + "sdk/core", + "sdk/block-storage", + "sdk/container-infrastructure-management", + "sdk/compute", + "sdk/dns", + "sdk/identity", + "sdk/image", + "sdk/load-balancer", + "sdk/network", + "sdk/object-store", + "sdk/placement", + "cli-core", + "cli-cmd/*", + "openstack_*"] [workspace.package] license = "Apache-2.0" diff --git a/cli-cmd/auth/Cargo.toml b/cli-cmd/auth/Cargo.toml index c450dabf8..68029d813 100644 --- a/cli-cmd/auth/Cargo.toml +++ b/cli-cmd/auth/Cargo.toml @@ -15,7 +15,7 @@ clap.workspace = true eyre.workspace = true openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "identity"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } secrecy.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/cli-cmd/block-storage/Cargo.toml b/cli-cmd/block-storage/Cargo.toml index 791f52db6..1263ebe3c 100644 --- a/cli-cmd/block-storage/Cargo.toml +++ b/cli-cmd/block-storage/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "block_storage", "identity"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/catalog/Cargo.toml b/cli-cmd/catalog/Cargo.toml index ffc7214a5..df41c7308 100644 --- a/cli-cmd/catalog/Cargo.toml +++ b/cli-cmd/catalog/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true clap.workspace = true openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "identity"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } serde.workspace = true serde_json.workspace = true structable = { workspace = true } diff --git a/cli-cmd/compute/Cargo.toml b/cli-cmd/compute/Cargo.toml index f075fae5a..994ee0b4b 100644 --- a/cli-cmd/compute/Cargo.toml +++ b/cli-cmd/compute/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "compute", "identity"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/container-infrastructure-management/Cargo.toml b/cli-cmd/container-infrastructure-management/Cargo.toml index 20fec7da9..f0acfa761 100644 --- a/cli-cmd/container-infrastructure-management/Cargo.toml +++ b/cli-cmd/container-infrastructure-management/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "container_infra"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/dns/Cargo.toml b/cli-cmd/dns/Cargo.toml index 42b9024e3..955e4d5e2 100644 --- a/cli-cmd/dns/Cargo.toml +++ b/cli-cmd/dns/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "dns", "identity"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/identity/Cargo.toml b/cli-cmd/identity/Cargo.toml index 374204b8d..5796f5bce 100644 --- a/cli-cmd/identity/Cargo.toml +++ b/cli-cmd/identity/Cargo.toml @@ -15,7 +15,7 @@ clap.workspace = true dialoguer.workspace = true openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "identity"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre.workspace = true http.workspace = true diff --git a/cli-cmd/image/Cargo.toml b/cli-cmd/image/Cargo.toml index 0ff557e8d..61761bc6b 100644 --- a/cli-cmd/image/Cargo.toml +++ b/cli-cmd/image/Cargo.toml @@ -14,7 +14,7 @@ clap = { workspace = true } json-patch = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "identity", "image"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/load-balancer/Cargo.toml b/cli-cmd/load-balancer/Cargo.toml index edb53aecb..ffa14610a 100644 --- a/cli-cmd/load-balancer/Cargo.toml +++ b/cli-cmd/load-balancer/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "identity", "load_balancer"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/network/Cargo.toml b/cli-cmd/network/Cargo.toml index aeb838dfb..3903d7add 100644 --- a/cli-cmd/network/Cargo.toml +++ b/cli-cmd/network/Cargo.toml @@ -12,7 +12,7 @@ repository.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "network"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/object-store/Cargo.toml b/cli-cmd/object-store/Cargo.toml index d33299f77..03a104f71 100644 --- a/cli-cmd/object-store/Cargo.toml +++ b/cli-cmd/object-store/Cargo.toml @@ -14,7 +14,7 @@ bytes.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "object_store"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-cmd/placement/Cargo.toml b/cli-cmd/placement/Cargo.toml index da61f50ba..bb1173d11 100644 --- a/cli-cmd/placement/Cargo.toml +++ b/cli-cmd/placement/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true clap = { workspace = true } openstack-cli-core = { version = "0.13", path = "../../cli-core/" } openstack_sdk = { path="../../openstack_sdk", version = "^0.22", default-features = false, features = ["async", "identity", "placement"] } -openstack-sdk-core = { path="../../sdk-core", version = "^0.22" } +openstack-sdk-core = { path="../../sdk/core", version = "^0.22" } openstack_types = { path="../../openstack_types", version = "^0.22" } eyre = { workspace = true } http = { workspace = true } diff --git a/cli-core/Cargo.toml b/cli-core/Cargo.toml index b1a9cdf6b..5ecf24618 100644 --- a/cli-core/Cargo.toml +++ b/cli-core/Cargo.toml @@ -21,8 +21,8 @@ eyre = { workspace = true } http = { workspace = true } indicatif = "^0.18" itertools = { workspace = true } -openstack-sdk-auth-core = { path="../auth-core", version = "^0.22", default-features = false } -openstack-sdk-core = { path="../sdk-core", version = "^0.22", default-features = false } +openstack-sdk-auth-core = { path="../sdk/auth-core", version = "^0.22", default-features = false } +openstack-sdk-core = { path="../sdk/core", version = "^0.22", default-features = false } owo-colors = { version = "^4.3", features = ["supports-colors"] } rand = { version = "^0.10" } reqwest = { workspace = true } diff --git a/openstack_sdk/Cargo.toml b/openstack_sdk/Cargo.toml index 4f4e1bf4f..a107feb3a 100644 --- a/openstack_sdk/Cargo.toml +++ b/openstack_sdk/Cargo.toml @@ -26,50 +26,78 @@ default = [ "object_store", "placement" ] -block_storage = [] -compute = [] -container_infra = [] -dns = [] -identity = [] -image = [] -load_balancer = [] -network = [] -object_store = [] -placement = [] -sync = ["openstack-sdk-core/sync"] -async = ["openstack-sdk-core/async"] +block_storage = ["dep:openstack-sdk-block-storage"] +compute = ["dep:openstack-sdk-compute"] +container_infra = ["dep:openstack-sdk-container-infrastructure-management"] +dns = ["dep:openstack-sdk-dns"] +identity = ["dep:openstack-sdk-identity"] +image = ["dep:openstack-sdk-image"] +load_balancer = ["dep:openstack-sdk-load-balancer"] +network = ["dep:openstack-sdk-network"] +object_store = ["dep:openstack-sdk-object-store"] +placement = ["dep:openstack-sdk-placement"] +sync = ["openstack-sdk-core/sync", + "openstack-sdk-block-storage/sync", + "openstack-sdk-compute/sync", + "openstack-sdk-container-infrastructure-management/sync", + "openstack-sdk-dns/sync", + "openstack-sdk-identity/sync", + "openstack-sdk-image/sync", + "openstack-sdk-load-balancer/sync", + "openstack-sdk-network/sync", + "openstack-sdk-object-store/sync", + "openstack-sdk-placement/sync" +] +async = ["openstack-sdk-core/async", + "openstack-sdk-block-storage/async", + "openstack-sdk-compute/async", + "openstack-sdk-container-infrastructure-management/async", + "openstack-sdk-dns/async", + "openstack-sdk-identity/async", + "openstack-sdk-image/async", + "openstack-sdk-load-balancer/async", + "openstack-sdk-network/async", + "openstack-sdk-object-store/async", + "openstack-sdk-placement/async" +] client_der = [] client_pem = [] keystone_ng = ["dep:openstack-sdk-auth-jwt", "dep:openstack-sdk-auth-federation"] passkey = ["keystone_ng", "dep:openstack-sdk-auth-passkey"] -#keystone_ng = [] -#passkey = ["keystone_ng", "openstack-sdk-core/passkey" ] [dependencies] async-trait.workspace = true -base64.workspace = true bytes.workspace = true chrono.workspace= true derive_builder.workspace = true -dialoguer.workspace = true futures.workspace = true futures-util.workspace = true http.workspace = true -json-patch.workspace = true inventory.workspace = true -openstack-sdk-auth-applicationcredential = { version = "0.1", path = "../auth-application-credential/" } -openstack-sdk-auth-core = { version = "0.22", path = "../auth-core/" } -openstack-sdk-auth-federation = { version = "0.1", path = "../auth-federation/", optional = true } -openstack-sdk-auth-jwt = { version = "0.1", path = "../auth-jwt/", optional = true } -openstack-sdk-auth-oidcaccesstoken = { version = "0.1", path = "../auth-oidcaccesstoken/" } -openstack-sdk-auth-passkey = { version = "0.1", path = "../auth-passkey/", optional = true } -openstack-sdk-auth-password = { version = "0.1", path = "../auth-password/" } -openstack-sdk-auth-receipt = { version = "0.1", path = "../auth-receipt/" } -openstack-sdk-auth-token = { version = "0.1", path = "../auth-token/" } -openstack-sdk-auth-totp = { version = "0.1", path = "../auth-totp/" } -openstack-sdk-auth-websso = { version = "0.1", path = "../auth-websso/" } -openstack-sdk-core = { path = "../sdk-core/", version = "^0.22" } -reqwest = { workspace = true, features = ["rustls", "stream", "gzip", "deflate", "http2", "socks", "system-proxy"] } +openstack-sdk-auth-applicationcredential = { version = "0.1", path = "../sdk/auth-application-credential/" } +openstack-sdk-auth-core = { version = "0.22", path = "../sdk/auth-core/" } +openstack-sdk-auth-federation = { version = "0.1", path = "../sdk/auth-federation/", optional = true } +openstack-sdk-auth-jwt = { version = "0.1", path = "../sdk/auth-jwt/", optional = true } +openstack-sdk-auth-oidcaccesstoken = { version = "0.1", path = "../sdk/auth-oidcaccesstoken/" } +openstack-sdk-auth-passkey = { version = "0.1", path = "../sdk/auth-passkey/", optional = true } +openstack-sdk-auth-password = { version = "0.1", path = "../sdk/auth-password/" } +openstack-sdk-auth-receipt = { version = "0.1", path = "../sdk/auth-receipt/" } +openstack-sdk-auth-token = { version = "0.1", path = "../sdk/auth-token/" } +openstack-sdk-auth-totp = { version = "0.1", path = "../sdk/auth-totp/" } +openstack-sdk-auth-websso = { version = "0.1", path = "../sdk/auth-websso/" } +openstack-sdk-core = { path = "../sdk/core/", version = "^0.22" } +openstack-sdk-block-storage = { path = "../sdk/block-storage/", version = "^0.1", optional = true } +openstack-sdk-compute = { path = "../sdk/compute/", version = "^0.1", optional = true } +openstack-sdk-container-infrastructure-management = { path = "../sdk/container-infrastructure-management/", version = "^0.1", optional = true } +openstack-sdk-dns = { path = "../sdk/dns/", version = "^0.1", optional = true } +openstack-sdk-identity = { path = "../sdk/identity/", version = "^0.1", optional = true } +openstack-sdk-image = { path = "../sdk/image/", version = "^0.1", optional = true } +openstack-sdk-load-balancer = { path = "../sdk/load-balancer/", version = "^0.1", optional = true } +openstack-sdk-network = { path = "../sdk/network/", version = "^0.1", optional = true } +openstack-sdk-object-store = { path = "../sdk/object-store/", version = "^0.1", optional = true } +openstack-sdk-placement= { path = "../sdk/placement/", version = "^0.1", optional = true } +reqwest = { workspace = true, features = ["rustls", "stream", "gzip", "deflate", "json", "http2", + "socks", "system-proxy"] } secrecy.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/openstack_sdk/src/api.rs b/openstack_sdk/src/api.rs index 54230b65e..8327a07d9 100644 --- a/openstack_sdk/src/api.rs +++ b/openstack_sdk/src/api.rs @@ -142,8 +142,6 @@ pub use openstack_sdk_core::api::*; mod client; mod error; -mod find; -//mod rest_endpoint; #[cfg(feature = "block_storage")] pub mod block_storage; @@ -172,6 +170,7 @@ pub use self::error::ApiError; pub use self::error::BodyError; pub use self::client::RestClient; +pub use openstack_sdk_core::api::Findable; pub use self::rest_endpoint::RestEndpoint; pub use self::rest_endpoint::check_response_error; diff --git a/openstack_sdk/src/api/block_storage.rs b/openstack_sdk/src/api/block_storage.rs index 5bda0b25b..ac5e2b17d 100644 --- a/openstack_sdk/src/api/block_storage.rs +++ b/openstack_sdk/src/api/block_storage.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Block Storage (Cinder) API bindings -pub mod v3; +//! # Block Storage (Cinder) API bindings +pub use openstack_sdk_block_storage::*; diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/delete.rs b/openstack_sdk/src/api/block_storage/v3/attachment/delete.rs deleted file mode 100644 index 6953d719f..000000000 --- a/openstack_sdk/src/api/block_storage/v3/attachment/delete.rs +++ /dev/null @@ -1,186 +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`. - -//! Delete an attachment. -//! -//! Disconnects/Deletes the specified attachment, returns a list of any known -//! shared attachment-id's for the effected backend device. -//! -//! returns: A summary list of any attachments sharing this connection -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/attachments/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("attachments/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/attachments/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/attachments/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/get.rs b/openstack_sdk/src/api/block_storage/v3/attachment/get.rs deleted file mode 100644 index ffd195fd7..000000000 --- a/openstack_sdk/src/api/block_storage/v3/attachment/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about the given attachment. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/attachments/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("attachments/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("attachment".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "attachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/attachments/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "attachment": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/attachments/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "attachment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/list.rs b/openstack_sdk/src/api/block_storage/v3/attachment/list.rs deleted file mode 100644 index fd9d3b859..000000000 --- a/openstack_sdk/src/api/block_storage/v3/attachment/list.rs +++ /dev/null @@ -1,231 +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`. - -//! Return a summary list of attachments. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "attachments".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("attachments".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "attachments" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/attachments".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "attachments": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/attachments".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "attachments": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/attachment/list_detailed.rs deleted file mode 100644 index ce0b70441..000000000 --- a/openstack_sdk/src/api/block_storage/v3/attachment/list_detailed.rs +++ /dev/null @@ -1,231 +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`. - -//! Return a detailed list of attachments. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "attachments/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("attachments".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "attachments" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/attachments/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "attachments": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/attachments/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "attachments": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/availability_zone/list.rs b/openstack_sdk/src/api/block_storage/v3/availability_zone/list.rs deleted file mode 100644 index 96f93f7ee..000000000 --- a/openstack_sdk/src/api/block_storage/v3/availability_zone/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Describe all known availability zones. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-availability-zone".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("availabilityZoneInfo".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availabilityZoneInfo" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-availability-zone".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availabilityZoneInfo": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-availability-zone".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availabilityZoneInfo": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/create_30.rs b/openstack_sdk/src/api/block_storage/v3/backup/create_30.rs deleted file mode 100644 index 64d113989..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/create_30.rs +++ /dev/null @@ -1,248 +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`. - -//! Create a new backup. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `backup` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Backup<'a> { - /// The container name or null. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) container: Option>>, - - /// The backup description or null. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Indicates whether to backup, even if the volume is attached. Default is - /// `false`. See [valid boolean values](#valid-boolean-values) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) force: Option, - - /// Indicates whether to backup, even if the volume is attached. Default is - /// `false`. See [valid boolean values](#valid-boolean-values) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) incremental: Option, - - /// The name of the Volume Backup. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The UUID of the source snapshot that you want to back up. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) snapshot_id: Option>>, - - /// The UUID of the volume that you want to back up. - #[serde()] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `backup` object. - #[builder(setter(into))] - pub(crate) backup: Backup<'a>, - - #[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 Backup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "backups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("backup", serde_json::to_value(&self.backup)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("backup".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "backup" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/backups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup": {} })); - }); - - let endpoint = Request::builder() - .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/backups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup": {} })); - }); - - let endpoint = Request::builder() - .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/delete.rs b/openstack_sdk/src/api/block_storage/v3/backup/delete.rs deleted file mode 100644 index 07c69bcde..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a backup. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/backups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Backup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("backups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/backups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/backups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/export_record/get.rs b/openstack_sdk/src/api/block_storage/v3/backup/export_record/get.rs deleted file mode 100644 index 1b114ac0b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/export_record/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Export a backup. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/backups/{id}/export_record 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<'a> RequestBuilder<'a> { - /// Add a single header to the Export_Record. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("backups/{id}/export_record", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("backup-record".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "backup-record" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/backups/{id}/export_record", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup-record": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/backups/{id}/export_record", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup-record": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/find.rs b/openstack_sdk/src/api/block_storage/v3/backup/find.rs deleted file mode 100644 index 5919fc8b5..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::backup::{get as Get, list_detailed as List}; - -/// Find for backup 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate backup in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // backup 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/backup/get.rs b/openstack_sdk/src/api/block_storage/v3/backup/get.rs deleted file mode 100644 index 827f035ff..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about the given backup. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/backups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Backup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("backups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("backup".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "backup" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/backups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/backups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/import_record/create.rs b/openstack_sdk/src/api/block_storage/v3/backup/import_record/create.rs deleted file mode 100644 index 03cfb1a80..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/import_record/create.rs +++ /dev/null @@ -1,247 +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`. - -//! Import a backup. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// An object recording volume backup metadata, including `backup_service` and -/// `backup_url`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct BackupRecord<'a> { - /// The service used to perform the backup. - #[serde()] - #[builder(setter(into))] - pub(crate) backup_service: Cow<'a, str>, - - /// An identifier string to locate the backup. - #[serde()] - #[builder(setter(into))] - pub(crate) backup_url: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An object recording volume backup metadata, including `backup_service` - /// and `backup_url`. - #[builder(setter(into))] - pub(crate) backup_record: BackupRecord<'a>, - - #[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 Import_Record. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "backups/import_record".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("backup-record", serde_json::to_value(&self.backup_record)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("backup".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .backup_record( - BackupRecordBuilder::default() - .backup_service("foo") - .backup_url("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .backup_record( - BackupRecordBuilder::default() - .backup_service("foo") - .backup_url("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "backup" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/backups/import_record".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup": {} })); - }); - - let endpoint = Request::builder() - .backup_record( - BackupRecordBuilder::default() - .backup_service("foo") - .backup_url("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/backups/import_record".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backup": {} })); - }); - - let endpoint = Request::builder() - .backup_record( - BackupRecordBuilder::default() - .backup_service("foo") - .backup_url("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/list.rs b/openstack_sdk/src/api/block_storage/v3/backup/list.rs deleted file mode 100644 index b1d869e8f..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/list.rs +++ /dev/null @@ -1,236 +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`. - -//! Returns a summary list of backups. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Whether to show count in API response or not, default is False. - #[builder(default)] - with_count: 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> { - /// Add a single header to the Backup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "backups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("with_count", self.with_count); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("backups".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "backups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/backups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/backups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/backup/list_detailed.rs deleted file mode 100644 index 68c07fd5a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/list_detailed.rs +++ /dev/null @@ -1,236 +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`. - -//! Returns a detailed list of backups. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Whether to show count in API response or not, default is False. - #[builder(default)] - with_count: 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> { - /// Add a single header to the Backup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "backups/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("with_count", self.with_count); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("backups".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "backups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/backups/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/backups/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "backups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/os_force_delete.rs b/openstack_sdk/src/api/block_storage/v3/backup/os_force_delete.rs deleted file mode 100644 index 7f8c7dd93..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/os_force_delete.rs +++ /dev/null @@ -1,211 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// OpenAPI specifies the field as '{}'. - #[builder(setter(into))] - pub(crate) os_force_delete: Value, - - /// id parameter for /v3/backups/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Backup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("backups/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "os-force_delete", - serde_json::to_value(&self.os_force_delete)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_force_delete(json!({})) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_force_delete(json!({})) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/backups/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_force_delete(json!({})) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/backups/{id}/action", 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") - .os_force_delete(json!({})) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/os_reset_status.rs b/openstack_sdk/src/api/block_storage/v3/backup/os_reset_status.rs deleted file mode 100644 index cbb142a4c..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/os_reset_status.rs +++ /dev/null @@ -1,239 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsResetStatus<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) status: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) os_reset_status: OsResetStatus<'a>, - - /// id parameter for /v3/backups/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Backup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("backups/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "os-reset_status", - serde_json::to_value(&self.os_reset_status)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/backups/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/backups/{id}/action", 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") - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/restore/create.rs b/openstack_sdk/src/api/block_storage/v3/backup/restore/create.rs deleted file mode 100644 index dab710a6f..000000000 --- a/openstack_sdk/src/api/block_storage/v3/backup/restore/create.rs +++ /dev/null @@ -1,223 +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`. - -//! Restore an existing backup to a volume. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Restore<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_id: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) restore: Option>, - - /// id parameter for /v3/backups/{id}/restore 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<'a> RequestBuilder<'a> { - /// Add a single header to the Restore. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("backups/{id}/restore", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("restore", serde_json::to_value(&self.restore)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("restore".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .restore(RestoreBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .restore(RestoreBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "restore" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/backups/{id}/restore", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "restore": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .restore(RestoreBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/backups/{id}/restore", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "restore": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .restore(RestoreBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/capability/get.rs b/openstack_sdk/src/api/block_storage/v3/capability/get.rs deleted file mode 100644 index 7db31a35a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/capability/get.rs +++ /dev/null @@ -1,181 +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`. - -//! Return capabilities list of given backend. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/capabilities/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Capability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("capabilities/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/capabilities/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/capabilities/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/create.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/create.rs deleted file mode 100644 index fbc15aa8a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/create.rs +++ /dev/null @@ -1,282 +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`. - -//! Create a new cgsnapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A consistency group snapshot object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Cgsnapshot<'a> { - /// The UUID of the consistency group. - #[serde()] - #[builder(setter(into))] - pub(crate) consistencygroup_id: Cow<'a, str>, - - /// The consistency group snapshot description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The name of the snapshot. Default is `None`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> CgsnapshotBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A consistency group snapshot object. - #[builder(setter(into))] - pub(crate) cgsnapshot: Cgsnapshot<'a>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Cgsnapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "cgsnapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("cgsnapshot", serde_json::to_value(&self.cgsnapshot)?); - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .cgsnapshot( - CgsnapshotBuilder::default() - .consistencygroup_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .cgsnapshot( - CgsnapshotBuilder::default() - .consistencygroup_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/cgsnapshots".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .cgsnapshot( - CgsnapshotBuilder::default() - .consistencygroup_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/cgsnapshots".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() - .cgsnapshot( - CgsnapshotBuilder::default() - .consistencygroup_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/delete.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/delete.rs deleted file mode 100644 index 8bf1e9ceb..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a cgsnapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/cgsnapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Cgsnapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("cgsnapshots/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/cgsnapshots/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/cgsnapshots/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/get.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/get.rs deleted file mode 100644 index f718c3687..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/get.rs +++ /dev/null @@ -1,181 +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`. - -//! Return data about the given cgsnapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/cgsnapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Cgsnapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("cgsnapshots/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/cgsnapshots/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/cgsnapshots/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list.rs deleted file mode 100644 index 0aee7332b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a summary list of cgsnapshots. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Cgsnapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "cgsnapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/cgsnapshots".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/cgsnapshots".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list_detailed.rs deleted file mode 100644 index f86c4ce01..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list_detailed.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a detailed list of cgsnapshots. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Cgsnapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "cgsnapshots/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/cgsnapshots/detail".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/cgsnapshots/detail".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cluster/get.rs b/openstack_sdk/src/api/block_storage/v3/cluster/get.rs deleted file mode 100644 index 9bb5b82f9..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cluster/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data for a given cluster name with optional binary. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/clusters/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Cluster. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("cluster".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "cluster" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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!({ "cluster": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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!({ "cluster": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cluster/list.rs b/openstack_sdk/src/api/block_storage/v3/cluster/list.rs deleted file mode 100644 index 960641bfa..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cluster/list.rs +++ /dev/null @@ -1,220 +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`. - -//! Return a non detailed list of all existing clusters. -//! -//! Filter by is_up, disabled, num_hosts, and num_down_hosts. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filter the cluster list result by binary name of the clustered - /// services. One of cinder-api, cinder-scheduler, cinder-volume or - /// cinder-backup. - #[builder(default, setter(into))] - binary: Option>, - - /// Filter the cluster list result by status. - #[builder(default)] - disabled: Option, - - /// Filter the cluster list result by state. - #[builder(default)] - is_up: Option, - - /// Filter the cluster list result by cluster name. - #[builder(default, setter(into))] - name: Option>, - - /// Filter the cluster list result by number of down hosts. - #[builder(default)] - num_down_hosts: Option, - - /// Filter the cluster list result by number of hosts. - #[builder(default)] - num_hosts: Option, - - /// Filter the cluster list result by replication status. - #[builder(default, setter(into))] - replication_stats: 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> { - /// Add a single header to the Cluster. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'_> { - let mut params = QueryParams::default(); - params.push_opt("binary", self.binary.as_ref()); - params.push_opt("disabled", self.disabled); - params.push_opt("is_up", self.is_up); - params.push_opt("name", self.name.as_ref()); - params.push_opt("num_down_hosts", self.num_down_hosts); - params.push_opt("num_hosts", self.num_hosts); - params.push_opt("replication_stats", self.replication_stats.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "clusters" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/cluster/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/cluster/list_detailed.rs deleted file mode 100644 index 97f06281c..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cluster/list_detailed.rs +++ /dev/null @@ -1,230 +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`. - -//! Return a detailed list of all existing clusters. -//! -//! Filter by is_up, disabled, num_hosts, and num_down_hosts. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of active storage backend. Only in cinder-volume service. - #[builder(default, setter(into))] - active_backend_id: Option>, - - /// Filter the cluster list result by binary name of the clustered - /// services. One of cinder-api, cinder-scheduler, cinder-volume or - /// cinder-backup. - #[builder(default, setter(into))] - binary: Option>, - - /// Filter the cluster list result by status. - #[builder(default)] - disabled: Option, - - /// Whether the cluster is frozen or not. - #[builder(default)] - frozen: Option, - - /// Filter the cluster list result by state. - #[builder(default)] - is_up: Option, - - /// Filter the cluster list result by cluster name. - #[builder(default, setter(into))] - name: Option>, - - /// Filter the cluster list result by number of down hosts. - #[builder(default)] - num_down_hosts: Option, - - /// Filter the cluster list result by number of hosts. - #[builder(default)] - num_hosts: Option, - - /// Filter the cluster list result by replication status. - #[builder(default, setter(into))] - replication_stats: 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> { - /// Add a single header to the Cluster. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("active_backend_id", self.active_backend_id.as_ref()); - params.push_opt("binary", self.binary.as_ref()); - params.push_opt("disabled", self.disabled); - params.push_opt("frozen", self.frozen); - params.push_opt("is_up", self.is_up); - params.push_opt("name", self.name.as_ref()); - params.push_opt("num_down_hosts", self.num_down_hosts); - params.push_opt("num_hosts", self.num_hosts); - params.push_opt("replication_stats", self.replication_stats.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "clusters" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/clusters/detail".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/clusters/detail".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create.rs deleted file mode 100644 index dae3dad50..000000000 --- a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create.rs +++ /dev/null @@ -1,290 +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`. - -//! Create a new consistency group. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A consistency group. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Consistencygroup<'a> { - /// OpenAPI specifies the field as '{}'. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option, - - /// The consistency group description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The consistency group name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// OpenAPI specifies the field as '{}'. - #[serde()] - #[builder(setter(into))] - pub(crate) volume_types: Value, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> ConsistencygroupBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A consistency group. - #[builder(setter(into))] - pub(crate) consistencygroup: Consistencygroup<'a>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Consistencygroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "consistencygroups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "consistencygroup", - serde_json::to_value(&self.consistencygroup)?, - ); - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .consistencygroup( - ConsistencygroupBuilder::default() - .volume_types(json!({})) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .consistencygroup( - ConsistencygroupBuilder::default() - .volume_types(json!({})) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/consistencygroups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consistencygroup( - ConsistencygroupBuilder::default() - .volume_types(json!({})) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/consistencygroups".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() - .consistencygroup( - ConsistencygroupBuilder::default() - .volume_types(json!({})) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src/create.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src/create.rs deleted file mode 100644 index 316073379..000000000 --- a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src/create.rs +++ /dev/null @@ -1,277 +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`. - -//! Create a new consistency group from a source. -//! -//! The source can be a CG snapshot or a CG. Note that this does not require -//! volume_types as the "create" API above. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// The consistency group from source object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ConsistencygroupFromSrc<'a> { - /// The UUID of the consistency group snapshot. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cgsnapshot_id: Option>, - - /// The consistency group description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The name of the object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The UUID of the source consistency group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) source_cgid: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> ConsistencygroupFromSrcBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The consistency group from source object. - #[builder(setter(into))] - pub(crate) consistencygroup_from_src: ConsistencygroupFromSrc<'a>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Create_From_Src. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "consistencygroups/create_from_src".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "consistencygroup-from-src", - serde_json::to_value(&self.consistencygroup_from_src)?, - ); - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .consistencygroup_from_src( - ConsistencygroupFromSrcBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .consistencygroup_from_src( - ConsistencygroupFromSrcBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/consistencygroups/create_from_src".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consistencygroup_from_src(ConsistencygroupFromSrcBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/consistencygroups/create_from_src".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() - .consistencygroup_from_src(ConsistencygroupFromSrcBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete/create.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete/create.rs deleted file mode 100644 index 7371f8bf6..000000000 --- a/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete/create.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a consistency group. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/consistencygroups/{id}/delete 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<'a> RequestBuilder<'a> { - /// Add a single header to the Delete. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("consistencygroups/{id}/delete", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/consistencygroups/{id}/delete", 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/consistencygroups/{id}/delete", 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/get.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/get.rs deleted file mode 100644 index 29ec6e6d6..000000000 --- a/openstack_sdk/src/api/block_storage/v3/consistencygroup/get.rs +++ /dev/null @@ -1,181 +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`. - -//! Return data about the given consistency group. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/consistencygroups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Consistencygroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("consistencygroups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/consistencygroups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/consistencygroups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/list.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/list.rs deleted file mode 100644 index 7346bd166..000000000 --- a/openstack_sdk/src/api/block_storage/v3/consistencygroup/list.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a summary list of consistency groups. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Consistencygroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "consistencygroups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/consistencygroups".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/consistencygroups".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/list_detailed.rs deleted file mode 100644 index 7b6f766ef..000000000 --- a/openstack_sdk/src/api/block_storage/v3/consistencygroup/list_detailed.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a detailed list of consistency groups. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Consistencygroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "consistencygroups/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/consistencygroups/detail".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/consistencygroups/detail".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/set.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/set.rs deleted file mode 100644 index 64803f60d..000000000 --- a/openstack_sdk/src/api/block_storage/v3/consistencygroup/set.rs +++ /dev/null @@ -1,284 +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`. - -//! Update the consistency group. -//! -//! Expected format of the input parameter 'body': -//! -//! ```text -//! { -//! "consistencygroup": -//! { -//! "name": "my_cg", -//! "description": "My consistency group", -//! "add_volumes": "volume-uuid-1,volume-uuid-2,...", -//! "remove_volumes": "volume-uuid-8,volume-uuid-9,..." -//! } -//! } -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Consistencygroup<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) add_volumes: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remove_volumes: Option>>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> ConsistencygroupBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) consistencygroup: Consistencygroup<'a>, - - /// id parameter for /v3/consistencygroups/{id}/update API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Consistencygroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("consistencygroups/{id}/update", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "consistencygroup", - serde_json::to_value(&self.consistencygroup)?, - ); - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/consistencygroups/{id}/update", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/consistencygroups/{id}/update", 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") - .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/default_type/delete.rs b/openstack_sdk/src/api/block_storage/v3/default_type/delete.rs deleted file mode 100644 index bf0cc1764..000000000 --- a/openstack_sdk/src/api/block_storage/v3/default_type/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Unset a default volume type for a project. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/default-types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Default_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("default-types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/default-types/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/default-types/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/default_type/get.rs b/openstack_sdk/src/api/block_storage/v3/default_type/get.rs deleted file mode 100644 index 01a6ffae8..000000000 --- a/openstack_sdk/src/api/block_storage/v3/default_type/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return detail of a default type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/default-types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Default_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("default-types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("default_type".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "default_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/default-types/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_type": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/default-types/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/default_type/list.rs b/openstack_sdk/src/api/block_storage/v3/default_type/list.rs deleted file mode 100644 index cd42bf251..000000000 --- a/openstack_sdk/src/api/block_storage/v3/default_type/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Return a list of default types. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Default_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "default-types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("default_types".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "default_types" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/default-types".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_types": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/default-types".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_types": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/extension/list.rs b/openstack_sdk/src/api/block_storage/v3/extension/list.rs deleted file mode 100644 index 4b252521b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/extension/list.rs +++ /dev/null @@ -1,175 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Extension. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "extensions".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("extensions".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "extensions" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/extensions".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extensions": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/extensions".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extensions": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group/create_313.rs b/openstack_sdk/src/api/block_storage/v3/group/create_313.rs deleted file mode 100644 index 9c861a5f8..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group/create_313.rs +++ /dev/null @@ -1,264 +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`. - -//! Create a new group. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A group object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Group<'a> { - /// The name of the availability zone. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// The group description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The group type ID. - #[serde()] - #[builder(setter(into))] - pub(crate) group_type: Cow<'a, str>, - - /// The group name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The list of volume types. In an environment with multiple-storage back - /// ends, the scheduler determines where to send the volume based on the - /// volume type. For information about how to use volume types to create - /// multiple- storage back ends, see - /// [Configure multiple-storage back ends](https://docs.openstack.org/cinder/latest/admin/blockstorage-multi-backend.html). - #[serde()] - #[builder(setter(into))] - pub(crate) volume_types: Vec>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A group object. - #[builder(setter(into))] - pub(crate) group: Group<'a>, - - #[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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("group", serde_json::to_value(&self.group)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group".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(3, 13)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .group( - GroupBuilder::default() - .group_type("foo") - .volume_types(Vec::from(["foo".into()])) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .group( - GroupBuilder::default() - .group_type("foo") - .volume_types(Vec::from(["foo".into()])) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .group( - GroupBuilder::default() - .group_type("foo") - .volume_types(Vec::from(["foo".into()])) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .group( - GroupBuilder::default() - .group_type("foo") - .volume_types(Vec::from(["foo".into()])) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group/find.rs b/openstack_sdk/src/api/block_storage/v3/group/find.rs deleted file mode 100644 index 2db72255d..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::group::{get as Get, list_detailed as List}; - -/// Find for group 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate group in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // group 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/group/get.rs b/openstack_sdk/src/api/block_storage/v3/group/get.rs deleted file mode 100644 index 131513ac2..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about the given group. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group/list.rs b/openstack_sdk/src/api/block_storage/v3/group/list.rs deleted file mode 100644 index 94eb92a9a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group/list.rs +++ /dev/null @@ -1,231 +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`. - -//! Returns a summary list of groups. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("groups".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/group/list_detailed.rs deleted file mode 100644 index d3a0e0b73..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group/list_detailed.rs +++ /dev/null @@ -1,231 +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`. - -//! Returns a detailed list of groups. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "groups/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("groups".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/groups/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/groups/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_snapshot/delete.rs b/openstack_sdk/src/api/block_storage/v3/group_snapshot/delete.rs deleted file mode 100644 index 0c0040d47..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_snapshot/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a group_snapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/group_snapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("group_snapshots/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/group_snapshots/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/group_snapshots/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_snapshot/find.rs b/openstack_sdk/src/api/block_storage/v3/group_snapshot/find.rs deleted file mode 100644 index 87c4da594..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_snapshot/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::group_snapshot::{get as Get, list_detailed as List}; - -/// Find for group_snapshot 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate group_snapshot in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // group_snapshot 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/group_snapshot/get.rs b/openstack_sdk/src/api/block_storage/v3/group_snapshot/get.rs deleted file mode 100644 index 633c95430..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_snapshot/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about the given group_snapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/group_snapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("group_snapshots/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_snapshot".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group_snapshot" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/group_snapshots/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_snapshot": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/group_snapshots/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_snapshot": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_snapshot/list.rs b/openstack_sdk/src/api/block_storage/v3/group_snapshot/list.rs deleted file mode 100644 index 10053b8e0..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_snapshot/list.rs +++ /dev/null @@ -1,231 +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`. - -//! Returns a summary list of group_snapshots. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Group_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "group_snapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_snapshots".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group_snapshots" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/group_snapshots".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_snapshots": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/group_snapshots".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_snapshots": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_snapshot/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/group_snapshot/list_detailed.rs deleted file mode 100644 index cc7d0d32b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_snapshot/list_detailed.rs +++ /dev/null @@ -1,231 +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`. - -//! Returns a detailed list of group_snapshots. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Group_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "group_snapshots/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_snapshots".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group_snapshots" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/group_snapshots/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_snapshots": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/group_snapshots/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_snapshots": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/create_311.rs b/openstack_sdk/src/api/block_storage/v3/group_type/create_311.rs deleted file mode 100644 index 41fe5a059..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/create_311.rs +++ /dev/null @@ -1,252 +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`. - -//! Creates a new group type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `group_type` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct GroupType<'a> { - /// The group type description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// A set of key and value pairs that contains the specifications for a - /// group type. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_group_specs"))] - pub(crate) group_specs: Option, Cow<'a, str>>>>, - - /// Whether the group type is publicly visible. See - /// [valid boolean values](#valid-boolean-values) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_public: Option, - - /// The group type name. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -impl<'a> GroupTypeBuilder<'a> { - /// A set of key and value pairs that contains the specifications for a - /// group type. - pub fn group_specs(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.group_specs - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `group_type` object. - #[builder(setter(into))] - pub(crate) group_type: GroupType<'a>, - - #[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 Group_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "group_types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("group_type", serde_json::to_value(&self.group_type)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_type".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(3, 11)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "group_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/group_types".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_type": {} })); - }); - - let endpoint = Request::builder() - .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/group_types".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_type": {} })); - }); - - let endpoint = Request::builder() - .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/delete.rs b/openstack_sdk/src/api/block_storage/v3/group_type/delete.rs deleted file mode 100644 index 8775358d7..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Deletes an existing group type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/group_types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("group_types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/group_types/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/group_types/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/find.rs b/openstack_sdk/src/api/block_storage/v3/group_type/find.rs deleted file mode 100644 index 0b6e89114..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::group_type::{get as Get, list as List}; - -/// Find for group_type 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate group_type in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // group_type 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/group_type/get.rs b/openstack_sdk/src/api/block_storage/v3/group_type/get.rs deleted file mode 100644 index bb8bdb1bc..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return a single group type item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/group_types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("group_types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_type".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/group_types/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_type": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/group_types/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/create_311.rs b/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/create_311.rs deleted file mode 100644 index 306ca6453..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/create_311.rs +++ /dev/null @@ -1,250 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A set of key and value pairs that contains the specifications for a - /// group type. - #[builder(private, setter(into, name = "_group_specs"))] - pub(crate) group_specs: BTreeMap, Option>>, - - /// group_type_id parameter for - /// /v3/group_types/{group_type_id}/group_specs/{id} API - #[builder(default, setter(into))] - group_type_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> { - /// A set of key and value pairs that contains the specifications for a - /// group type. - pub fn group_specs(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>>, - { - self.group_specs - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Group_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "group_types/{group_type_id}/group_specs", - group_type_id = self.group_type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("group_specs", serde_json::to_value(&self.group_specs)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_specs".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(3, 11)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .group_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))) - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .group_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))) - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "group_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/group_types/{group_type_id}/group_specs", - group_type_id = "group_type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_specs": {} })); - }); - - let endpoint = Request::builder() - .group_type_id("group_type_id") - .group_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/group_types/{group_type_id}/group_specs", - group_type_id = "group_type_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_specs": {} })); - }); - - let endpoint = Request::builder() - .group_type_id("group_type_id") - .group_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/delete.rs b/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/delete.rs deleted file mode 100644 index 34d0209a0..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/delete.rs +++ /dev/null @@ -1,203 +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`. - -//! Deletes an existing group spec. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_type_id parameter for - /// /v3/group_types/{group_type_id}/group_specs/{id} API - #[builder(default, setter(into))] - group_type_id: Cow<'a, str>, - - /// id parameter for /v3/group_types/{group_type_id}/group_specs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "group_types/{group_type_id}/group_specs/{id}", - group_type_id = self.group_type_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/group_types/{group_type_id}/group_specs/{id}", - group_type_id = "group_type_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_type_id("group_type_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/group_types/{group_type_id}/group_specs/{id}", - group_type_id = "group_type_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() - .group_type_id("group_type_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/get.rs b/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/get.rs deleted file mode 100644 index 4019ed834..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/get.rs +++ /dev/null @@ -1,203 +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`. - -//! Return a single extra spec item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_type_id parameter for - /// /v3/group_types/{group_type_id}/group_specs/{id} API - #[builder(default, setter(into))] - group_type_id: Cow<'a, str>, - - /// id parameter for /v3/group_types/{group_type_id}/group_specs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "group_types/{group_type_id}/group_specs/{id}", - group_type_id = self.group_type_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/group_types/{group_type_id}/group_specs/{id}", - group_type_id = "group_type_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_type_id("group_type_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/group_types/{group_type_id}/group_specs/{id}", - group_type_id = "group_type_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() - .group_type_id("group_type_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/list.rs b/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/list.rs deleted file mode 100644 index 0a41841cd..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/list.rs +++ /dev/null @@ -1,197 +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`. - -//! Returns the list of group specs for a given group type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_type_id parameter for - /// /v3/group_types/{group_type_id}/group_specs/{id} API - #[builder(default, setter(into))] - group_type_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 Group_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "group_types/{group_type_id}/group_specs", - group_type_id = self.group_type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_specs".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/group_types/{group_type_id}/group_specs", - group_type_id = "group_type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_specs": {} })); - }); - - let endpoint = Request::builder() - .group_type_id("group_type_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/group_types/{group_type_id}/group_specs", - group_type_id = "group_type_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_specs": {} })); - }); - - let endpoint = Request::builder() - .group_type_id("group_type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/set_311.rs b/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/set_311.rs deleted file mode 100644 index 2a06ab862..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec/set_311.rs +++ /dev/null @@ -1,227 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_type_id parameter for - /// /v3/group_types/{group_type_id}/group_specs/{id} API - #[builder(default, setter(into))] - group_type_id: Cow<'a, str>, - - /// id parameter for /v3/group_types/{group_type_id}/group_specs/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, 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 Group_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>>, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "group_types/{group_type_id}/group_specs/{id}", - group_type_id = self.group_type_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 11)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/group_types/{group_type_id}/group_specs/{id}", - group_type_id = "group_type_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_type_id("group_type_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/group_types/{group_type_id}/group_specs/{id}", - group_type_id = "group_type_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() - .group_type_id("group_type_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/list.rs b/openstack_sdk/src/api/block_storage/v3/group_type/list.rs deleted file mode 100644 index 44f35f472..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/list.rs +++ /dev/null @@ -1,231 +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`. - -//! Returns the list of group types. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Group_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "group_types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_types".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group_types" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/group_types".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_types": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/group_types".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_types": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/set_311.rs b/openstack_sdk/src/api/block_storage/v3/group_type/set_311.rs deleted file mode 100644 index 1acc8172a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/group_type/set_311.rs +++ /dev/null @@ -1,225 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct GroupType<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_public: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) group_type: GroupType<'a>, - - /// id parameter for /v3/group_types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Group_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("group_types/{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("group_type", serde_json::to_value(&self.group_type)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("group_type".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(3, 11)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .group_type(GroupTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .group_type(GroupTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "group_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/group_types/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .group_type(GroupTypeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/group_types/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .group_type(GroupTypeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/host/get.rs b/openstack_sdk/src/api/block_storage/v3/host/get.rs deleted file mode 100644 index c719a6608..000000000 --- a/openstack_sdk/src/api/block_storage/v3/host/get.rs +++ /dev/null @@ -1,184 +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 Host Details for a project -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/os-hosts/{id} API - #[builder(default, setter(into))] - host_name: 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 Host. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-hosts/{host_name}", host_name = self.host_name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("host".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "host" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hosts/{host_name}", host_name = "host_name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "host": {} })); - }); - - let endpoint = Request::builder().host_name("host_name").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hosts/{host_name}", host_name = "host_name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "host": {} })); - }); - - let endpoint = Request::builder() - .host_name("host_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/host/list.rs b/openstack_sdk/src/api/block_storage/v3/host/list.rs deleted file mode 100644 index 53d46c380..000000000 --- a/openstack_sdk/src/api/block_storage/v3/host/list.rs +++ /dev/null @@ -1,177 +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`. - -//! List all hosts for a project -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Host. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-hosts".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("hosts".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "hosts" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hosts".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hosts": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hosts".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hosts": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/limit/list.rs b/openstack_sdk/src/api/block_storage/v3/limit/list.rs deleted file mode 100644 index 40f0ccbb3..000000000 --- a/openstack_sdk/src/api/block_storage/v3/limit/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Return all global and rate limit information. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "limits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("limits".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "limits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/create.rs b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/create.rs deleted file mode 100644 index 109877e9c..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/create.rs +++ /dev/null @@ -1,322 +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`. - -//! Instruct Cinder to manage a storage snapshot object. -//! -//! Manages an existing backend storage snapshot object (e.g. a Linux logical -//! volume or a SAN disk) by creating the Cinder objects required to manage it, -//! and possibly renaming the backend storage snapshot object (driver -//! dependent). -//! -//! From an API perspective, this operation behaves very much like a snapshot -//! creation operation. -//! -//! Required HTTP Body: -//! -//! ```text -//! { -//! "snapshot": -//! { -//! "volume_id": "", -//! "ref": -//! "" -//! } -//! } -//! ``` -//! -//! See the appropriate Cinder drivers' implementations of the manage_snapshot -//! method to find out the accepted format of 'ref'. For example,in LVM driver, -//! it will be the logic volume name of snapshot which you want to manage. -//! -//! This API call will return with an error if any of the above elements are -//! missing from the request, or if the 'volume_id' element refers to a cinder -//! volume that could not be found. -//! -//! The snapshot will later enter the error state if it is discovered that -//! 'ref' is bad. -//! -//! Optional elements to 'snapshot' are: -//! -//! ```text -//! name A name for the new snapshot. -//! description A description for the new snapshot. -//! metadata Key/value pairs to be associated with the new snapshot. -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `snapshot` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Snapshot<'a> { - /// A description for the snapshot. Default is `None`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// One or more metadata key and value pairs for the snapshot. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - /// The name of the snapshot. Default is `None`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// A reference to the existing volume. The internal structure of this - /// reference depends on the volume driver implementation. For details - /// about the required elements in the structure, see the documentation for - /// the volume driver. - #[serde(rename = "ref")] - #[builder(setter(into))] - pub(crate) _ref: Option, - - /// The UUID of the volume. - #[serde()] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -impl<'a> SnapshotBuilder<'a> { - /// One or more metadata key and value pairs for the snapshot. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `snapshot` object. - #[builder(setter(into))] - pub(crate) snapshot: Snapshot<'a>, - - #[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 Manageable_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_snapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("snapshot", serde_json::to_value(&self.snapshot)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("snapshot".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "snapshot" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_snapshots".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_snapshots".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/get.rs b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/get.rs deleted file mode 100644 index 9640e3ed8..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/get.rs +++ /dev/null @@ -1,223 +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`. - -//! Returns a summary list of volumes available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Manageable_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_snapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_snapshots".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_snapshots".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/list_detailed.rs deleted file mode 100644 index 6b5277682..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/list_detailed.rs +++ /dev/null @@ -1,223 +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`. - -//! Returns a detailed list of volumes available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Manageable_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_snapshots/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_snapshots/detail".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_snapshots/detail".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/create.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/create.rs deleted file mode 100644 index 926f38120..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_volume/create.rs +++ /dev/null @@ -1,324 +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`. - -//! Instruct Cinder to manage a storage object. -//! -//! Manages an existing backend storage object (e.g. a Linux logical volume or -//! a SAN disk) by creating the Cinder objects required to manage it, and -//! possibly renaming the backend storage object (driver dependent) -//! -//! From an API perspective, this operation behaves very much like a volume -//! creation operation, except that properties such as image, snapshot and -//! volume references don't make sense, because we are taking an existing -//! storage object into Cinder management. -//! -//! Required HTTP Body: -//! -//! ```text -//! { -//! "volume": { -//! "host": "", -//! "cluster": "", -//! "ref": "" -//! } -//! } -//! ``` -//! -//! See the appropriate Cinder drivers' implementations of the manage_volume -//! method to find out the accepted format of 'ref'. -//! -//! This API call will return with an error if any of the above elements are -//! missing from the request, or if the 'host' element refers to a cinder host -//! that is not registered. -//! -//! The volume will later enter the error state if it is discovered that 'ref' -//! is bad. -//! -//! Optional elements to 'volume' are: -//! -//! ```text -//! name A name for the new volume. -//! description A description for the new volume. -//! volume_type ID or name of a volume type to associate with -//! the new Cinder volume. Does not necessarily -//! guarantee that the managed volume will have the -//! properties described in the volume_type. The -//! driver may choose to fail if it identifies that -//! the specified volume_type is not compatible with -//! the backend storage object. -//! metadata Key/value pairs to be associated with the new -//! volume. -//! availability_zone The availability zone to associate with the new -//! volume. -//! bootable If set to True, marks the volume as bootable. -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use crate::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `volume` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Volume<'a> { - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// Enables or disables the bootable attribute. You can boot an instance - /// from a bootable volume. See - /// [valid boolean values](#valid-boolean-values) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bootable: Option, - - /// The volume description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The OpenStack Block Storage host where the existing resource resides. - /// Optional only if cluster field is provided. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host: Option>>, - - /// One or more metadata key and value pairs to be associated with the new - /// volume. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// A reference to the existing volume. The internal structure of this - /// reference depends on the volume driver implementation. For details - /// about the required elements in the structure, see the documentation for - /// the volume driver. - #[serde(rename = "ref")] - #[builder(setter(into))] - pub(crate) _ref: Value, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_type: Option>>, -} - -impl<'a> VolumeBuilder<'a> { - /// One or more metadata key and value pairs to be associated with the new - /// volume. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `volume` object. - #[builder(setter(into))] - pub(crate) volume: Volume<'a>, - - #[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 Manageable_Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_volumes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("volume", serde_json::to_value(&self.volume)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - #[cfg(feature = "sync")] - use crate::api::Query; - use crate::test::client::FakeOpenStackClient; - use crate::types::ServiceType; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - use serde_json::json; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .response_key() - .is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_volumes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_volumes".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() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/create_30.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/create_30.rs deleted file mode 100644 index 657a9e19e..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_volume/create_30.rs +++ /dev/null @@ -1,327 +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`. - -//! Instruct Cinder to manage a storage object. -//! -//! Manages an existing backend storage object (e.g. a Linux logical volume or -//! a SAN disk) by creating the Cinder objects required to manage it, and -//! possibly renaming the backend storage object (driver dependent) -//! -//! From an API perspective, this operation behaves very much like a volume -//! creation operation, except that properties such as image, snapshot and -//! volume references don't make sense, because we are taking an existing -//! storage object into Cinder management. -//! -//! Required HTTP Body: -//! -//! ```text -//! { -//! "volume": { -//! "host": "", -//! "cluster": "", -//! "ref": "" -//! } -//! } -//! ``` -//! -//! See the appropriate Cinder drivers' implementations of the manage_volume -//! method to find out the accepted format of 'ref'. -//! -//! This API call will return with an error if any of the above elements are -//! missing from the request, or if the 'host' element refers to a cinder host -//! that is not registered. -//! -//! The volume will later enter the error state if it is discovered that 'ref' -//! is bad. -//! -//! Optional elements to 'volume' are: -//! -//! ```text -//! name A name for the new volume. -//! description A description for the new volume. -//! volume_type ID or name of a volume type to associate with -//! the new Cinder volume. Does not necessarily -//! guarantee that the managed volume will have the -//! properties described in the volume_type. The -//! driver may choose to fail if it identifies that -//! the specified volume_type is not compatible with -//! the backend storage object. -//! metadata Key/value pairs to be associated with the new -//! volume. -//! availability_zone The availability zone to associate with the new -//! volume. -//! bootable If set to True, marks the volume as bootable. -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `volume` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Volume<'a> { - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// Enables or disables the bootable attribute. You can boot an instance - /// from a bootable volume. See - /// [valid boolean values](#valid-boolean-values) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bootable: Option, - - /// The volume description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The OpenStack Block Storage host where the existing resource resides. - /// Optional only if cluster field is provided. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host: Option>>, - - /// One or more metadata key and value pairs to be associated with the new - /// volume. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// A reference to the existing volume. The internal structure of this - /// reference depends on the volume driver implementation. For details - /// about the required elements in the structure, see the documentation for - /// the volume driver. - #[serde(rename = "ref")] - #[builder(setter(into))] - pub(crate) _ref: Value, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_type: Option>>, -} - -impl<'a> VolumeBuilder<'a> { - /// One or more metadata key and value pairs to be associated with the new - /// volume. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `volume` object. - #[builder(setter(into))] - pub(crate) volume: Volume<'a>, - - #[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 Manageable_Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_volumes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("volume", serde_json::to_value(&self.volume)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_volumes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_volumes".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() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/create_316.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/create_316.rs deleted file mode 100644 index 3ad5c2f8c..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_volume/create_316.rs +++ /dev/null @@ -1,333 +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`. - -//! Instruct Cinder to manage a storage object. -//! -//! Manages an existing backend storage object (e.g. a Linux logical volume or -//! a SAN disk) by creating the Cinder objects required to manage it, and -//! possibly renaming the backend storage object (driver dependent) -//! -//! From an API perspective, this operation behaves very much like a volume -//! creation operation, except that properties such as image, snapshot and -//! volume references don't make sense, because we are taking an existing -//! storage object into Cinder management. -//! -//! Required HTTP Body: -//! -//! ```text -//! { -//! "volume": { -//! "host": "", -//! "cluster": "", -//! "ref": "" -//! } -//! } -//! ``` -//! -//! See the appropriate Cinder drivers' implementations of the manage_volume -//! method to find out the accepted format of 'ref'. -//! -//! This API call will return with an error if any of the above elements are -//! missing from the request, or if the 'host' element refers to a cinder host -//! that is not registered. -//! -//! The volume will later enter the error state if it is discovered that 'ref' -//! is bad. -//! -//! Optional elements to 'volume' are: -//! -//! ```text -//! name A name for the new volume. -//! description A description for the new volume. -//! volume_type ID or name of a volume type to associate with -//! the new Cinder volume. Does not necessarily -//! guarantee that the managed volume will have the -//! properties described in the volume_type. The -//! driver may choose to fail if it identifies that -//! the specified volume_type is not compatible with -//! the backend storage object. -//! metadata Key/value pairs to be associated with the new -//! volume. -//! availability_zone The availability zone to associate with the new -//! volume. -//! bootable If set to True, marks the volume as bootable. -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `volume` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Volume<'a> { - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// Enables or disables the bootable attribute. You can boot an instance - /// from a bootable volume. See - /// [valid boolean values](#valid-boolean-values) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bootable: Option, - - /// The OpenStack Block Storage cluster where the resource resides. - /// Optional only if host field is provided. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cluster: Option>>, - - /// The volume description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The OpenStack Block Storage host where the existing resource resides. - /// Optional only if cluster field is provided. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host: Option>>, - - /// One or more metadata key and value pairs to be associated with the new - /// volume. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// A reference to the existing volume. The internal structure of this - /// reference depends on the volume driver implementation. For details - /// about the required elements in the structure, see the documentation for - /// the volume driver. - #[serde(rename = "ref")] - #[builder(setter(into))] - pub(crate) _ref: Value, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_type: Option>>, -} - -impl<'a> VolumeBuilder<'a> { - /// One or more metadata key and value pairs to be associated with the new - /// volume. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `volume` object. - #[builder(setter(into))] - pub(crate) volume: Volume<'a>, - - #[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 Manageable_Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_volumes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("volume", serde_json::to_value(&self.volume)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 16)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_volumes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/manageable_volumes".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() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/get.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/get.rs deleted file mode 100644 index d69b8318c..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_volume/get.rs +++ /dev/null @@ -1,223 +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`. - -//! Returns a summary list of volumes available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Manageable_Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_volumes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_volumes".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_volumes".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/list_detailed.rs deleted file mode 100644 index fc0c2d07d..000000000 --- a/openstack_sdk/src/api/block_storage/v3/manageable_volume/list_detailed.rs +++ /dev/null @@ -1,223 +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`. - -//! Returns a detailed list of volumes available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Manageable_Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "manageable_volumes/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_volumes/detail".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/manageable_volumes/detail".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/message/delete.rs b/openstack_sdk/src/api/block_storage/v3/message/delete.rs deleted file mode 100644 index 2e14c6153..000000000 --- a/openstack_sdk/src/api/block_storage/v3/message/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a message. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/messages/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Message. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("messages/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/messages/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/messages/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/message/get.rs b/openstack_sdk/src/api/block_storage/v3/message/get.rs deleted file mode 100644 index 5b18e94d8..000000000 --- a/openstack_sdk/src/api/block_storage/v3/message/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return the given message. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/messages/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Message. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("messages/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("message".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "message" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/messages/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "message": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/messages/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "message": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/message/list.rs b/openstack_sdk/src/api/block_storage/v3/message/list.rs deleted file mode 100644 index 5c87fa17d..000000000 --- a/openstack_sdk/src/api/block_storage/v3/message/list.rs +++ /dev/null @@ -1,226 +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`. - -//! Returns a list of messages, transformed through view builder. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Message. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "messages".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("messages".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "messages" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/messages".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "messages": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/messages".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "messages": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/accept.rs b/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/accept.rs deleted file mode 100644 index 90eda50c4..000000000 --- a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/accept.rs +++ /dev/null @@ -1,219 +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`. - -//! Accept a new volume transfer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Accept<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) auth_key: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) accept: Accept<'a>, - - /// id parameter for /v3/os-volume-transfer/{id}/accept 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<'a> RequestBuilder<'a> { - /// Add a single header to the Os_Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("os-volume-transfer/{id}/accept", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("accept", serde_json::to_value(&self.accept)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfer".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "transfer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/os-volume-transfer/{id}/accept", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/os-volume-transfer/{id}/accept", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/create.rs b/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/create.rs deleted file mode 100644 index 24cbd40c0..000000000 --- a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/create.rs +++ /dev/null @@ -1,221 +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`. - -//! Create a new volume transfer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The volume transfer object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Transfer<'a> { - /// The name of the object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The UUID of the volume. - #[serde()] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The volume transfer object. - #[builder(setter(into))] - pub(crate) transfer: Transfer<'a>, - - #[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 Os_Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-volume-transfer".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("transfer", serde_json::to_value(&self.transfer)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfer".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "transfer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-volume-transfer".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-volume-transfer".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/delete.rs b/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/delete.rs deleted file mode 100644 index 58c8d6332..000000000 --- a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a transfer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/os-volume-transfer/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Os_Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-volume-transfer/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-volume-transfer/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-volume-transfer/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/find.rs b/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/find.rs deleted file mode 100644 index 3a08ed0eb..000000000 --- a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::os_volume_transfer::{get as Get, list_detailed as List}; - -/// Find for os_volume_transfer 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate os_volume_transfer in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // os_volume_transfer 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/os_volume_transfer/get.rs b/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/get.rs deleted file mode 100644 index 270ad7ac2..000000000 --- a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about active transfers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/os-volume-transfer/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Os_Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-volume-transfer/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfer".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "transfer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-volume-transfer/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-volume-transfer/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/list.rs b/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/list.rs deleted file mode 100644 index a7e668d64..000000000 --- a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Returns a summary list of transfers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Os_Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-volume-transfer".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfers".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "transfers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-transfer".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-transfer".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/list_detailed.rs deleted file mode 100644 index 5aedc6cc0..000000000 --- a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer/list_detailed.rs +++ /dev/null @@ -1,177 +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`. - -//! Returns a detailed list of transfers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Os_Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-volume-transfer/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfers".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "transfers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-transfer/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-transfer/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/association/list.rs b/openstack_sdk/src/api/block_storage/v3/qos_spec/association/list.rs deleted file mode 100644 index b2e1cde97..000000000 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/association/list.rs +++ /dev/null @@ -1,184 +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`. - -//! List all associations of given qos specs. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/qos-specs/{id}/associations 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<'a> RequestBuilder<'a> { - /// Add a single header to the Association. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos-specs/{id}/associations", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("qos_associations".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "qos_associations" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos-specs/{id}/associations", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_associations": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos-specs/{id}/associations", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_associations": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/create.rs b/openstack_sdk/src/api/block_storage/v3/qos_spec/create.rs deleted file mode 100644 index a6bd18877..000000000 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/create.rs +++ /dev/null @@ -1,234 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `qos_specs` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct QosSpecs<'a> { - /// The name of the QoS specification. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> QosSpecsBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `qos_specs` object. - #[builder(setter(into))] - pub(crate) qos_specs: QosSpecs<'a>, - - #[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 Qos_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos-specs".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("qos_specs", serde_json::to_value(&self.qos_specs)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("qos_specs".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "qos_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos-specs".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - let endpoint = Request::builder() - .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos-specs".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - let endpoint = Request::builder() - .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/delete.rs b/openstack_sdk/src/api/block_storage/v3/qos_spec/delete.rs deleted file mode 100644 index 1e0710a1a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Deletes an existing qos specs. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/qos-specs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Qos_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos-specs/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos-specs/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos-specs/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/find.rs b/openstack_sdk/src/api/block_storage/v3/qos_spec/find.rs deleted file mode 100644 index 619d0caa8..000000000 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::qos_spec::{get as Get, list as List}; - -/// Find for qos_spec 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate qos_spec in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // qos_spec 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/qos_spec/get.rs b/openstack_sdk/src/api/block_storage/v3/qos_spec/get.rs deleted file mode 100644 index 17b1a051c..000000000 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return a single qos spec item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/qos-specs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Qos_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos-specs/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("qos_specs".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "qos_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos-specs/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos-specs/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/list.rs b/openstack_sdk/src/api/block_storage/v3/qos_spec/list.rs deleted file mode 100644 index 2a1555513..000000000 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/list.rs +++ /dev/null @@ -1,226 +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`. - -//! Returns the list of qos_specs. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Qos_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos-specs".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("qos_specs".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "qos_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos-specs".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos-specs".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/set.rs b/openstack_sdk/src/api/block_storage/v3/qos_spec/set.rs deleted file mode 100644 index d90c027fe..000000000 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/set.rs +++ /dev/null @@ -1,236 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_qos_specs"))] - pub(crate) qos_specs: BTreeMap, Option>>, - - /// id parameter for /v3/qos-specs/{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<'a> RequestBuilder<'a> { - pub fn qos_specs(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>>, - { - self.qos_specs - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Qos_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("qos-specs/{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("qos_specs", serde_json::to_value(&self.qos_specs)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("qos_specs".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .qos_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))) - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .qos_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))) - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "qos_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos-specs/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .qos_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos-specs/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "qos_specs": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .qos_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_class_set/get.rs b/openstack_sdk/src/api/block_storage/v3/quota_class_set/get.rs deleted file mode 100644 index f647bbeb2..000000000 --- a/openstack_sdk/src/api/block_storage/v3/quota_class_set/get.rs +++ /dev/null @@ -1,184 +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 quota classes for a project -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/os-quota-class-sets/{id} API - #[builder(default, setter(into))] - name: 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 Quota_Class_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-quota-class-sets/{name}", name = self.name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("quota_class_set".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota_class_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-class-sets/{name}", name = "name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder().name("name").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-class-sets/{name}", name = "name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_class_set/set.rs b/openstack_sdk/src/api/block_storage/v3/quota_class_set/set.rs deleted file mode 100644 index 5052b48cc..000000000 --- a/openstack_sdk/src/api/block_storage/v3/quota_class_set/set.rs +++ /dev/null @@ -1,225 +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`. - -//! Update quota classes for a project -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_quota_class_set"))] - pub(crate) quota_class_set: BTreeMap, i32>, - - /// id parameter for /v3/os-quota-class-sets/{id} API - #[builder(default, setter(into))] - name: 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> { - pub fn quota_class_set(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.quota_class_set - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Quota_Class_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-quota-class-sets/{name}", name = self.name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "quota_class_set", - serde_json::to_value(&self.quota_class_set)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("quota_class_set".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota_class_set(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota_class_set(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota_class_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-class-sets/{name}", name = "name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .quota_class_set(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-class-sets/{name}", name = "name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .quota_class_set(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/defaults.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/defaults.rs deleted file mode 100644 index 16d5dd4ae..000000000 --- a/openstack_sdk/src/api/block_storage/v3/quota_set/defaults.rs +++ /dev/null @@ -1,191 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The quota-set project_id attribute - #[builder(default, setter(into))] - project_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 Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "os-quota-sets/{project_id}/defaults", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/os-quota-sets/{project_id}/defaults", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/os-quota-sets/{project_id}/defaults", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/delete.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/delete.rs deleted file mode 100644 index 38ae3f6b4..000000000 --- a/openstack_sdk/src/api/block_storage/v3/quota_set/delete.rs +++ /dev/null @@ -1,190 +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`. - -//! Delete quota for a particular tenant -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The quota-set project_id attribute - #[builder(default, setter(into))] - project_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 Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "os-quota-sets/{project_id}", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/os-quota-sets/{project_id}", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/os-quota-sets/{project_id}", - project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/get.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/get.rs deleted file mode 100644 index f887d4f1a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/quota_set/get.rs +++ /dev/null @@ -1,200 +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 quota for a particular tenant -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The quota-set project_id attribute - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// Show project’s quota usage information. Default is false. - #[builder(default)] - usage: 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> { - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "os-quota-sets/{project_id}", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("usage", self.usage); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/os-quota-sets/{project_id}", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/os-quota-sets/{project_id}", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/set.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/set.rs deleted file mode 100644 index 2fb314980..000000000 --- a/openstack_sdk/src/api/block_storage/v3/quota_set/set.rs +++ /dev/null @@ -1,234 +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`. - -//! Update quota for a particular tenant -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `quota_set` object. - #[builder(private, setter(into, name = "_quota_set"))] - pub(crate) quota_set: BTreeMap, Value>, - - /// The quota-set project_id attribute - #[builder(default, setter(into))] - project_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> { - /// A `quota_set` object. - pub fn quota_set(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.quota_set - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "os-quota-sets/{project_id}", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("quota_set", serde_json::to_value(&self.quota_set)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota_set(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota_set(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/os-quota-sets/{project_id}", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .quota_set(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/os-quota-sets/{project_id}", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .quota_set(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/resource_filter/list.rs b/openstack_sdk/src/api/block_storage/v3/resource_filter/list.rs deleted file mode 100644 index 55ea880ba..000000000 --- a/openstack_sdk/src/api/block_storage/v3/resource_filter/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Return a list of resource filters. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Resource_Filter. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "resource_filters".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("resource_filters".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "resource_filters" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/resource_filters".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_filters": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/resource_filters".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_filters": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/scheduler_stat/pool/list.rs b/openstack_sdk/src/api/block_storage/v3/scheduler_stat/pool/list.rs deleted file mode 100644 index cdd36b4ea..000000000 --- a/openstack_sdk/src/api/block_storage/v3/scheduler_stat/pool/list.rs +++ /dev/null @@ -1,186 +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`. - -//! List all active pools in scheduler. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request { - /// Indicates whether to show pool details or only pool names in the - /// response. Set to true to show pool details. Set to false to show only - /// pool names. Default is false. - #[builder(default)] - detail: Option, - - #[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 Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "scheduler-stats/get_pools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("detail", self.detail); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("pools".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "pools" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/scheduler-stats/get_pools".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pools": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/scheduler-stats/get_pools".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pools": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/service/list.rs b/openstack_sdk/src/api/block_storage/v3/service/list.rs deleted file mode 100644 index 3d546647f..000000000 --- a/openstack_sdk/src/api/block_storage/v3/service/list.rs +++ /dev/null @@ -1,176 +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`. - -//! Return a list of all running services. -//! -//! Filter by host & service name. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-services".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-services".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-services".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/service/set.rs b/openstack_sdk/src/api/block_storage/v3/service/set.rs deleted file mode 100644 index bb567779d..000000000 --- a/openstack_sdk/src/api/block_storage/v3/service/set.rs +++ /dev/null @@ -1,211 +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`. - -//! Enable/Disable scheduling for a service. -//! -//! Includes Freeze/Thaw which sends call down to drivers and allows -//! volume.manager for the specified host to disable the service rather than -//! accessing the service directly in this API layer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use crate::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/os-services/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-services/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - #[cfg(feature = "sync")] - use crate::api::Query; - use crate::test::client::FakeOpenStackClient; - use crate::types::ServiceType; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - use serde_json::json; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-services/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-services/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/create.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/create.rs deleted file mode 100644 index cf7f58cf4..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/create.rs +++ /dev/null @@ -1,260 +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`. - -//! Creates a new snapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `snapshot` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Snapshot<'a> { - /// A description for the snapshot. Default is `None`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The name of the snapshot. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) display_name: Option>>, - - /// Indicates whether to snapshot, even if the volume is attached. Default - /// is `false`. See [valid boolean values](#valid-boolean-values) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) force: Option, - - /// One or more metadata key and value pairs for the snapshot. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - /// The name of the snapshot. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The UUID of the volume. - #[serde()] - #[builder(setter(into))] - pub(crate) volume_id: Option>, -} - -impl<'a> SnapshotBuilder<'a> { - /// One or more metadata key and value pairs for the snapshot. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `snapshot` object. - #[builder(setter(into))] - pub(crate) snapshot: Snapshot<'a>, - - #[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 Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "snapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("snapshot", serde_json::to_value(&self.snapshot)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("snapshot".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "snapshot" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/snapshots".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/snapshots".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/delete.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/delete.rs deleted file mode 100644 index 398ea9647..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a snapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/snapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("snapshots/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/snapshots/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/snapshots/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/find.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/find.rs deleted file mode 100644 index 8c2104d66..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::snapshot::{get as Get, list_detailed as List}; - -/// Find for snapshot 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate snapshot in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // snapshot 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/snapshot/get.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/get.rs deleted file mode 100644 index 93771f7b3..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about the given snapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/snapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("snapshots/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("snapshot".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "snapshot" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/snapshots/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/snapshots/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/list.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/list.rs deleted file mode 100644 index 5be4570f8..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/list.rs +++ /dev/null @@ -1,245 +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`. - -//! Returns a summary list of snapshots. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Filters results by consumes_quota field. Resources that don’t use - /// quotas are usually temporary internal resources created to perform an - /// operation. Default is to not filter by it. Filtering by this option may - /// not be always possible in a cloud, see List Resource Filters to - /// determine whether this filter is available in your cloud. - #[builder(default)] - consumes_quota: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Whether to show count in API response or not, default is False. - #[builder(default)] - with_count: 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> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "snapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("consumes_quota", self.consumes_quota); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("with_count", self.with_count); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("snapshots".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "snapshots" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/snapshots".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshots": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/snapshots".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshots": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/list_detailed.rs deleted file mode 100644 index 2a9d5adf7..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/list_detailed.rs +++ /dev/null @@ -1,245 +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`. - -//! Returns a detailed list of snapshots. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Filters results by consumes_quota field. Resources that don’t use - /// quotas are usually temporary internal resources created to perform an - /// operation. Default is to not filter by it. Filtering by this option may - /// not be always possible in a cloud, see List Resource Filters to - /// determine whether this filter is available in your cloud. - #[builder(default)] - consumes_quota: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Whether to show count in API response or not, default is False. - #[builder(default)] - with_count: 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> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "snapshots/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("consumes_quota", self.consumes_quota); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("with_count", self.with_count); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("snapshots".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "snapshots" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/snapshots/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshots": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/snapshots/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshots": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/create.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/create.rs deleted file mode 100644 index 72b1db90e..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/create.rs +++ /dev/null @@ -1,249 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// One or more metadata key and value pairs for the snapshot, if any. - #[builder(private, setter(into, name = "_metadata"))] - pub(crate) metadata: BTreeMap, Cow<'a, str>>, - - /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API - #[builder(default, setter(into))] - snapshot_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -impl<'a> Request<'a> { - /// Create a builder for the endpoint. - pub fn builder() -> RequestBuilder<'a> { - RequestBuilder::default() - } -} - -impl<'a> RequestBuilder<'a> { - /// One or more metadata key and value pairs for the snapshot, if any. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "snapshots/{snapshot_id}/metadata", - snapshot_id = self.snapshot_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("metadata", serde_json::to_value(&self.metadata)?); - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("metadata".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/snapshots/{snapshot_id}/metadata", - snapshot_id = "snapshot_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .snapshot_id("snapshot_id") - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/snapshots/{snapshot_id}/metadata", - snapshot_id = "snapshot_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .snapshot_id("snapshot_id") - .metadata(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/delete.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/delete.rs deleted file mode 100644 index 25f0f33a0..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/delete.rs +++ /dev/null @@ -1,202 +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`. - -//! Deletes an existing metadata. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/snapshots/{snapshot_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API - #[builder(default, setter(into))] - snapshot_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "snapshots/{snapshot_id}/metadata/{id}", - id = self.id.as_ref(), - snapshot_id = self.snapshot_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/snapshots/{snapshot_id}/metadata/{id}", - id = "id", - snapshot_id = "snapshot_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .snapshot_id("snapshot_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/snapshots/{snapshot_id}/metadata/{id}", - id = "id", - snapshot_id = "snapshot_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") - .snapshot_id("snapshot_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/get.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/get.rs deleted file mode 100644 index a7fb98887..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/get.rs +++ /dev/null @@ -1,205 +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`. - -//! Return a single metadata item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/snapshots/{snapshot_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API - #[builder(default, setter(into))] - snapshot_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "snapshots/{snapshot_id}/metadata/{id}", - id = self.id.as_ref(), - snapshot_id = self.snapshot_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("meta".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "meta" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/snapshots/{snapshot_id}/metadata/{id}", - id = "id", - snapshot_id = "snapshot_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .snapshot_id("snapshot_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/snapshots/{snapshot_id}/metadata/{id}", - id = "id", - snapshot_id = "snapshot_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .snapshot_id("snapshot_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/list.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/list.rs deleted file mode 100644 index 8073c1539..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/list.rs +++ /dev/null @@ -1,196 +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`. - -//! Returns the list of metadata for a given snapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API - #[builder(default, setter(into))] - snapshot_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "snapshots/{snapshot_id}/metadata", - snapshot_id = self.snapshot_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("metadata".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/snapshots/{snapshot_id}/metadata", - snapshot_id = "snapshot_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .snapshot_id("snapshot_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/snapshots/{snapshot_id}/metadata", - snapshot_id = "snapshot_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .snapshot_id("snapshot_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/replace.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/replace.rs deleted file mode 100644 index 2d40a005b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/replace.rs +++ /dev/null @@ -1,249 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// One or more metadata key and value pairs for the snapshot, if any. - #[builder(private, setter(into, name = "_metadata"))] - pub(crate) metadata: BTreeMap, Cow<'a, str>>, - - /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API - #[builder(default, setter(into))] - snapshot_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -impl<'a> Request<'a> { - /// Create a builder for the endpoint. - pub fn builder() -> RequestBuilder<'a> { - RequestBuilder::default() - } -} - -impl<'a> RequestBuilder<'a> { - /// One or more metadata key and value pairs for the snapshot, if any. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "snapshots/{snapshot_id}/metadata", - snapshot_id = self.snapshot_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("metadata", serde_json::to_value(&self.metadata)?); - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("metadata".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/snapshots/{snapshot_id}/metadata", - snapshot_id = "snapshot_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .snapshot_id("snapshot_id") - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/snapshots/{snapshot_id}/metadata", - snapshot_id = "snapshot_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .snapshot_id("snapshot_id") - .metadata(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/set.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/set.rs deleted file mode 100644 index b166eb253..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata/set.rs +++ /dev/null @@ -1,256 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_meta"))] - pub(crate) meta: BTreeMap, Cow<'a, str>>, - - /// id parameter for /v3/snapshots/{snapshot_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API - #[builder(default, setter(into))] - snapshot_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -impl<'a> Request<'a> { - /// Create a builder for the endpoint. - pub fn builder() -> RequestBuilder<'a> { - RequestBuilder::default() - } -} - -impl<'a> RequestBuilder<'a> { - pub fn meta(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.meta - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "snapshots/{snapshot_id}/metadata/{id}", - id = self.id.as_ref(), - snapshot_id = self.snapshot_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("meta", serde_json::to_value(&self.meta)?); - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("meta".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "meta" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/snapshots/{snapshot_id}/metadata/{id}", - id = "id", - snapshot_id = "snapshot_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .snapshot_id("snapshot_id") - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/snapshots/{snapshot_id}/metadata/{id}", - id = "id", - snapshot_id = "snapshot_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .snapshot_id("snapshot_id") - .meta(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/os_force_delete.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/os_force_delete.rs deleted file mode 100644 index 39bc90f19..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/os_force_delete.rs +++ /dev/null @@ -1,211 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// OpenAPI specifies the field as '{}'. - #[builder(setter(into))] - pub(crate) os_force_delete: Value, - - /// id parameter for /v3/snapshots/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("snapshots/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "os-force_delete", - serde_json::to_value(&self.os_force_delete)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_force_delete(json!({})) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_force_delete(json!({})) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/snapshots/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_force_delete(json!({})) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/snapshots/{id}/action", 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") - .os_force_delete(json!({})) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/os_reset_status.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/os_reset_status.rs deleted file mode 100644 index 1d3e0499e..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/os_reset_status.rs +++ /dev/null @@ -1,239 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsResetStatus<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) status: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) os_reset_status: OsResetStatus<'a>, - - /// id parameter for /v3/snapshots/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("snapshots/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "os-reset_status", - serde_json::to_value(&self.os_reset_status)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/snapshots/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/snapshots/{id}/action", 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") - .os_reset_status( - OsResetStatusBuilder::default() - .status("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/os_unmanage.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/os_unmanage.rs deleted file mode 100644 index 1b4d3c8c2..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/os_unmanage.rs +++ /dev/null @@ -1,208 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// OpenAPI specifies the field as '{}'. - #[builder(setter(into))] - pub(crate) os_unmanage: Value, - - /// id parameter for /v3/snapshots/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("snapshots/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("os-unmanage", serde_json::to_value(&self.os_unmanage)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_unmanage(json!({})) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_unmanage(json!({})) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/snapshots/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_unmanage(json!({})) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/snapshots/{id}/action", 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") - .os_unmanage(json!({})) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/set.rs b/openstack_sdk/src/api/block_storage/v3/snapshot/set.rs deleted file mode 100644 index d2e365261..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/set.rs +++ /dev/null @@ -1,231 +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`. - -//! Update a snapshot. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Snapshot<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) display_description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) display_name: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) snapshot: Snapshot<'a>, - - /// id parameter for /v3/snapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("snapshots/{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("snapshot", serde_json::to_value(&self.snapshot)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("snapshot".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .snapshot(SnapshotBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .snapshot(SnapshotBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "snapshot" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/snapshots/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .snapshot(SnapshotBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/snapshots/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .snapshot(SnapshotBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot_manage/create.rs b/openstack_sdk/src/api/block_storage/v3/snapshot_manage/create.rs deleted file mode 100644 index d7f33c413..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot_manage/create.rs +++ /dev/null @@ -1,310 +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`. - -//! Instruct Cinder to manage a storage snapshot object. -//! -//! Manages an existing backend storage snapshot object (e.g. a Linux logical -//! volume or a SAN disk) by creating the Cinder objects required to manage it, -//! and possibly renaming the backend storage snapshot object (driver -//! dependent). -//! -//! From an API perspective, this operation behaves very much like a snapshot -//! creation operation. -//! -//! Required HTTP Body: -//! -//! ```text -//! { -//! "snapshot": -//! { -//! "volume_id": "", -//! "ref": -//! "" -//! } -//! } -//! ``` -//! -//! See the appropriate Cinder drivers' implementations of the manage_snapshot -//! method to find out the accepted format of 'ref'. For example,in LVM driver, -//! it will be the logic volume name of snapshot which you want to manage. -//! -//! This API call will return with an error if any of the above elements are -//! missing from the request, or if the 'volume_id' element refers to a cinder -//! volume that could not be found. -//! -//! The snapshot will later enter the error state if it is discovered that -//! 'ref' is bad. -//! -//! Optional elements to 'snapshot' are: -//! -//! ```text -//! name A name for the new snapshot. -//! description A description for the new snapshot. -//! metadata Key/value pairs to be associated with the new snapshot. -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Snapshot<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - #[serde(rename = "ref")] - #[builder(setter(into))] - pub(crate) _ref: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -impl<'a> SnapshotBuilder<'a> { - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) snapshot: Snapshot<'a>, - - #[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 Snapshot_Manage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-snapshot-manage".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("snapshot", serde_json::to_value(&self.snapshot)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-snapshot-manage".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-snapshot-manage".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() - .snapshot( - SnapshotBuilder::default() - ._ref(json!({})) - .volume_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot_manage/get.rs b/openstack_sdk/src/api/block_storage/v3/snapshot_manage/get.rs deleted file mode 100644 index 1d746a970..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot_manage/get.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a summary list of snapshots available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Snapshot_Manage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-snapshot-manage".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-snapshot-manage".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-snapshot-manage".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot_manage/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/snapshot_manage/list_detailed.rs deleted file mode 100644 index f56cce91e..000000000 --- a/openstack_sdk/src/api/block_storage/v3/snapshot_manage/list_detailed.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a detailed list of snapshots available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Snapshot_Manage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-snapshot-manage/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-snapshot-manage/detail".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-snapshot-manage/detail".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/create.rs b/openstack_sdk/src/api/block_storage/v3/type/create.rs deleted file mode 100644 index 5b4d3e735..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/create.rs +++ /dev/null @@ -1,248 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct VolumeType<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_extra_specs"))] - pub(crate) extra_specs: Option, Option>>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[serde( - rename = "os-volume-type-access:is_public", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) os_volume_type_access_is_public: Option, -} - -impl<'a> VolumeTypeBuilder<'a> { - pub fn extra_specs(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>>, - { - self.extra_specs - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) volume_type: VolumeType<'a>, - - /// id parameter for /v3/types/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("types/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("volume_type", serde_json::to_value(&self.volume_type)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume_type".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "volume_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/types/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/types/{id}/action", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/delete.rs b/openstack_sdk/src/api/block_storage/v3/type/delete.rs deleted file mode 100644 index f9829876a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Deletes an existing volume type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/types/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/types/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/encryption/create.rs b/openstack_sdk/src/api/block_storage/v3/type/encryption/create.rs deleted file mode 100644 index e2d29d780..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/encryption/create.rs +++ /dev/null @@ -1,287 +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`. - -//! Create encryption specs for an existing volume type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum ControlLocation { - #[serde(rename = "back-end")] - BackEnd, - #[serde(rename = "front-end")] - FrontEnd, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Encryption<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cipher: Option>>, - - #[serde()] - #[builder()] - pub(crate) control_location: ControlLocation, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_size: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) provider: Cow<'a, str>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> EncryptionBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) encryption: Encryption<'a>, - - /// type_id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - type_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 Encryption. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "types/{type_id}/encryption", - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("encryption", serde_json::to_value(&self.encryption)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("encryption".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .encryption( - EncryptionBuilder::default() - .control_location(ControlLocation::BackEnd) - .provider("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .encryption( - EncryptionBuilder::default() - .control_location(ControlLocation::BackEnd) - .provider("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "encryption" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/types/{type_id}/encryption", type_id = "type_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "encryption": {} })); - }); - - let endpoint = Request::builder() - .type_id("type_id") - .encryption( - EncryptionBuilder::default() - .control_location(ControlLocation::BackEnd) - .provider("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/types/{type_id}/encryption", type_id = "type_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "encryption": {} })); - }); - - let endpoint = Request::builder() - .type_id("type_id") - .encryption( - EncryptionBuilder::default() - .control_location(ControlLocation::BackEnd) - .provider("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/encryption/delete.rs b/openstack_sdk/src/api/block_storage/v3/type/encryption/delete.rs deleted file mode 100644 index 13933f77f..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/encryption/delete.rs +++ /dev/null @@ -1,202 +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`. - -//! Delete encryption specs for a given volume type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// type_id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - type_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 Encryption. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "types/{type_id}/encryption/{id}", - id = self.id.as_ref(), - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/types/{type_id}/encryption/{id}", - id = "id", - type_id = "type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .type_id("type_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/types/{type_id}/encryption/{id}", - id = "id", - type_id = "type_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") - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/encryption/get.rs b/openstack_sdk/src/api/block_storage/v3/type/encryption/get.rs deleted file mode 100644 index 57288fb58..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/encryption/get.rs +++ /dev/null @@ -1,202 +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`. - -//! Return a single encryption item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// type_id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - type_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 Encryption. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "types/{type_id}/encryption/{id}", - id = self.id.as_ref(), - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/types/{type_id}/encryption/{id}", - id = "id", - type_id = "type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .type_id("type_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/types/{type_id}/encryption/{id}", - id = "id", - type_id = "type_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") - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/encryption/list.rs b/openstack_sdk/src/api/block_storage/v3/type/encryption/list.rs deleted file mode 100644 index 419d2b5ae..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/encryption/list.rs +++ /dev/null @@ -1,185 +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`. - -//! Returns the encryption specs for a given volume type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// type_id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - type_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 Encryption. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "types/{type_id}/encryption", - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/types/{type_id}/encryption", type_id = "type_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().type_id("type_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/types/{type_id}/encryption", type_id = "type_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() - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/encryption/set.rs b/openstack_sdk/src/api/block_storage/v3/type/encryption/set.rs deleted file mode 100644 index dea3e1918..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/encryption/set.rs +++ /dev/null @@ -1,277 +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`. - -//! Update encryption specs for a given volume type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum ControlLocation { - #[serde(rename = "back-end")] - BackEnd, - #[serde(rename = "front-end")] - FrontEnd, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Encryption<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cipher: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) control_location: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_size: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) provider: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> EncryptionBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) encryption: Encryption<'a>, - - /// id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// type_id parameter for /v3/types/{type_id}/encryption/{id} API - #[builder(default, setter(into))] - type_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 Encryption. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "types/{type_id}/encryption/{id}", - id = self.id.as_ref(), - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("encryption", serde_json::to_value(&self.encryption)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("encryption".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .encryption(EncryptionBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .encryption(EncryptionBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "encryption" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/types/{type_id}/encryption/{id}", - id = "id", - type_id = "type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "encryption": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .type_id("type_id") - .encryption(EncryptionBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/types/{type_id}/encryption/{id}", - id = "id", - type_id = "type_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "encryption": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .type_id("type_id") - .encryption(EncryptionBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/create.rs b/openstack_sdk/src/api/block_storage/v3/type/extra_spec/create.rs deleted file mode 100644 index 64d658a34..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/create.rs +++ /dev/null @@ -1,240 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_extra_specs"))] - pub(crate) extra_specs: BTreeMap, Option>>, - - /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - type_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> { - pub fn extra_specs(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>>, - { - self.extra_specs - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "types/{type_id}/extra_specs", - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("extra_specs", serde_json::to_value(&self.extra_specs)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("extra_specs".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .extra_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))) - ) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .extra_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))) - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "extra_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder() - .type_id("type_id") - .extra_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder() - .type_id("type_id") - .extra_specs( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.map(Into::into))), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/delete.rs b/openstack_sdk/src/api/block_storage/v3/type/extra_spec/delete.rs deleted file mode 100644 index f30c28e1b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/delete.rs +++ /dev/null @@ -1,202 +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`. - -//! Deletes an existing extra spec. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - type_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 Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "types/{type_id}/extra_specs/{id}", - id = self.id.as_ref(), - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/types/{type_id}/extra_specs/{id}", - id = "id", - type_id = "type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .type_id("type_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/types/{type_id}/extra_specs/{id}", - id = "id", - type_id = "type_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") - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/get.rs b/openstack_sdk/src/api/block_storage/v3/type/extra_spec/get.rs deleted file mode 100644 index b70ee9fc4..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/get.rs +++ /dev/null @@ -1,202 +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`. - -//! Return a single extra spec item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - type_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 Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "types/{type_id}/extra_specs/{id}", - id = self.id.as_ref(), - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/types/{type_id}/extra_specs/{id}", - id = "id", - type_id = "type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .type_id("type_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/types/{type_id}/extra_specs/{id}", - id = "id", - type_id = "type_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") - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/list.rs b/openstack_sdk/src/api/block_storage/v3/type/extra_spec/list.rs deleted file mode 100644 index 647f177f0..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/list.rs +++ /dev/null @@ -1,188 +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`. - -//! Returns the list of extra specs for a given volume type. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - type_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 Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "types/{type_id}/extra_specs", - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("extra_specs".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "extra_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder().type_id("type_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder() - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/set.rs b/openstack_sdk/src/api/block_storage/v3/type/extra_spec/set.rs deleted file mode 100644 index 9a72dcf57..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/extra_spec/set.rs +++ /dev/null @@ -1,226 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API - #[builder(default, setter(into))] - type_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, 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 Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>>, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "types/{type_id}/extra_specs/{id}", - id = self.id.as_ref(), - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/types/{type_id}/extra_specs/{id}", - id = "id", - type_id = "type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .type_id("type_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/types/{type_id}/extra_specs/{id}", - id = "id", - type_id = "type_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") - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/find.rs b/openstack_sdk/src/api/block_storage/v3/type/find.rs deleted file mode 100644 index a0fc9c223..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::r#type::{get as Get, list as List}; - -/// Find for type 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate type in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // type 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/type/get.rs b/openstack_sdk/src/api/block_storage/v3/type/get.rs deleted file mode 100644 index eb563f60e..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return a single volume type item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume_type".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volume_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/types/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/types/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/list.rs b/openstack_sdk/src/api/block_storage/v3/type/list.rs deleted file mode 100644 index 82b2f58d6..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Returns the list of volume types. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume_types".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volume_types" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/types".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_types": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/types".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_types": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/set.rs b/openstack_sdk/src/api/block_storage/v3/type/set.rs deleted file mode 100644 index aa94c9e48..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/set.rs +++ /dev/null @@ -1,225 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct VolumeType<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_public: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) volume_type: VolumeType<'a>, - - /// id parameter for /v3/types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("types/{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("volume_type", serde_json::to_value(&self.volume_type)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume_type".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume_type(VolumeTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .volume_type(VolumeTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "volume_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/types/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_type(VolumeTypeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/types/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_type(VolumeTypeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/type/volume_type_access/get.rs b/openstack_sdk/src/api/block_storage/v3/type/volume_type_access/get.rs deleted file mode 100644 index 23d063b79..000000000 --- a/openstack_sdk/src/api/block_storage/v3/type/volume_type_access/get.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// type_id parameter for /v3/types/{type_id}/os-volume-type-access/{id} - /// API - #[builder(default, setter(into))] - type_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 Volume_Type_Access. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "types/{type_id}/os-volume-type-access", - type_id = self.type_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume_type_access".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volume_type_access" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/types/{type_id}/os-volume-type-access", - type_id = "type_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type_access": {} })); - }); - - let endpoint = Request::builder().type_id("type_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/types/{type_id}/os-volume-type-access", - type_id = "type_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume_type_access": {} })); - }); - - let endpoint = Request::builder() - .type_id("type_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/version/get.rs b/openstack_sdk/src/api/block_storage/v3/version/get.rs deleted file mode 100644 index aba03f34b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/version/get.rs +++ /dev/null @@ -1,173 +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`. - -//! Shows details for Block Storage API v3. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/create_30.rs b/openstack_sdk/src/api/block_storage/v3/volume/create_30.rs deleted file mode 100644 index 56b2e253b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/create_30.rs +++ /dev/null @@ -1,357 +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`. - -//! Creates a new volume. -//! -//! | | | | --- | --- | | param req: | the request | | param body: | the -//! request body | | returns: | dict -- the new volume dictionary | | raises -//! HTTPNotFound, HTTPBadRequest: | | | | | -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `volume` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Volume<'a> { - /// The name of the availability zone. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// The UUID of the consistency group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) consistencygroup_id: Option>>, - - /// The volume description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) display_description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) display_name: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_id: Option>>, - - /// The UUID of the image from which you want to create the volume. - /// Required to create a bootable volume. - /// - /// **New in version 3.46**: Instead of directly consuming a zero-byte - /// image that has been created by the Compute service when an instance - /// snapshot was requested, the Block Storage service will use the - /// `snapshot_id` contained in the `block_device_mapping` image property to - /// locate the volume snapshot, and will use that to create the volume - /// instead. - #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_ref: Option>>, - - /// One or more metadata key and value pairs to be associated with the new - /// volume. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) multiattach: Option>, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The size of the volume, in gibibytes (GiB). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) size: Option>, - - /// The UUID of the consistency group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) snapshot_id: Option>>, - - /// The UUID of the consistency group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) source_volid: Option>>, - - /// The volume type (either name or ID). To create an environment with - /// multiple-storage back ends, you must specify a volume type. Block - /// Storage volume back ends are spawned as children to `cinder- volume`, - /// and they are keyed from a unique queue. They are named - /// `cinder- volume.HOST.BACKEND`. For example, - /// `cinder- volume.ubuntu.lvmdriver`. When a volume is created, the - /// scheduler chooses an appropriate back end to handle the request based - /// on the volume type. Default is `None`. For information about how to use - /// volume types to create multiple- storage back ends, see - /// [Configure multiple-storage back ends](https://docs.openstack.org/cinder/latest/admin/blockstorage-multi-backend.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_type: Option>>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> VolumeBuilder<'a> { - /// One or more metadata key and value pairs to be associated with the new - /// volume. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The dictionary of data to send to the scheduler. - #[builder(default, private, setter(into, name = "_os_sch_hnt_scheduler_hints"))] - pub(crate) os_sch_hnt_scheduler_hints: Option, Value>>>, - - /// A `volume` object. - #[builder(setter(into))] - pub(crate) volume: Volume<'a>, - - #[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> { - /// The dictionary of data to send to the scheduler. - pub fn os_sch_hnt_scheduler_hints(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.os_sch_hnt_scheduler_hints - .get_or_insert(None) - .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 Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volumes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.os_sch_hnt_scheduler_hints { - params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); - } - params.push("volume", serde_json::to_value(&self.volume)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "volume" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/volumes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/volumes".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/create_313.rs b/openstack_sdk/src/api/block_storage/v3/volume/create_313.rs deleted file mode 100644 index d7322601f..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/create_313.rs +++ /dev/null @@ -1,361 +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`. - -//! Creates a new volume. -//! -//! | | | | --- | --- | | param req: | the request | | param body: | the -//! request body | | returns: | dict -- the new volume dictionary | | raises -//! HTTPNotFound, HTTPBadRequest: | | | | | -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `volume` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Volume<'a> { - /// The name of the availability zone. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// The UUID of the consistency group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) consistencygroup_id: Option>>, - - /// The volume description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) display_description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) display_name: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group_id: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_id: Option>>, - - /// The UUID of the image from which you want to create the volume. - /// Required to create a bootable volume. - /// - /// **New in version 3.46**: Instead of directly consuming a zero-byte - /// image that has been created by the Compute service when an instance - /// snapshot was requested, the Block Storage service will use the - /// `snapshot_id` contained in the `block_device_mapping` image property to - /// locate the volume snapshot, and will use that to create the volume - /// instead. - #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_ref: Option>>, - - /// One or more metadata key and value pairs to be associated with the new - /// volume. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) multiattach: Option>, - - /// The volume name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The size of the volume, in gibibytes (GiB). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) size: Option>, - - /// The UUID of the consistency group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) snapshot_id: Option>>, - - /// The UUID of the consistency group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) source_volid: Option>>, - - /// The volume type (either name or ID). To create an environment with - /// multiple-storage back ends, you must specify a volume type. Block - /// Storage volume back ends are spawned as children to `cinder- volume`, - /// and they are keyed from a unique queue. They are named - /// `cinder- volume.HOST.BACKEND`. For example, - /// `cinder- volume.ubuntu.lvmdriver`. When a volume is created, the - /// scheduler chooses an appropriate back end to handle the request based - /// on the volume type. Default is `None`. For information about how to use - /// volume types to create multiple- storage back ends, see - /// [Configure multiple-storage back ends](https://docs.openstack.org/cinder/latest/admin/blockstorage-multi-backend.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_type: Option>>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> VolumeBuilder<'a> { - /// One or more metadata key and value pairs to be associated with the new - /// volume. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The dictionary of data to send to the scheduler. - #[builder(default, private, setter(into, name = "_os_sch_hnt_scheduler_hints"))] - pub(crate) os_sch_hnt_scheduler_hints: Option, Value>>>, - - /// A `volume` object. - #[builder(setter(into))] - pub(crate) volume: Volume<'a>, - - #[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> { - /// The dictionary of data to send to the scheduler. - pub fn os_sch_hnt_scheduler_hints(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.os_sch_hnt_scheduler_hints - .get_or_insert(None) - .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 Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volumes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.os_sch_hnt_scheduler_hints { - params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); - } - params.push("volume", serde_json::to_value(&self.volume)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume".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(3, 13)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "volume" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/volumes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/volumes".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/delete.rs b/openstack_sdk/src/api/block_storage/v3/volume/delete.rs deleted file mode 100644 index 134905e4a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a volume. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/volumes/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("volumes/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/volumes/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/volumes/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/encryption/get.rs b/openstack_sdk/src/api/block_storage/v3/volume/encryption/get.rs deleted file mode 100644 index c01d209f7..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/encryption/get.rs +++ /dev/null @@ -1,202 +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`. - -//! Return a single encryption item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/volumes/{volume_id}/encryption/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// volume_id parameter for /v3/volumes/{volume_id}/encryption/{id} API - #[builder(default, setter(into))] - volume_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 Encryption. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "volumes/{volume_id}/encryption/{id}", - id = self.id.as_ref(), - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/volumes/{volume_id}/encryption/{id}", - id = "id", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_id("volume_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/volumes/{volume_id}/encryption/{id}", - id = "id", - volume_id = "volume_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") - .volume_id("volume_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/encryption/list.rs b/openstack_sdk/src/api/block_storage/v3/volume/encryption/list.rs deleted file mode 100644 index 8ca4dbf76..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/encryption/list.rs +++ /dev/null @@ -1,190 +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`. - -//! Returns the encryption metadata for a given volume. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// volume_id parameter for /v3/volumes/{volume_id}/encryption/{id} API - #[builder(default, setter(into))] - volume_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 Encryption. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "volumes/{volume_id}/encryption", - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/volumes/{volume_id}/encryption", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().volume_id("volume_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/volumes/{volume_id}/encryption", - volume_id = "volume_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() - .volume_id("volume_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/find.rs b/openstack_sdk/src/api/block_storage/v3/volume/find.rs deleted file mode 100644 index ac30ab175..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::volume::{get as Get, list_detailed as List}; - -/// Find for volume 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate volume in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // volume 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/volume/get.rs b/openstack_sdk/src/api/block_storage/v3/volume/get.rs deleted file mode 100644 index 886abcb37..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about the given volume. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/volumes/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("volumes/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volume".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volume" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/volumes/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/volumes/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volume": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/list.rs b/openstack_sdk/src/api/block_storage/v3/volume/list.rs deleted file mode 100644 index 533295b90..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/list.rs +++ /dev/null @@ -1,257 +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`. - -//! Returns a summary list of volumes. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Filters results by consumes_quota field. Resources that don’t use - /// quotas are usually temporary internal resources created to perform an - /// operation. Default is to not filter by it. Filtering by this option may - /// not be always possible in a cloud, see List Resource Filters to - /// determine whether this filter is available in your cloud. - #[builder(default)] - consumes_quota: Option, - - /// Filters results by a time that resources are created at with time - /// comparison operators: gt/gte/eq/neq/lt/lte. - #[builder(default, setter(into))] - created_at: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filters results by a time that resources are updated at with time - /// comparison operators: gt/gte/eq/neq/lt/lte. - #[builder(default, setter(into))] - updated_at: Option>, - - /// Whether to show count in API response or not, default is False. - #[builder(default)] - with_count: 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> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volumes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("consumes_quota", self.consumes_quota); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - params.push_opt("with_count", self.with_count); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volumes".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volumes" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volumes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumes": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volumes".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumes": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/volume/list_detailed.rs deleted file mode 100644 index 05e862b79..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/list_detailed.rs +++ /dev/null @@ -1,257 +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`. - -//! Returns a detailed list of volumes. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Filters results by consumes_quota field. Resources that don’t use - /// quotas are usually temporary internal resources created to perform an - /// operation. Default is to not filter by it. Filtering by this option may - /// not be always possible in a cloud, see List Resource Filters to - /// determine whether this filter is available in your cloud. - #[builder(default)] - consumes_quota: Option, - - /// Filters results by a time that resources are created at with time - /// comparison operators: gt/gte/eq/neq/lt/lte. - #[builder(default, setter(into))] - created_at: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filters results by a time that resources are updated at with time - /// comparison operators: gt/gte/eq/neq/lt/lte. - #[builder(default, setter(into))] - updated_at: Option>, - - /// Whether to show count in API response or not, default is False. - #[builder(default)] - with_count: 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> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volumes/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("consumes_quota", self.consumes_quota); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - params.push_opt("with_count", self.with_count); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("volumes".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volumes" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volumes/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumes": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volumes/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumes": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/metadata/create.rs b/openstack_sdk/src/api/block_storage/v3/volume/metadata/create.rs deleted file mode 100644 index 2f5772d2e..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/metadata/create.rs +++ /dev/null @@ -1,233 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// One or more metadata key and value pairs that are associated with the - /// volume. - #[builder(private, setter(into, name = "_metadata"))] - pub(crate) metadata: BTreeMap, Cow<'a, str>>, - - /// volume_id parameter for /v3/volumes/{volume_id}/metadata API - #[builder(default, setter(into))] - volume_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> { - /// One or more metadata key and value pairs that are associated with the - /// volume. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "volumes/{volume_id}/metadata", - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("metadata", serde_json::to_value(&self.metadata)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("metadata".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/volumes/{volume_id}/metadata", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .volume_id("volume_id") - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/volumes/{volume_id}/metadata", - volume_id = "volume_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .volume_id("volume_id") - .metadata(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/metadata/delete.rs b/openstack_sdk/src/api/block_storage/v3/volume/metadata/delete.rs deleted file mode 100644 index 4da543da8..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/metadata/delete.rs +++ /dev/null @@ -1,202 +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`. - -//! Deletes an existing metadata. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/volumes/{volume_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// volume_id parameter for /v3/volumes/{volume_id}/metadata API - #[builder(default, setter(into))] - volume_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "volumes/{volume_id}/metadata/{id}", - id = self.id.as_ref(), - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/volumes/{volume_id}/metadata/{id}", - id = "id", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_id("volume_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/volumes/{volume_id}/metadata/{id}", - id = "id", - volume_id = "volume_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") - .volume_id("volume_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/metadata/get.rs b/openstack_sdk/src/api/block_storage/v3/volume/metadata/get.rs deleted file mode 100644 index 0c37b44a4..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/metadata/get.rs +++ /dev/null @@ -1,205 +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`. - -//! Return a single metadata item. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/volumes/{volume_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// volume_id parameter for /v3/volumes/{volume_id}/metadata API - #[builder(default, setter(into))] - volume_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "volumes/{volume_id}/metadata/{id}", - id = self.id.as_ref(), - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("meta".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "meta" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/volumes/{volume_id}/metadata/{id}", - id = "id", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_id("volume_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/volumes/{volume_id}/metadata/{id}", - id = "id", - volume_id = "volume_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_id("volume_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/metadata/list.rs b/openstack_sdk/src/api/block_storage/v3/volume/metadata/list.rs deleted file mode 100644 index 36f6182a7..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/metadata/list.rs +++ /dev/null @@ -1,191 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// volume_id parameter for /v3/volumes/{volume_id}/metadata API - #[builder(default, setter(into))] - volume_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "volumes/{volume_id}/metadata", - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("metadata".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/volumes/{volume_id}/metadata", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder().volume_id("volume_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/volumes/{volume_id}/metadata", - volume_id = "volume_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .volume_id("volume_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/metadata/replace.rs b/openstack_sdk/src/api/block_storage/v3/volume/metadata/replace.rs deleted file mode 100644 index 4827f752b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/metadata/replace.rs +++ /dev/null @@ -1,233 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// One or more metadata key and value pairs that are associated with the - /// volume. - #[builder(private, setter(into, name = "_metadata"))] - pub(crate) metadata: BTreeMap, Cow<'a, str>>, - - /// volume_id parameter for /v3/volumes/{volume_id}/metadata API - #[builder(default, setter(into))] - volume_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> { - /// One or more metadata key and value pairs that are associated with the - /// volume. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "volumes/{volume_id}/metadata", - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("metadata", serde_json::to_value(&self.metadata)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("metadata".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/volumes/{volume_id}/metadata", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .volume_id("volume_id") - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/volumes/{volume_id}/metadata", - volume_id = "volume_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .volume_id("volume_id") - .metadata(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/metadata/set.rs b/openstack_sdk/src/api/block_storage/v3/volume/metadata/set.rs deleted file mode 100644 index 7518c4e07..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/metadata/set.rs +++ /dev/null @@ -1,238 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_meta"))] - pub(crate) meta: BTreeMap, Cow<'a, str>>, - - /// id parameter for /v3/volumes/{volume_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// volume_id parameter for /v3/volumes/{volume_id}/metadata API - #[builder(default, setter(into))] - volume_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> { - pub fn meta(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.meta - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "volumes/{volume_id}/metadata/{id}", - id = self.id.as_ref(), - volume_id = self.volume_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("meta", serde_json::to_value(&self.meta)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("meta".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "meta" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/volumes/{volume_id}/metadata/{id}", - id = "id", - volume_id = "volume_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_id("volume_id") - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/volumes/{volume_id}/metadata/{id}", - id = "id", - volume_id = "volume_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .volume_id("volume_id") - .meta(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_force_delete.rs b/openstack_sdk/src/api/block_storage/v3/volume/os_force_delete.rs deleted file mode 100644 index 98560a491..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_force_delete.rs +++ /dev/null @@ -1,211 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// OpenAPI specifies the field as '{}'. - #[builder(setter(into))] - pub(crate) os_force_delete: Value, - - /// id parameter for /v3/volumes/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("volumes/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "os-force_delete", - serde_json::to_value(&self.os_force_delete)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_force_delete(json!({})) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_force_delete(json!({})) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volumes/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_force_delete(json!({})) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volumes/{id}/action", 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") - .os_force_delete(json!({})) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_reset_status.rs b/openstack_sdk/src/api/block_storage/v3/volume/os_reset_status.rs deleted file mode 100644 index 33d3e6e48..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_reset_status.rs +++ /dev/null @@ -1,227 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsResetStatus<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) attach_status: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) migration_status: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) status: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) os_reset_status: OsResetStatus<'a>, - - /// id parameter for /v3/volumes/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("volumes/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "os-reset_status", - serde_json::to_value(&self.os_reset_status)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volumes/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volumes/{id}/action", 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") - .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_unmanage.rs b/openstack_sdk/src/api/block_storage/v3/volume/os_unmanage.rs deleted file mode 100644 index e7ee38a23..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_unmanage.rs +++ /dev/null @@ -1,208 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// OpenAPI specifies the field as '{}'. - #[builder(setter(into))] - pub(crate) os_unmanage: Value, - - /// id parameter for /v3/volumes/{id}/action 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("volumes/{id}/action", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("os-unmanage", serde_json::to_value(&self.os_unmanage)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .os_unmanage(json!({})) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .os_unmanage(json!({})) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volumes/{id}/action", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .os_unmanage(json!({})) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volumes/{id}/action", 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") - .os_unmanage(json!({})) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/summary/get.rs b/openstack_sdk/src/api/block_storage/v3/volume/summary/get.rs deleted file mode 100644 index 595db3768..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume/summary/get.rs +++ /dev/null @@ -1,174 +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`. - -//! Return summary of volumes. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Summary. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volumes/summary".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volumes/summary".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volumes/summary".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_manage/create_30.rs b/openstack_sdk/src/api/block_storage/v3/volume_manage/create_30.rs deleted file mode 100644 index fe63b4b97..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_manage/create_30.rs +++ /dev/null @@ -1,308 +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`. - -//! Instruct Cinder to manage a storage object. -//! -//! Manages an existing backend storage object (e.g. a Linux logical volume or -//! a SAN disk) by creating the Cinder objects required to manage it, and -//! possibly renaming the backend storage object (driver dependent) -//! -//! From an API perspective, this operation behaves very much like a volume -//! creation operation, except that properties such as image, snapshot and -//! volume references don't make sense, because we are taking an existing -//! storage object into Cinder management. -//! -//! Required HTTP Body: -//! -//! ```text -//! { -//! "volume": { -//! "host": "", -//! "cluster": "", -//! "ref": "" -//! } -//! } -//! ``` -//! -//! See the appropriate Cinder drivers' implementations of the manage_volume -//! method to find out the accepted format of 'ref'. -//! -//! This API call will return with an error if any of the above elements are -//! missing from the request, or if the 'host' element refers to a cinder host -//! that is not registered. -//! -//! The volume will later enter the error state if it is discovered that 'ref' -//! is bad. -//! -//! Optional elements to 'volume' are: -//! -//! ```text -//! name A name for the new volume. -//! description A description for the new volume. -//! volume_type ID or name of a volume type to associate with -//! the new Cinder volume. Does not necessarily -//! guarantee that the managed volume will have the -//! properties described in the volume_type. The -//! driver may choose to fail if it identifies that -//! the specified volume_type is not compatible with -//! the backend storage object. -//! metadata Key/value pairs to be associated with the new -//! volume. -//! availability_zone The availability zone to associate with the new -//! volume. -//! bootable If set to True, marks the volume as bootable. -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Volume<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bootable: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - #[serde(rename = "ref")] - #[builder(setter(into))] - pub(crate) _ref: Value, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_type: Option>>, -} - -impl<'a> VolumeBuilder<'a> { - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) volume: Volume<'a>, - - #[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 Volume_Manage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-volume-manage".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("volume", serde_json::to_value(&self.volume)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-volume-manage".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-volume-manage".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() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_manage/create_316.rs b/openstack_sdk/src/api/block_storage/v3/volume_manage/create_316.rs deleted file mode 100644 index 0b91bce4d..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_manage/create_316.rs +++ /dev/null @@ -1,312 +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`. - -//! Instruct Cinder to manage a storage object. -//! -//! Manages an existing backend storage object (e.g. a Linux logical volume or -//! a SAN disk) by creating the Cinder objects required to manage it, and -//! possibly renaming the backend storage object (driver dependent) -//! -//! From an API perspective, this operation behaves very much like a volume -//! creation operation, except that properties such as image, snapshot and -//! volume references don't make sense, because we are taking an existing -//! storage object into Cinder management. -//! -//! Required HTTP Body: -//! -//! ```text -//! { -//! "volume": { -//! "host": "", -//! "cluster": "", -//! "ref": "" -//! } -//! } -//! ``` -//! -//! See the appropriate Cinder drivers' implementations of the manage_volume -//! method to find out the accepted format of 'ref'. -//! -//! This API call will return with an error if any of the above elements are -//! missing from the request, or if the 'host' element refers to a cinder host -//! that is not registered. -//! -//! The volume will later enter the error state if it is discovered that 'ref' -//! is bad. -//! -//! Optional elements to 'volume' are: -//! -//! ```text -//! name A name for the new volume. -//! description A description for the new volume. -//! volume_type ID or name of a volume type to associate with -//! the new Cinder volume. Does not necessarily -//! guarantee that the managed volume will have the -//! properties described in the volume_type. The -//! driver may choose to fail if it identifies that -//! the specified volume_type is not compatible with -//! the backend storage object. -//! metadata Key/value pairs to be associated with the new -//! volume. -//! availability_zone The availability zone to associate with the new -//! volume. -//! bootable If set to True, marks the volume as bootable. -//! ``` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Volume<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bootable: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cluster: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - #[serde(rename = "ref")] - #[builder(setter(into))] - pub(crate) _ref: Value, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_type: Option>>, -} - -impl<'a> VolumeBuilder<'a> { - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) volume: Volume<'a>, - - #[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 Volume_Manage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-volume-manage".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("volume", serde_json::to_value(&self.volume)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 16)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-volume-manage".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-volume-manage".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() - .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_manage/get.rs b/openstack_sdk/src/api/block_storage/v3/volume_manage/get.rs deleted file mode 100644 index 36132768c..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_manage/get.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a summary list of volumes available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Volume_Manage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-volume-manage".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-manage".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-manage".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_manage/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/volume_manage/list_detailed.rs deleted file mode 100644 index 631425f06..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_manage/list_detailed.rs +++ /dev/null @@ -1,174 +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`. - -//! Returns a detailed list of volumes available to manage. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Volume_Manage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-volume-manage/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-manage/detail".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-volume-manage/detail".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer/accept.rs b/openstack_sdk/src/api/block_storage/v3/volume_transfer/accept.rs deleted file mode 100644 index e04a1bded..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/accept.rs +++ /dev/null @@ -1,219 +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`. - -//! Accept a new volume transfer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Accept<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) auth_key: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) accept: Accept<'a>, - - /// id parameter for /v3/volume-transfers/{id}/accept 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("volume-transfers/{id}/accept", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("accept", serde_json::to_value(&self.accept)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfer".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "transfer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volume-transfers/{id}/accept", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/volume-transfers/{id}/accept", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer/create_30.rs b/openstack_sdk/src/api/block_storage/v3/volume_transfer/create_30.rs deleted file mode 100644 index 4a8182e21..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/create_30.rs +++ /dev/null @@ -1,221 +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`. - -//! Create a new volume transfer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The volume transfer object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Transfer<'a> { - /// The name of the object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The UUID of the volume. - #[serde()] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The volume transfer object. - #[builder(setter(into))] - pub(crate) transfer: Transfer<'a>, - - #[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 Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volume-transfers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("transfer", serde_json::to_value(&self.transfer)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfer".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "transfer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/volume-transfers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/volume-transfers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer/delete.rs b/openstack_sdk/src/api/block_storage/v3/volume_transfer/delete.rs deleted file mode 100644 index 564e9653a..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a transfer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/volume-transfers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("volume-transfers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/volume-transfers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/volume-transfers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer/find.rs b/openstack_sdk/src/api/block_storage/v3/volume_transfer/find.rs deleted file mode 100644 index caeb0f0bd..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::block_storage::v3::volume_transfer::{get as Get, list_detailed as List}; - -/// Find for volume_transfer 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate volume_transfer in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // volume_transfer 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") - && let Some(name) = name_as_val.as_str() - && 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/block_storage/v3/volume_transfer/get.rs b/openstack_sdk/src/api/block_storage/v3/volume_transfer/get.rs deleted file mode 100644 index 0e6a0878e..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Return data about active transfers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v3/volume-transfers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("volume-transfers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfer".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "transfer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/volume-transfers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/volume-transfers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer/list.rs b/openstack_sdk/src/api/block_storage/v3/volume_transfer/list.rs deleted file mode 100644 index 427c6fd27..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Returns a summary list of transfers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volume-transfers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfers".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "transfers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volume-transfers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volume-transfers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/volume_transfer/list_detailed.rs deleted file mode 100644 index c95113435..000000000 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/list_detailed.rs +++ /dev/null @@ -1,236 +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`. - -//! Returns a detailed list of transfers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Shows details for all project. Admin only. - #[builder(default)] - all_tenants: Option, - - /// Filter the volume transfer by public visibility. - #[builder(default)] - is_public: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Used in conjunction with limit to return a slice of items. offset is - /// where to start in the list. - #[builder(default)] - offset: Option, - - /// Comma-separated list of sort keys and optional sort directions in the - /// form of < key > [: < direction > ]. A valid direction is asc - /// (ascending) or desc (descending). - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts by one or more sets of attribute and sort direction combinations. - /// If you omit the sort direction in a set, default is desc. Deprecated in - /// favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts by an attribute. A valid value is name, status, container_format, - /// disk_format, size, id, created_at, or updated_at. Default is - /// created_at. The API uses the natural sorting direction of the sort_key - /// attribute value. Deprecated in favour of the combined sort parameter. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Volume_Transfer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "volume-transfers/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_tenants", self.all_tenants); - params.push_opt("is_public", self.is_public); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("offset", self.offset); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("transfers".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "transfers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volume-transfers/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/volume-transfers/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "transfers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute.rs b/openstack_sdk/src/api/compute.rs index 57fd7b879..30f6b1f73 100644 --- a/openstack_sdk/src/api/compute.rs +++ b/openstack_sdk/src/api/compute.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Compute service (Nova) bindings -pub mod v2; +//! # Compute service (Nova) bindings +pub use openstack_sdk_compute::*; diff --git a/openstack_sdk/src/api/compute/v2/aggregate/create_20.rs b/openstack_sdk/src/api/compute/v2/aggregate/create_20.rs deleted file mode 100644 index aab6d71ad..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/create_20.rs +++ /dev/null @@ -1,231 +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`. - -//! Creates an aggregate. If specifying an option availability_zone, the -//! aggregate is created as an availability zone and the availability zone is -//! visible to normal users. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The host aggregate object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Aggregate<'a> { - /// The availability zone of the host aggregate. You should use a custom - /// availability zone rather than the default returned by the - /// os-availability-zone API. The availability zone must not include ‘:’ in - /// its name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// The name of the host aggregate. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The host aggregate object. - #[builder(setter(into))] - pub(crate) aggregate: Aggregate<'a>, - - #[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 Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-aggregates".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("aggregate", serde_json::to_value(&self.aggregate)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("aggregate".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "aggregate" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-aggregates".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-aggregates".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/create_21.rs b/openstack_sdk/src/api/compute/v2/aggregate/create_21.rs deleted file mode 100644 index 036f75af4..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/create_21.rs +++ /dev/null @@ -1,231 +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`. - -//! Creates an aggregate. If specifying an option availability_zone, the -//! aggregate is created as an availability zone and the availability zone is -//! visible to normal users. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The host aggregate object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Aggregate<'a> { - /// The availability zone of the host aggregate. You should use a custom - /// availability zone rather than the default returned by the - /// os-availability-zone API. The availability zone must not include ‘:’ in - /// its name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// The name of the host aggregate. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The host aggregate object. - #[builder(setter(into))] - pub(crate) aggregate: Aggregate<'a>, - - #[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 Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-aggregates".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("aggregate", serde_json::to_value(&self.aggregate)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("aggregate".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "aggregate" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-aggregates".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-aggregates".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/delete.rs b/openstack_sdk/src/api/compute/v2/aggregate/delete.rs deleted file mode 100644 index d1f33df17..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/delete.rs +++ /dev/null @@ -1,186 +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`. - -//! Deletes an aggregate. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-aggregates/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-aggregates/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-aggregates/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/find.rs b/openstack_sdk/src/api/compute/v2/aggregate/find.rs deleted file mode 100644 index 6c277b803..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::compute::v2::aggregate::{get as Get, list as List}; - -/// Find for aggregate 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate aggregate in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // aggregate 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") - && let Some(name) = name_as_val.as_str() - && 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/compute/v2/aggregate/get.rs b/openstack_sdk/src/api/compute/v2/aggregate/get.rs deleted file mode 100644 index 443defd72..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/get.rs +++ /dev/null @@ -1,188 +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`. - -//! Shows details for an aggregate. Details include hosts and metadata. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-aggregates/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("aggregate".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "aggregate" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-aggregates/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-aggregates/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/list.rs b/openstack_sdk/src/api/compute/v2/aggregate/list.rs deleted file mode 100644 index c6998f2c2..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/list.rs +++ /dev/null @@ -1,182 +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`. - -//! Lists all aggregates. Includes the ID, name, and availability zone for each -//! aggregate. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-aggregates".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("aggregates".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "aggregates" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-aggregates".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregates": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-aggregates".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregates": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/set_20.rs b/openstack_sdk/src/api/compute/v2/aggregate/set_20.rs deleted file mode 100644 index 4cd361928..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/set_20.rs +++ /dev/null @@ -1,243 +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`. - -//! Updates either or both the name and availability zone for an aggregate. If -//! the aggregate to be updated has host that already in the given availability -//! zone, the request will fail with 400 error. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The host aggregate object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Aggregate<'a> { - /// The availability zone of the host aggregate. You should use a custom - /// availability zone rather than the default returned by the - /// os-availability-zone API. The availability zone must not include ‘:’ in - /// its name. - /// - /// Warning - /// - /// You should not change or unset the availability zone of an aggregate - /// when that aggregate has hosts which contain servers in it since that - /// may impact the ability for those servers to move to another host. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// The name of the host aggregate. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The host aggregate object. - #[builder(setter(into))] - pub(crate) aggregate: Aggregate<'a>, - - /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-aggregates/{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("aggregate", serde_json::to_value(&self.aggregate)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("aggregate".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "aggregate" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-aggregates/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .aggregate(AggregateBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-aggregates/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .aggregate(AggregateBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/set_21.rs b/openstack_sdk/src/api/compute/v2/aggregate/set_21.rs deleted file mode 100644 index f41c39e6f..000000000 --- a/openstack_sdk/src/api/compute/v2/aggregate/set_21.rs +++ /dev/null @@ -1,243 +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`. - -//! Updates either or both the name and availability zone for an aggregate. If -//! the aggregate to be updated has host that already in the given availability -//! zone, the request will fail with 400 error. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The host aggregate object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Aggregate<'a> { - /// The availability zone of the host aggregate. You should use a custom - /// availability zone rather than the default returned by the - /// os-availability-zone API. The availability zone must not include ‘:’ in - /// its name. - /// - /// Warning - /// - /// You should not change or unset the availability zone of an aggregate - /// when that aggregate has hosts which contain servers in it since that - /// may impact the ability for those servers to move to another host. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>>, - - /// The name of the host aggregate. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The host aggregate object. - #[builder(setter(into))] - pub(crate) aggregate: Aggregate<'a>, - - /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-aggregates/{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("aggregate", serde_json::to_value(&self.aggregate)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("aggregate".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .aggregate(AggregateBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "aggregate" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-aggregates/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .aggregate(AggregateBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-aggregates/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregate": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .aggregate(AggregateBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/assisted_volume_snapshot/create.rs b/openstack_sdk/src/api/compute/v2/assisted_volume_snapshot/create.rs deleted file mode 100644 index eeeba9df4..000000000 --- a/openstack_sdk/src/api/compute/v2/assisted_volume_snapshot/create.rs +++ /dev/null @@ -1,310 +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`. - -//! Creates an assisted volume snapshot. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400),unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "qcow2")] - Qcow2, -} - -/// Information for snapshot creation. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct CreateInfo<'a> { - /// Its an arbitrary string that gets passed back to the user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The name of the qcow2 file that Block Storage creates, which becomes - /// the active image for the VM. - #[serde()] - #[builder(setter(into))] - pub(crate) new_file: Cow<'a, str>, - - /// The UUID for a snapshot. - #[serde()] - #[builder(setter(into))] - pub(crate) snapshot_id: Cow<'a, str>, - - /// The snapshot type. A valid value is `qcow2`. - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, -} - -/// A partial representation of a snapshot that is used to create a snapshot. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Snapshot<'a> { - /// Information for snapshot creation. - #[serde()] - #[builder(setter(into))] - pub(crate) create_info: CreateInfo<'a>, - - /// The source volume ID. - #[serde()] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A partial representation of a snapshot that is used to create a - /// snapshot. - #[builder(setter(into))] - pub(crate) snapshot: Snapshot<'a>, - - #[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 Assisted_Volume_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-assisted-volume-snapshots".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("snapshot", serde_json::to_value(&self.snapshot)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("snapshot".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .snapshot( - SnapshotBuilder::default() - .create_info( - CreateInfoBuilder::default() - ._type(Type::Qcow2) - .new_file("foo") - .snapshot_id("foo") - .build() - .unwrap() - ) - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .snapshot( - SnapshotBuilder::default() - .create_info( - CreateInfoBuilder::default() - ._type(Type::Qcow2) - .new_file("foo") - .snapshot_id("foo") - .build() - .unwrap() - ) - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "snapshot" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-assisted-volume-snapshots".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .snapshot( - SnapshotBuilder::default() - .create_info( - CreateInfoBuilder::default() - ._type(Type::Qcow2) - .new_file("foo") - .snapshot_id("foo") - .build() - .unwrap(), - ) - .volume_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-assisted-volume-snapshots".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "snapshot": {} })); - }); - - let endpoint = Request::builder() - .snapshot( - SnapshotBuilder::default() - .create_info( - CreateInfoBuilder::default() - ._type(Type::Qcow2) - .new_file("foo") - .snapshot_id("foo") - .build() - .unwrap(), - ) - .volume_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/assisted_volume_snapshot/delete.rs b/openstack_sdk/src/api/compute/v2/assisted_volume_snapshot/delete.rs deleted file mode 100644 index 2ec603559..000000000 --- a/openstack_sdk/src/api/compute/v2/assisted_volume_snapshot/delete.rs +++ /dev/null @@ -1,199 +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`. - -//! Deletes an assisted volume snapshot. -//! -//! To make this request, add the `delete_info` query parameter to the URI, as -//! follows: -//! -//! DELETE -//! /os-assisted-volume-snapshots/421752a6-acf6-4b2d-bc7a-119f9148cd8c?delete_info=’{“volume_id”: -//! “521752a6-acf6-4b2d-bc7a-119f9148cd8c”}’ -//! -//! Normal response codes: 204 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - delete_info: Option>, - - /// id parameter for /v2.1/os-assisted-volume-snapshots/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Assisted_Volume_Snapshot. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-assisted-volume-snapshots/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("delete_info", self.delete_info.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-assisted-volume-snapshots/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-assisted-volume-snapshots/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/availability_zone/list.rs b/openstack_sdk/src/api/compute/v2/availability_zone/list.rs deleted file mode 100644 index 2788df091..000000000 --- a/openstack_sdk/src/api/compute/v2/availability_zone/list.rs +++ /dev/null @@ -1,181 +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`. - -//! Lists availability zone information. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-availability-zone".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("availabilityZoneInfo".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availabilityZoneInfo" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-availability-zone".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availabilityZoneInfo": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-availability-zone".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availabilityZoneInfo": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/console_auth_token/get.rs b/openstack_sdk/src/api/compute/v2/console_auth_token/get.rs deleted file mode 100644 index 963505553..000000000 --- a/openstack_sdk/src/api/compute/v2/console_auth_token/get.rs +++ /dev/null @@ -1,194 +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`. - -//! Given the console authentication token for a server, shows the related -//! connection information. -//! -//! Nova HyperV driver has been removed therefore requests for RDP console -//! connection information will always return an http 400 error. Starting from -//! microversion 2.31 it’s available for all other console types. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-console-auth-tokens/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Console_Auth_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-console-auth-tokens/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("console".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "console" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-console-auth-tokens/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "console": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-console-auth-tokens/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "console": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/extension/get.rs b/openstack_sdk/src/api/compute/v2/extension/get.rs deleted file mode 100644 index 18b150415..000000000 --- a/openstack_sdk/src/api/compute/v2/extension/get.rs +++ /dev/null @@ -1,188 +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`. - -//! Shows details for an extension, by alias. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/extensions/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Extension. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("extensions/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("extension".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "extension" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/extensions/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extension": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/extensions/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extension": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/extension/list.rs b/openstack_sdk/src/api/compute/v2/extension/list.rs deleted file mode 100644 index b692e8219..000000000 --- a/openstack_sdk/src/api/compute/v2/extension/list.rs +++ /dev/null @@ -1,181 +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`. - -//! Lists all extensions to the API. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Extension. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "extensions".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("extensions".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "extensions" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/extensions".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extensions": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/extensions".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extensions": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/create_20.rs b/openstack_sdk/src/api/compute/v2/flavor/create_20.rs deleted file mode 100644 index 0c8503997..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/create_20.rs +++ /dev/null @@ -1,314 +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`. - -//! Creates a flavor. -//! -//! Creating a flavor is typically only available to administrators of a cloud -//! because this has implications for scheduling efficiently in the cloud. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The ID and links for the flavor for your server instance. A flavor is a -/// combination of memory, disk size, and CPUs. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavor<'a> { - /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 - /// (the default), no dedicated swap disk will be created. - #[serde()] - #[builder(setter(into))] - pub(crate) disk: i32, - - /// Only alphanumeric characters with hyphen ‘-’, underscore ‘\_’, spaces - /// and dots ‘.’ are permitted. If an ID is not provided, then a default - /// UUID will be assigned. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>>, - - /// The display name of a flavor. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// Whether the flavor is public (available to all projects) or scoped to a - /// set of projects. Default is True if not specified. - #[serde( - rename = "os-flavor-access:is_public", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) os_flavor_access_is_public: Option, - - /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 - /// (the default), no dedicated swap disk will be created. - #[serde( - rename = "OS-FLV-EXT-DATA:ephemeral", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) os_flv_ext_data_ephemeral: Option, - - /// The number of virtual CPUs that will be allocated to the server. - #[serde()] - #[builder(setter(into))] - pub(crate) ram: i32, - - /// The receive / transmit factor (as a float) that will be set on ports if - /// the network backend supports the QOS extension. Otherwise it will be - /// ignored. It defaults to 1.0. - /// - /// **Available until version 2.101** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) rxtx_factor: Option>, - - /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 - /// (the default), no dedicated swap disk will be created. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) swap: Option, - - /// The number of virtual CPUs that will be allocated to the server. - #[serde()] - #[builder(setter(into))] - pub(crate) vcpus: i32, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID and links for the flavor for your server instance. A flavor is a - /// combination of memory, disk size, and CPUs. - #[builder(setter(into))] - pub(crate) flavor: Flavor<'a>, - - #[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 Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "flavors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("flavor", serde_json::to_value(&self.flavor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/flavors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/flavors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/create_21.rs b/openstack_sdk/src/api/compute/v2/flavor/create_21.rs deleted file mode 100644 index 360f97b0c..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/create_21.rs +++ /dev/null @@ -1,314 +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`. - -//! Creates a flavor. -//! -//! Creating a flavor is typically only available to administrators of a cloud -//! because this has implications for scheduling efficiently in the cloud. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The ID and links for the flavor for your server instance. A flavor is a -/// combination of memory, disk size, and CPUs. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavor<'a> { - /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 - /// (the default), no dedicated swap disk will be created. - #[serde()] - #[builder(setter(into))] - pub(crate) disk: i32, - - /// Only alphanumeric characters with hyphen ‘-’, underscore ‘\_’, spaces - /// and dots ‘.’ are permitted. If an ID is not provided, then a default - /// UUID will be assigned. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>>, - - /// The display name of a flavor. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// Whether the flavor is public (available to all projects) or scoped to a - /// set of projects. Default is True if not specified. - #[serde( - rename = "os-flavor-access:is_public", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) os_flavor_access_is_public: Option, - - /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 - /// (the default), no dedicated swap disk will be created. - #[serde( - rename = "OS-FLV-EXT-DATA:ephemeral", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) os_flv_ext_data_ephemeral: Option, - - /// The number of virtual CPUs that will be allocated to the server. - #[serde()] - #[builder(setter(into))] - pub(crate) ram: i32, - - /// The receive / transmit factor (as a float) that will be set on ports if - /// the network backend supports the QOS extension. Otherwise it will be - /// ignored. It defaults to 1.0. - /// - /// **Available until version 2.101** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) rxtx_factor: Option>, - - /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 - /// (the default), no dedicated swap disk will be created. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) swap: Option, - - /// The number of virtual CPUs that will be allocated to the server. - #[serde()] - #[builder(setter(into))] - pub(crate) vcpus: i32, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID and links for the flavor for your server instance. A flavor is a - /// combination of memory, disk size, and CPUs. - #[builder(setter(into))] - pub(crate) flavor: Flavor<'a>, - - #[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 Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "flavors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("flavor", serde_json::to_value(&self.flavor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/flavors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/flavors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor( - FlavorBuilder::default() - .disk(123) - .name("foo") - .ram(123) - .vcpus(123) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/delete.rs b/openstack_sdk/src/api/compute/v2/flavor/delete.rs deleted file mode 100644 index d842df3c0..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/delete.rs +++ /dev/null @@ -1,189 +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`. - -//! Deletes a flavor. -//! -//! This is typically an admin only action. Deleting a flavor that is in use by -//! existing servers is not recommended as it can cause incorrect data to be -//! returned to the user under some operations. -//! -//! Normal response codes: 202 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/flavors/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("flavors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/flavors/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/flavors/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/create.rs b/openstack_sdk/src/api/compute/v2/flavor/extra_spec/create.rs deleted file mode 100644 index 3059ad7df..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/create.rs +++ /dev/null @@ -1,243 +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`. - -//! Creates extra specs for a flavor, by ID. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary of the flavor’s extra-specs key-and-value pairs. It - /// appears in the os-extra-specs’ “create” REQUEST body, as well as the - /// os-extra-specs’ “create” and “list” RESPONSE body. - #[builder(private, setter(into, name = "_extra_specs"))] - pub(crate) extra_specs: BTreeMap, Cow<'a, str>>, - - /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} - /// API - #[builder(default, setter(into))] - flavor_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> { - /// A dictionary of the flavor’s extra-specs key-and-value pairs. It - /// appears in the os-extra-specs’ “create” REQUEST body, as well as the - /// os-extra-specs’ “create” and “list” RESPONSE body. - pub fn extra_specs(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.extra_specs - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "flavors/{flavor_id}/os-extra_specs", - flavor_id = self.flavor_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("extra_specs", serde_json::to_value(&self.extra_specs)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("extra_specs".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .extra_specs(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .extra_specs(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "extra_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/flavors/{flavor_id}/os-extra_specs", - flavor_id = "flavor_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .extra_specs(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/flavors/{flavor_id}/os-extra_specs", - flavor_id = "flavor_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .extra_specs(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/delete.rs b/openstack_sdk/src/api/compute/v2/flavor/extra_spec/delete.rs deleted file mode 100644 index 0aacb3cec..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Deletes an extra spec, by key, for a flavor, by ID. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = "flavor_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() - .flavor_id("flavor_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/get.rs b/openstack_sdk/src/api/compute/v2/flavor/extra_spec/get.rs deleted file mode 100644 index b9d644893..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/get.rs +++ /dev/null @@ -1,207 +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`. - -//! Shows an extra spec, by key, for a flavor, by ID. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = "flavor_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() - .flavor_id("flavor_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/list.rs b/openstack_sdk/src/api/compute/v2/flavor/extra_spec/list.rs deleted file mode 100644 index 5c8a3bc21..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/list.rs +++ /dev/null @@ -1,198 +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`. - -//! Lists all extra specs for a flavor, by ID. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} - /// API - #[builder(default, setter(into))] - flavor_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 Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/os-extra_specs", - flavor_id = self.flavor_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("extra_specs".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "extra_specs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/flavors/{flavor_id}/os-extra_specs", - flavor_id = "flavor_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/flavors/{flavor_id}/os-extra_specs", - flavor_id = "flavor_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extra_specs": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/set.rs b/openstack_sdk/src/api/compute/v2/flavor/extra_spec/set.rs deleted file mode 100644 index 1ddb8a309..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/extra_spec/set.rs +++ /dev/null @@ -1,234 +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`. - -//! Updates an extra spec, by key, for a flavor, by ID. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Cow<'a, str>>, -} -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 Extra_Spec. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), serde_json::Value::from(val.clone())); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/flavors/{flavor_id}/os-extra_specs/{id}", - flavor_id = "flavor_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() - .flavor_id("flavor_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/find.rs b/openstack_sdk/src/api/compute/v2/flavor/find.rs deleted file mode 100644 index 96ac27852..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::compute::v2::flavor::{get as Get, list_detailed as List}; - -/// Find for flavor 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate flavor in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // flavor 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") - && let Some(name) = name_as_val.as_str() - && 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/compute/v2/flavor/flavor_access/list.rs b/openstack_sdk/src/api/compute/v2/flavor/flavor_access/list.rs deleted file mode 100644 index bff9ba9f5..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/flavor_access/list.rs +++ /dev/null @@ -1,197 +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`. - -//! Lists flavor access information. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-flavor-access API - #[builder(default, setter(into))] - flavor_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 Flavor_Access. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/os-flavor-access", - flavor_id = self.flavor_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("flavor_access".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavor_access" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/flavors/{flavor_id}/os-flavor-access", - flavor_id = "flavor_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor_access": {} })); - }); - - let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/flavors/{flavor_id}/os-flavor-access", - flavor_id = "flavor_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor_access": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/get.rs b/openstack_sdk/src/api/compute/v2/flavor/get.rs deleted file mode 100644 index 19083d292..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/get.rs +++ /dev/null @@ -1,188 +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`. - -//! Shows details for a flavor. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/flavors/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("flavors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/flavors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/flavors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/list.rs b/openstack_sdk/src/api/compute/v2/flavor/list.rs deleted file mode 100644 index 1bde7ae5f..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/list.rs +++ /dev/null @@ -1,219 +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`. - -//! Lists all flavors accessible to your project. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - is_public: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - min_disk: Option>, - - #[builder(default, setter(into))] - min_ram: Option>, - - #[builder(default, setter(into))] - name: Option>, - - #[builder(default, setter(into))] - sort_dir: Option>, - - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "flavors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("is_public", self.is_public.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("minDisk", self.min_disk.as_ref()); - params.push_opt("minRam", self.min_ram.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("flavors".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavors" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/flavors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/flavors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/flavor/list_detailed.rs b/openstack_sdk/src/api/compute/v2/flavor/list_detailed.rs deleted file mode 100644 index 115b693c8..000000000 --- a/openstack_sdk/src/api/compute/v2/flavor/list_detailed.rs +++ /dev/null @@ -1,219 +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`. - -//! Lists flavors with details. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - is_public: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - min_disk: Option>, - - #[builder(default, setter(into))] - min_ram: Option>, - - #[builder(default, setter(into))] - name: Option>, - - #[builder(default, setter(into))] - sort_dir: Option>, - - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "flavors/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("is_public", self.is_public.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("minDisk", self.min_disk.as_ref()); - params.push_opt("minRam", self.min_ram.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("flavors".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavors" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/flavors/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/flavors/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ip/create.rs b/openstack_sdk/src/api/compute/v2/floating_ip/create.rs deleted file mode 100644 index 63b67e4fe..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ip/create.rs +++ /dev/null @@ -1,190 +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`. - -//! Creates, or allocates, a floating IP address for the current project. By -//! default, the floating IP address is allocated from the public pool. -//! -//! If more than one floating IP address pool is available, use the `pool` -//! parameter to specify from which pool to allocate the IP address. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Floating_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-floating-ips".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("floating_ip".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floating_ip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-floating-ips".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floating_ip": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-floating-ips".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floating_ip": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ip/delete.rs b/openstack_sdk/src/api/compute/v2/floating_ip/delete.rs deleted file mode 100644 index f64723f2a..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ip/delete.rs +++ /dev/null @@ -1,194 +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`. - -//! Deletes, or deallocates, a floating IP address from the current project and -//! returns it to the pool from which it was allocated. -//! -//! If the IP address is still associated with a running instance, it is -//! automatically disassociated from that instance. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 202 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-floating-ips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floating_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-floating-ips/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-floating-ips/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-floating-ips/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ip/get.rs b/openstack_sdk/src/api/compute/v2/floating_ip/get.rs deleted file mode 100644 index fb9a09402..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ip/get.rs +++ /dev/null @@ -1,194 +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`. - -//! Shows details for a floating IP address, by ID, that is associated with the -//! tenant or account. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-floating-ips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floating_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-floating-ips/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("floating_ip".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floating_ip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-floating-ips/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floating_ip": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-floating-ips/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floating_ip": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ip/list.rs b/openstack_sdk/src/api/compute/v2/floating_ip/list.rs deleted file mode 100644 index fe085e8c9..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ip/list.rs +++ /dev/null @@ -1,185 +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`. - -//! Lists floating IP addresses associated with the tenant or account. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Floating_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-floating-ips".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("floating_ips".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floating_ips" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-floating-ips".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floating_ips": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-floating-ips".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floating_ips": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/create.rs b/openstack_sdk/src/api/compute/v2/floating_ips_bulk/create.rs deleted file mode 100644 index 1e47b916c..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/create.rs +++ /dev/null @@ -1,179 +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`. - -//! Bulk-creates floating IPs. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409), gone(410) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Floating_Ips_Bulk. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-floating-ips-bulk".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-floating-ips-bulk".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-floating-ips-bulk".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/get.rs b/openstack_sdk/src/api/compute/v2/floating_ips_bulk/get.rs deleted file mode 100644 index 5b8d2adc9..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/get.rs +++ /dev/null @@ -1,186 +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`. - -//! Lists all floating IPs for a host. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), -//! gone(410) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-floating-ips-bulk/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floating_Ips_Bulk. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-floating-ips-bulk/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-floating-ips-bulk/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-floating-ips-bulk/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/list.rs b/openstack_sdk/src/api/compute/v2/floating_ips_bulk/list.rs deleted file mode 100644 index 2fe3c1ca5..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/list.rs +++ /dev/null @@ -1,179 +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`. - -//! Lists all floating IPs. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), -//! gone(410) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Floating_Ips_Bulk. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-floating-ips-bulk".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-floating-ips-bulk".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-floating-ips-bulk".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/set.rs b/openstack_sdk/src/api/compute/v2/floating_ips_bulk/set.rs deleted file mode 100644 index cbfb8a80d..000000000 --- a/openstack_sdk/src/api/compute/v2/floating_ips_bulk/set.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-floating-ips-bulk/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floating_Ips_Bulk. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-floating-ips-bulk/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-floating-ips-bulk/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-floating-ips-bulk/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/find.rs b/openstack_sdk/src/api/compute/v2/hypervisor/find.rs deleted file mode 100644 index 1416add70..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/find.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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use tracing::trace; - -use crate::api::find::Findable; -use crate::api::rest_endpoint_prelude::*; - -use crate::api::{ApiError, RestClient}; - -use crate::api::compute::v2::hypervisor::{get as Get, list_detailed as List}; - -/// Find for hypervisor 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<'a> RequestBuilder<'a> { - /// 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<'a>; - 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<'a> { - 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 hypervisor in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // hypervisor 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/compute/v2/hypervisor/get.rs b/openstack_sdk/src/api/compute/v2/hypervisor/get.rs deleted file mode 100644 index 9772ff41b..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/get.rs +++ /dev/null @@ -1,199 +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`. - -//! Shows details for a given hypervisor. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-hypervisors/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(default)] - with_servers: 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> { - /// Add a single header to the Hypervisor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-hypervisors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("with_servers", self.with_servers); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("hypervisor".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "hypervisor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisor": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/list.rs b/openstack_sdk/src/api/compute/v2/hypervisor/list.rs deleted file mode 100644 index ac08951f9..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/list.rs +++ /dev/null @@ -1,210 +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`. - -//! Lists hypervisors. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - hypervisor_hostname_pattern: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default)] - with_servers: 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> { - /// Add a single header to the Hypervisor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-hypervisors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt( - "hypervisor_hostname_pattern", - self.hypervisor_hostname_pattern.as_ref(), - ); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("with_servers", self.with_servers); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("hypervisors".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "hypervisors" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hypervisors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisors": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hypervisors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisors": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/list_detailed.rs b/openstack_sdk/src/api/compute/v2/hypervisor/list_detailed.rs deleted file mode 100644 index 6ec45d32e..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/list_detailed.rs +++ /dev/null @@ -1,210 +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`. - -//! Lists hypervisors details. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - hypervisor_hostname_pattern: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default)] - with_servers: 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> { - /// Add a single header to the Hypervisor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-hypervisors/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt( - "hypervisor_hostname_pattern", - self.hypervisor_hostname_pattern.as_ref(), - ); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("with_servers", self.with_servers); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("hypervisors".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "hypervisors" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hypervisors/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisors": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hypervisors/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisors": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/search/get.rs b/openstack_sdk/src/api/compute/v2/hypervisor/search/get.rs deleted file mode 100644 index 500501d8c..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/search/get.rs +++ /dev/null @@ -1,189 +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`. - -//! Search hypervisor by a given hypervisor host name or portion of it. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response code: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-hypervisors/{id}/search 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<'a> RequestBuilder<'a> { - /// Add a single header to the Search. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-hypervisors/{id}/search", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}/search", 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}/search", 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/server/get.rs b/openstack_sdk/src/api/compute/v2/hypervisor/server/get.rs deleted file mode 100644 index c2388db04..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/server/get.rs +++ /dev/null @@ -1,193 +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`. - -//! List all servers belong to each hypervisor whose host name is matching a -//! given hypervisor host name or portion of it. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response code: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-hypervisors/{id}/servers 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<'a> RequestBuilder<'a> { - /// Add a single header to the Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-hypervisors/{id}/servers", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("servers".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "servers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}/servers", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "servers": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}/servers", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "servers": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/statistic/get.rs b/openstack_sdk/src/api/compute/v2/hypervisor/statistic/get.rs deleted file mode 100644 index b2acdd160..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/statistic/get.rs +++ /dev/null @@ -1,186 +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`. - -//! Shows summary statistics for all enabled hypervisors over all compute -//! nodes. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Statistic. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-hypervisors/statistics".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("hypervisor_statistics".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "hypervisor_statistics" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hypervisors/statistics".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisor_statistics": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-hypervisors/statistics".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisor_statistics": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/uptime/get.rs b/openstack_sdk/src/api/compute/v2/hypervisor/uptime/get.rs deleted file mode 100644 index ca8cf1541..000000000 --- a/openstack_sdk/src/api/compute/v2/hypervisor/uptime/get.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows the uptime for a given hypervisor. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), NotImplemented(501) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-hypervisors/{id}/uptime 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<'a> RequestBuilder<'a> { - /// Add a single header to the Uptime. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-hypervisors/{id}/uptime", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("hypervisor".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "hypervisor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}/uptime", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisor": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-hypervisors/{id}/uptime", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "hypervisor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/instance_usage_audit_log/get.rs b/openstack_sdk/src/api/compute/v2/instance_usage_audit_log/get.rs deleted file mode 100644 index 95760f824..000000000 --- a/openstack_sdk/src/api/compute/v2/instance_usage_audit_log/get.rs +++ /dev/null @@ -1,186 +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`. - -//! Lists usage audits that occurred before a specified time. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filters the response by the date and time before which to list usage - /// audits. - #[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<'a> RequestBuilder<'a> { - /// Add a single header to the Instance_Usage_Audit_Log. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-instance_usage_audit_log/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-instance_usage_audit_log/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-instance_usage_audit_log/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/instance_usage_audit_log/list.rs b/openstack_sdk/src/api/compute/v2/instance_usage_audit_log/list.rs deleted file mode 100644 index d2148e23c..000000000 --- a/openstack_sdk/src/api/compute/v2/instance_usage_audit_log/list.rs +++ /dev/null @@ -1,179 +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`. - -//! Lists usage audits for all servers on all compute hosts where usage -//! auditing is configured. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Instance_Usage_Audit_Log. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-instance_usage_audit_log".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-instance_usage_audit_log".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-instance_usage_audit_log".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/keypair/create_20.rs b/openstack_sdk/src/api/compute/v2/keypair/create_20.rs deleted file mode 100644 index 78fe676d6..000000000 --- a/openstack_sdk/src/api/compute/v2/keypair/create_20.rs +++ /dev/null @@ -1,233 +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`. - -//! Imports (or generates) a keypair. -//! -//! Normal response codes: 200, 201 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Keypair object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Keypair<'a> { - /// A name for the keypair which will be used to reference it later. - /// - /// Note - /// - /// Since microversion 2.92, allowed characters are ASCII letters - /// `[a-zA-Z]`, digits `[0-9]` and the following special characters: - /// `[@._- ]`. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The public ssh key to import. Was optional before microversion 2.92 : - /// if you were omitting this value, a keypair was generated for you. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) public_key: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Keypair object - #[builder(setter(into))] - pub(crate) keypair: Keypair<'a>, - - #[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 Keypair. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-keypairs".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("keypair", serde_json::to_value(&self.keypair)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("keypair".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "keypair" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-keypairs".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypair": {} })); - }); - - let endpoint = Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-keypairs".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypair": {} })); - }); - - let endpoint = Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/keypair/create_21.rs b/openstack_sdk/src/api/compute/v2/keypair/create_21.rs deleted file mode 100644 index 45a7dadf4..000000000 --- a/openstack_sdk/src/api/compute/v2/keypair/create_21.rs +++ /dev/null @@ -1,233 +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`. - -//! Imports (or generates) a keypair. -//! -//! Normal response codes: 200, 201 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Keypair object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Keypair<'a> { - /// A name for the keypair which will be used to reference it later. - /// - /// Note - /// - /// Since microversion 2.92, allowed characters are ASCII letters - /// `[a-zA-Z]`, digits `[0-9]` and the following special characters: - /// `[@._- ]`. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The public ssh key to import. Was optional before microversion 2.92 : - /// if you were omitting this value, a keypair was generated for you. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) public_key: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Keypair object - #[builder(setter(into))] - pub(crate) keypair: Keypair<'a>, - - #[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 Keypair. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-keypairs".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("keypair", serde_json::to_value(&self.keypair)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("keypair".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "keypair" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-keypairs".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypair": {} })); - }); - - let endpoint = Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-keypairs".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypair": {} })); - }); - - let endpoint = Request::builder() - .keypair(KeypairBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/keypair/delete.rs b/openstack_sdk/src/api/compute/v2/keypair/delete.rs deleted file mode 100644 index 1ea989cc1..000000000 --- a/openstack_sdk/src/api/compute/v2/keypair/delete.rs +++ /dev/null @@ -1,191 +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`. - -//! Deletes a keypair. -//! -//! Normal response codes: 202, 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-keypairs/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Keypair. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-keypairs/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-keypairs/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-keypairs/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/keypair/find.rs b/openstack_sdk/src/api/compute/v2/keypair/find.rs deleted file mode 100644 index c00a7b842..000000000 --- a/openstack_sdk/src/api/compute/v2/keypair/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::compute::v2::keypair::{get as Get, list as List}; - -/// Find for keypair 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate keypair in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // keypair 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") - && let Some(name) = name_as_val.as_str() - && 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/compute/v2/keypair/get.rs b/openstack_sdk/src/api/compute/v2/keypair/get.rs deleted file mode 100644 index 409b5a127..000000000 --- a/openstack_sdk/src/api/compute/v2/keypair/get.rs +++ /dev/null @@ -1,194 +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`. - -//! Shows details for a keypair that is associated with the account. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-keypairs/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Keypair. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-keypairs/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("keypair".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "keypair" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-keypairs/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypair": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-keypairs/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypair": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/keypair/list.rs b/openstack_sdk/src/api/compute/v2/keypair/list.rs deleted file mode 100644 index 850fc6b63..000000000 --- a/openstack_sdk/src/api/compute/v2/keypair/list.rs +++ /dev/null @@ -1,203 +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`. - -//! Lists keypairs that are associated with the account. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Keypair. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-keypairs".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("keypairs".into()) - } - - fn response_list_item_key(&self) -> Option> { - Some("keypair".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "keypairs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-keypairs".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypairs": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-keypairs".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "keypairs": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/limit/list.rs b/openstack_sdk/src/api/compute/v2/limit/list.rs deleted file mode 100644 index 0edb54745..000000000 --- a/openstack_sdk/src/api/compute/v2/limit/list.rs +++ /dev/null @@ -1,189 +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`. - -//! Shows rate and absolute limits for the project. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - tenant_id: 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> { - /// Add a single header to the Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "limits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("limits".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "limits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/migration/get.rs b/openstack_sdk/src/api/compute/v2/migration/get.rs deleted file mode 100644 index 7e220102c..000000000 --- a/openstack_sdk/src/api/compute/v2/migration/get.rs +++ /dev/null @@ -1,242 +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`. - -//! Lists migrations. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Starting from microversion 2.59, the response is sorted by `created_at` and -//! `id` in descending order. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - changes_before: Option>, - - #[builder(default, setter(into))] - changes_since: Option>, - - #[builder(default, setter(into))] - hidden: Option>, - - #[builder(default, setter(into))] - host: Option>, - - #[builder(default, setter(into))] - instance_uuid: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - migration_type: Option>, - - #[builder(default, setter(into))] - project_id: Option>, - - #[builder(default, setter(into))] - source_compute: Option>, - - #[builder(default, setter(into))] - status: Option>, - - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Migration. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-migrations".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("changes-before", self.changes_before.as_ref()); - params.push_opt("changes-since", self.changes_since.as_ref()); - params.push_opt("hidden", self.hidden.as_ref()); - params.push_opt("host", self.host.as_ref()); - params.push_opt("instance_uuid", self.instance_uuid.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("migration_type", self.migration_type.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("source_compute", self.source_compute.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("migrations".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "migrations" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-migrations".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "migrations": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-migrations".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "migrations": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_class_set/get.rs b/openstack_sdk/src/api/compute/v2/quota_class_set/get.rs deleted file mode 100644 index 98ae31b98..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_class_set/get.rs +++ /dev/null @@ -1,188 +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 quota for the Quota Class. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-quota-class-sets/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota_Class_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-quota-class-sets/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_class_set".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota_class_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-class-sets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-class-sets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_class_set/set_21.rs b/openstack_sdk/src/api/compute/v2/quota_class_set/set_21.rs deleted file mode 100644 index ff49a74b5..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_class_set/set_21.rs +++ /dev/null @@ -1,326 +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`. - -//! Update the quotas for the Quota Class. -//! -//! If the requested Quota Class is not found in the DB, then the API will -//! create the one. Only ‘default’ quota class is valid and used to set the -//! default quotas, all other quota class would not be used anywhere. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `quota_class_set` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct QuotaClassSet { - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cores: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ips: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) floating_ips: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) injected_file_content_bytes: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) injected_file_path_bytes: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) injected_files: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) instances: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_pairs: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) metadata_items: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ram: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_group_rules: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_groups: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_group_members: Option, - - /// The number of allowed injected files for the quota class. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_groups: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `quota_class_set` object. - #[builder(setter(into))] - pub(crate) quota_class_set: QuotaClassSet, - - /// id parameter for /v2.1/os-quota-class-sets/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota_Class_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-quota-class-sets/{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( - "quota_class_set", - serde_json::to_value(&self.quota_class_set)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_class_set".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota_class_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-class-sets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-class-sets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_class_set/set_257.rs b/openstack_sdk/src/api/compute/v2/quota_class_set/set_257.rs deleted file mode 100644 index 9b04b761e..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_class_set/set_257.rs +++ /dev/null @@ -1,263 +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`. - -//! Update the quotas for the Quota Class. -//! -//! If the requested Quota Class is not found in the DB, then the API will -//! create the one. Only ‘default’ quota class is valid and used to set the -//! default quotas, all other quota class would not be used anywhere. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `quota_class_set` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct QuotaClassSet { - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cores: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) instances: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_pairs: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) metadata_items: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ram: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_group_members: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_groups: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `quota_class_set` object. - #[builder(setter(into))] - pub(crate) quota_class_set: QuotaClassSet, - - /// id parameter for /v2.1/os-quota-class-sets/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota_Class_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-quota-class-sets/{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( - "quota_class_set", - serde_json::to_value(&self.quota_class_set)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_class_set".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(2, 57)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota_class_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-class-sets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-class-sets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_class_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_set/defaults.rs b/openstack_sdk/src/api/compute/v2/quota_set/defaults.rs deleted file mode 100644 index 11505cada..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_set/defaults.rs +++ /dev/null @@ -1,188 +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`. - -//! Lists the default quotas for a project. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badrequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-quota-sets/{id}/defaults 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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-quota-sets/{id}/defaults", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-sets/{id}/defaults", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-sets/{id}/defaults", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_set/delete.rs b/openstack_sdk/src/api/compute/v2/quota_set/delete.rs deleted file mode 100644 index 1e027ca27..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_set/delete.rs +++ /dev/null @@ -1,195 +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`. - -//! Reverts the quotas to default values for a project or a project and a user. -//! -//! To revert quotas for a project and a user, specify the `user_id` query -//! parameter. -//! -//! Normal response codes: 202 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-quota-sets/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// ID of user to set the quotas for. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-quota-sets/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-quota-sets/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-quota-sets/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_set/details.rs b/openstack_sdk/src/api/compute/v2/quota_set/details.rs deleted file mode 100644 index fbee40d91..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_set/details.rs +++ /dev/null @@ -1,197 +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 detail of quota for a project or a project and a user. -//! -//! To show a quota for a project and a user, specify the `user_id` query -//! parameter. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badrequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-quota-sets/{id}/detail API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-quota-sets/{id}/detail", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-sets/{id}/detail", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-sets/{id}/detail", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_set/get.rs b/openstack_sdk/src/api/compute/v2/quota_set/get.rs deleted file mode 100644 index ae0bb5752..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_set/get.rs +++ /dev/null @@ -1,195 +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 quota for a project or a project and a user. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-quota-sets/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// ID of user to set the quotas for. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-quota-sets/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-sets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-quota-sets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_set/set_20.rs b/openstack_sdk/src/api/compute/v2/quota_set/set_20.rs deleted file mode 100644 index 0d78cff41..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_set/set_20.rs +++ /dev/null @@ -1,338 +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`. - -//! Update the quotas for a project or a project and a user. -//! -//! Users can force the update even if the quota has already been used and the -//! reserved quota exceeds the new quota. To force the update, specify the -//! `"force": True` attribute in the request body, the default value is -//! `false`. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `quota_set` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct QuotaSet { - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cores: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ips: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) floating_ips: Option, - - /// You can force the update even if the quota has already been used and - /// the reserved quota exceeds the new quota. To force the update, specify - /// the `"force": "True"`. Default is `False`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) force: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) injected_file_content_bytes: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) injected_file_path_bytes: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) injected_files: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) instances: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_pairs: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) metadata_items: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ram: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_group_rules: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_groups: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_group_members: Option, - - /// The number of allowed injected files for each tenant. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_groups: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `quota_set` object. - #[builder(setter(into))] - pub(crate) quota_set: QuotaSet, - - /// id parameter for /v2.1/os-quota-sets/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// ID of user to set the quotas for. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-quota-sets/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("quota_set", serde_json::to_value(&self.quota_set)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-sets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-sets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/quota_set/set_257.rs b/openstack_sdk/src/api/compute/v2/quota_set/set_257.rs deleted file mode 100644 index c8d5bf9cb..000000000 --- a/openstack_sdk/src/api/compute/v2/quota_set/set_257.rs +++ /dev/null @@ -1,275 +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`. - -//! Update the quotas for a project or a project and a user. -//! -//! Users can force the update even if the quota has already been used and the -//! reserved quota exceeds the new quota. To force the update, specify the -//! `"force": True` attribute in the request body, the default value is -//! `false`. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `quota_set` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct QuotaSet { - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cores: Option, - - /// You can force the update even if the quota has already been used and - /// the reserved quota exceeds the new quota. To force the update, specify - /// the `"force": "True"`. Default is `False`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) force: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) instances: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_pairs: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) metadata_items: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ram: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_group_members: Option, - - /// The number of allowed members for each server group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) server_groups: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `quota_set` object. - #[builder(setter(into))] - pub(crate) quota_set: QuotaSet, - - /// id parameter for /v2.1/os-quota-sets/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// ID of user to set the quotas for. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Quota_Set. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-quota-sets/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("quota_set", serde_json::to_value(&self.quota_set)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("quota_set".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(2, 57)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota_set" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-sets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-quota-sets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota_set": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota_set(QuotaSetBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/create_20.rs b/openstack_sdk/src/api/compute/v2/server/create_20.rs deleted file mode 100644 index 59e4ba931..000000000 --- a/openstack_sdk/src/api/compute/v2/server/create_20.rs +++ /dev/null @@ -1,916 +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`. - -//! Creates a server. -//! -//! The progress of this operation depends on the location of the requested -//! image, network I/O, host load, selected flavor, and other factors. -//! -//! To check the progress of the request, make a `GET /servers/{id}` request. -//! This call returns a progress attribute, which is a percentage value from 0 -//! to 100. -//! -//! The `Location` header returns the full URL to the newly created server and -//! is available as a `self` and `bookmark` link in the server representation. -//! -//! When you create a server, the response shows only the server ID, its links, -//! and the admin password. You can get additional attributes through -//! subsequent `GET` requests on the server. -//! -//! Include the `block_device_mapping_v2` parameter in the create request body -//! to boot a server from a volume. -//! -//! Include the `key_name` parameter in the create request body to add a -//! keypair to the server when you create it. To create a keypair, make a -//! [create keypair](https://docs.openstack.org/api-ref/compute/#create-or-import-keypair) -//! request. -//! -//! **Preconditions** -//! -//! **Asynchronous postconditions** -//! -//! **Troubleshooting** -//! -//! Normal response codes: 202 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsSchHntSchedulerHints<'a> { - /// Schedule the server on a host in the network specified with this - /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) build_near_host_ip: Option>, - - /// Schedule the server on a host in the network specified with an IP - /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. - /// If `os:scheduler_hints:build_near_host_ip` is specified and this - /// parameter is omitted, `/24` is used. It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cidr: Option>, - - /// A list of cell routes or a cell route (string). Schedule the server in - /// a cell that is not specified. It is available when - /// `DifferentCellFilter` is available on cloud side that is cell v1 - /// environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_cell: Option>>, - - /// A list of server UUIDs or a server UUID. Schedule the server on a - /// different host from a set of servers. It is available when - /// `DifferentHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_host: Option>>, - - /// The server group UUID. Schedule the server according to a policy of the - /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or - /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, - /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, - /// `ServerGroupSoftAffinityWeigher` are available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group: Option>>, - - /// Schedule the server by using a custom filter in JSON format. For - /// example: - /// - /// ```text - /// "query": "[\">=\",\"$free_ram_mb\",1024]" - /// ``` - /// - /// It is available when `JsonFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) query: Option, - - /// A list of server UUIDs or a server UUID. Schedule the server on the - /// same host as another server in a set of servers. It is available when - /// `SameHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) same_host: Option>>, - - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) target_cell: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> OsSchHntSchedulerHintsBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -/// The dictionary of data to send to the scheduler. Alternatively, you can -/// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. -/// -/// Note -/// -/// This is a top-level key in the request body, not part of the server portion -/// of the request body. -/// -/// There are a few caveats with scheduler hints: -/// -/// - The request validation schema is per hint. For example, some require a -/// single string value, and some accept a list of values. -/// - Hints are only used based on the cloud scheduler configuration, which -/// varies per deployment. -/// - Hints are pluggable per deployment, meaning that a cloud can have custom -/// hints which may not be available in another cloud. -/// -/// For these reasons, it is important to consult each cloud’s user -/// documentation to know what is available for scheduler hints. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsSchedulerHints<'a> { - /// Schedule the server on a host in the network specified with this - /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) build_near_host_ip: Option>, - - /// Schedule the server on a host in the network specified with an IP - /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. - /// If `os:scheduler_hints:build_near_host_ip` is specified and this - /// parameter is omitted, `/24` is used. It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cidr: Option>, - - /// A list of cell routes or a cell route (string). Schedule the server in - /// a cell that is not specified. It is available when - /// `DifferentCellFilter` is available on cloud side that is cell v1 - /// environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_cell: Option>>, - - /// A list of server UUIDs or a server UUID. Schedule the server on a - /// different host from a set of servers. It is available when - /// `DifferentHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_host: Option>>, - - /// The server group UUID. Schedule the server according to a policy of the - /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or - /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, - /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, - /// `ServerGroupSoftAffinityWeigher` are available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group: Option>>, - - /// Schedule the server by using a custom filter in JSON format. For - /// example: - /// - /// ```text - /// "query": "[\">=\",\"$free_ram_mb\",1024]" - /// ``` - /// - /// It is available when `JsonFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) query: Option, - - /// A list of server UUIDs or a server UUID. Schedule the server on the - /// same host as another server in a set of servers. It is available when - /// `SameHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) same_host: Option>>, - - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) target_cell: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> OsSchedulerHintsBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum OsDcfDiskConfig { - #[serde(rename = "AUTO")] - Auto, - #[serde(rename = "MANUAL")] - Manual, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct BlockDeviceMapping<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) connection_info: Option>, - - /// Indicates whether a config drive enables metadata injection. The - /// config_drive setting provides information about a drive that the - /// instance can mount at boot time. The instance reads files from the - /// drive to get information that is normally available through the - /// metadata service. This metadata is different from the user data. Not - /// all cloud providers enable the `config_drive`. Read more in the - /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) delete_on_termination: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_name: Option>, - - /// OpenAPI specifies the field as '{}'. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) no_device: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) snapshot_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) virtual_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_size: Option, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum DestinationType { - #[serde(rename = "local")] - Local, - #[serde(rename = "volume")] - Volume, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum SourceType { - #[serde(rename = "blank")] - Blank, - #[serde(rename = "image")] - Image, - #[serde(rename = "snapshot")] - Snapshot, - #[serde(rename = "volume")] - Volume, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct BlockDeviceMappingV2<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) boot_index: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) connection_info: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) delete_on_termination: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) destination_type: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_type: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) disk_bus: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) guest_format: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_id: Option>, - - /// OpenAPI specifies the field as '{}'. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) no_device: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) snapshot_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) source_type: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) uuid: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) virtual_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_size: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Networks<'a> { - /// Schedule the server on a host in the network specified with this - /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ip: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) uuid: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Personality<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) contents: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) path: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SecurityGroups<'a> { - /// Key pair name. - /// - /// Note - /// - /// The `null` value was allowed in the Nova legacy v2 API, but due to - /// strict input validation, it is not allowed in the Nova v2.1 API. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// A `server` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Server<'a> { - /// IPv4 address that should be used to access this server. - #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv4: Option>, - - /// IPv6 address that should be used to access this server. - #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv6: Option>, - - /// The administrative password of the server. If you omit this parameter, - /// the operation generates a new password. - #[serde(rename = "adminPass", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_pass: Option>, - - /// Key pair name. - /// - /// Note - /// - /// The `null` value was allowed in the Nova legacy v2 API, but due to - /// strict input validation, it is not allowed in the Nova v2.1 API. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) block_device_mapping: Option>>, - - /// Enables fine grained control of the block device mapping for an - /// instance. This is typically used for booting servers from volumes. An - /// example format would look as follows: - /// - /// > ```text - /// > "block_device_mapping_v2": [{ - /// > "boot_index": "0", - /// > "uuid": "ac408821-c95a-448f-9292-73986c790911", - /// > "source_type": "image", - /// > "volume_size": "25", - /// > "destination_type": "volume", - /// > "delete_on_termination": true, - /// > "tag": "disk1", - /// > "disk_bus": "scsi"}] - /// > ``` - /// - /// In microversion 2.32, `tag` is an optional string attribute that can be - /// used to assign a tag to the block device. This tag is then exposed to - /// the guest in the metadata API and the config drive and is associated to - /// hardware metadata for that block device, such as bus (ex: SCSI), bus - /// address (ex: 1:0:2:0), and serial. - /// - /// A bug has caused the `tag` attribute to no longer be accepted starting - /// with version 2.33. It has been restored in version 2.42. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) block_device_mapping_v2: Option>>, - - /// Indicates whether a config drive enables metadata injection. The - /// config_drive setting provides information about a drive that the - /// instance can mount at boot time. The instance reads files from the - /// drive to get information that is normally available through the - /// metadata service. This metadata is different from the user data. Not - /// all cloud providers enable the `config_drive`. Read more in the - /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) config_drive: Option, - - /// The flavor reference, as an ID (including a UUID) or full URL, for the - /// flavor for your server instance. - #[serde(rename = "flavorRef")] - #[builder(setter(into))] - pub(crate) flavor_ref: Cow<'a, str>, - - /// The UUID of the image to use for your server instance. This is not - /// required in case of boot from volume. In all other cases it is required - /// and must be a valid UUID otherwise API will return 400. - #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_ref: Option>, - - /// Key pair name. - /// - /// Note - /// - /// The `null` value was allowed in the Nova legacy v2 API, but due to - /// strict input validation, it is not allowed in the Nova v2.1 API. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_count: Option, - - /// Metadata key and value pairs. The maximum size of the metadata key and - /// value is 255 bytes each. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_count: Option, - - /// Key pair name. - /// - /// Note - /// - /// The `null` value was allowed in the Nova legacy v2 API, but due to - /// strict input validation, it is not allowed in the Nova v2.1 API. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// A list of `network` object. Required parameter when there are multiple - /// networks defined for the tenant. When you do not specify the networks - /// parameter, the server attaches to the only network created for the - /// current tenant. Optionally, you can create one or more NICs on the - /// server. To provision the server instance with a NIC for a network, - /// specify the UUID of the network in the `uuid` attribute in a `networks` - /// object. To provision the server instance with a NIC for an already - /// existing port, specify the port-id in the `port` attribute in a - /// `networks` object. - /// - /// If multiple networks are defined, the order in which they appear in the - /// guest operating system will not necessarily reflect the order in which - /// they are given in the server boot request. Guests should therefore not - /// depend on device order to deduce any information about their network - /// devices. Instead, device role tags should be used: introduced in 2.32, - /// broken in 2.37, and re-introduced and fixed in 2.42, the `tag` is an - /// optional, string attribute that can be used to assign a tag to a - /// virtual network interface. This tag is then exposed to the guest in the - /// metadata API and the config drive and is associated to hardware - /// metadata for that network interface, such as bus (ex: PCI), bus address - /// (ex: 0000:00:02.0), and MAC address. - /// - /// A bug has caused the `tag` attribute to no longer be accepted starting - /// with version 2.37. Therefore, network interfaces could only be tagged - /// in versions 2.32 to 2.36 inclusively. Version 2.42 has restored the - /// `tag` attribute. - /// - /// Starting with microversion 2.37, this field is required and the special - /// string values *auto* and *none* can be specified for networks. *auto* - /// tells the Compute service to use a network that is available to the - /// project, if one exists. If one does not exist, the Compute service will - /// attempt to automatically allocate a network for the project (if - /// possible). *none* tells the Compute service to not allocate a network - /// for the instance. The *auto* and *none* values cannot be used with any - /// other network values, including other network uuids, ports, fixed IPs - /// or device tags. These are requested as strings for the networks value, - /// not in a list. See the associated example. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) networks: Option>>, - - /// Controls how the API partitions the disk when you create, rebuild, or - /// resize servers. A server inherits the `OS-DCF:diskConfig` value from - /// the image from which it was created, and an image inherits the - /// `OS-DCF:diskConfig` value from the server from which it was created. To - /// override the inherited setting, you can include this attribute in the - /// request body of a server create, rebuild, or resize request. If the - /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a - /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. - /// A valid value is: - /// - /// - `AUTO`. The API builds the server with a single partition the size of - /// the target flavor disk. The API automatically adjusts the file system - /// to fit the entire partition. - /// - `MANUAL`. The API builds the server by using whatever partition - /// scheme and file system is in the source image. If the target flavor - /// disk is larger, the API does not partition the remaining disk space. - #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) os_dcf_disk_config: Option, - - /// The file path and contents, text only, to inject into the server at - /// launch. The maximum size of the file path data is 255 bytes. The - /// maximum limit is the number of allowed bytes in the decoded, rather - /// than encoded, data. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) personality: Option>>, - - /// Indicates whether a config drive enables metadata injection. The - /// config_drive setting provides information about a drive that the - /// instance can mount at boot time. The instance reads files from the - /// drive to get information that is normally available through the - /// metadata service. This metadata is different from the user data. Not - /// all cloud providers enable the `config_drive`. Read more in the - /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) return_reservation_id: Option, - - /// One or more security groups. Specify the name of the security group in - /// the `name` attribute. If you omit this attribute, the API creates the - /// server in the `default` security group. Requested security groups are - /// not applied to pre-existing ports. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_groups: Option>>, - - /// Configuration information or scripts to use upon launch. Must be Base64 - /// encoded. Restricted to 65535 bytes. - /// - /// Note - /// - /// The `null` value allowed in Nova legacy v2 API, but due to the strict - /// input validation, it isn’t allowed in Nova v2.1 API. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user_data: Option>>, -} - -impl<'a> ServerBuilder<'a> { - /// Metadata key and value pairs. The maximum size of the metadata key and - /// value is 255 bytes each. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - pub(crate) os_sch_hnt_scheduler_hints: Option>, - - /// The dictionary of data to send to the scheduler. Alternatively, you can - /// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. - /// - /// Note - /// - /// This is a top-level key in the request body, not part of the server - /// portion of the request body. - /// - /// There are a few caveats with scheduler hints: - /// - /// - The request validation schema is per hint. For example, some require - /// a single string value, and some accept a list of values. - /// - Hints are only used based on the cloud scheduler configuration, which - /// varies per deployment. - /// - Hints are pluggable per deployment, meaning that a cloud can have - /// custom hints which may not be available in another cloud. - /// - /// For these reasons, it is important to consult each cloud’s user - /// documentation to know what is available for scheduler hints. - #[builder(default, setter(into))] - pub(crate) os_scheduler_hints: Option>, - - /// A `server` object. - #[builder(setter(into))] - pub(crate) server: Server<'a>, - - #[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 Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "servers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.os_sch_hnt_scheduler_hints { - params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); - } - if let Some(val) = &self.os_scheduler_hints { - params.push("os:scheduler_hints", serde_json::to_value(val)?); - } - params.push("server", serde_json::to_value(&self.server)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "server" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/servers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/servers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/create_21.rs b/openstack_sdk/src/api/compute/v2/server/create_21.rs deleted file mode 100644 index 4f138a911..000000000 --- a/openstack_sdk/src/api/compute/v2/server/create_21.rs +++ /dev/null @@ -1,904 +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`. - -//! Creates a server. -//! -//! The progress of this operation depends on the location of the requested -//! image, network I/O, host load, selected flavor, and other factors. -//! -//! To check the progress of the request, make a `GET /servers/{id}` request. -//! This call returns a progress attribute, which is a percentage value from 0 -//! to 100. -//! -//! The `Location` header returns the full URL to the newly created server and -//! is available as a `self` and `bookmark` link in the server representation. -//! -//! When you create a server, the response shows only the server ID, its links, -//! and the admin password. You can get additional attributes through -//! subsequent `GET` requests on the server. -//! -//! Include the `block_device_mapping_v2` parameter in the create request body -//! to boot a server from a volume. -//! -//! Include the `key_name` parameter in the create request body to add a -//! keypair to the server when you create it. To create a keypair, make a -//! [create keypair](https://docs.openstack.org/api-ref/compute/#create-or-import-keypair) -//! request. -//! -//! **Preconditions** -//! -//! **Asynchronous postconditions** -//! -//! **Troubleshooting** -//! -//! Normal response codes: 202 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsSchHntSchedulerHints<'a> { - /// Schedule the server on a host in the network specified with this - /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) build_near_host_ip: Option>, - - /// Schedule the server on a host in the network specified with an IP - /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. - /// If `os:scheduler_hints:build_near_host_ip` is specified and this - /// parameter is omitted, `/24` is used. It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cidr: Option>, - - /// A list of cell routes or a cell route (string). Schedule the server in - /// a cell that is not specified. It is available when - /// `DifferentCellFilter` is available on cloud side that is cell v1 - /// environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_cell: Option>>, - - /// A list of server UUIDs or a server UUID. Schedule the server on a - /// different host from a set of servers. It is available when - /// `DifferentHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_host: Option>>, - - /// The server group UUID. Schedule the server according to a policy of the - /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or - /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, - /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, - /// `ServerGroupSoftAffinityWeigher` are available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group: Option>>, - - /// Schedule the server by using a custom filter in JSON format. For - /// example: - /// - /// ```text - /// "query": "[\">=\",\"$free_ram_mb\",1024]" - /// ``` - /// - /// It is available when `JsonFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) query: Option, - - /// A list of server UUIDs or a server UUID. Schedule the server on the - /// same host as another server in a set of servers. It is available when - /// `SameHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) same_host: Option>>, - - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) target_cell: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> OsSchHntSchedulerHintsBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -/// The dictionary of data to send to the scheduler. Alternatively, you can -/// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. -/// -/// Note -/// -/// This is a top-level key in the request body, not part of the server portion -/// of the request body. -/// -/// There are a few caveats with scheduler hints: -/// -/// - The request validation schema is per hint. For example, some require a -/// single string value, and some accept a list of values. -/// - Hints are only used based on the cloud scheduler configuration, which -/// varies per deployment. -/// - Hints are pluggable per deployment, meaning that a cloud can have custom -/// hints which may not be available in another cloud. -/// -/// For these reasons, it is important to consult each cloud’s user -/// documentation to know what is available for scheduler hints. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsSchedulerHints<'a> { - /// Schedule the server on a host in the network specified with this - /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) build_near_host_ip: Option>, - - /// Schedule the server on a host in the network specified with an IP - /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. - /// If `os:scheduler_hints:build_near_host_ip` is specified and this - /// parameter is omitted, `/24` is used. It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cidr: Option>, - - /// A list of cell routes or a cell route (string). Schedule the server in - /// a cell that is not specified. It is available when - /// `DifferentCellFilter` is available on cloud side that is cell v1 - /// environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_cell: Option>>, - - /// A list of server UUIDs or a server UUID. Schedule the server on a - /// different host from a set of servers. It is available when - /// `DifferentHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) different_host: Option>>, - - /// The server group UUID. Schedule the server according to a policy of the - /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or - /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, - /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, - /// `ServerGroupSoftAffinityWeigher` are available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group: Option>>, - - /// Schedule the server by using a custom filter in JSON format. For - /// example: - /// - /// ```text - /// "query": "[\">=\",\"$free_ram_mb\",1024]" - /// ``` - /// - /// It is available when `JsonFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) query: Option, - - /// A list of server UUIDs or a server UUID. Schedule the server on the - /// same host as another server in a set of servers. It is available when - /// `SameHostFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) same_host: Option>>, - - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) target_cell: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> OsSchedulerHintsBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum OsDcfDiskConfig { - #[serde(rename = "AUTO")] - Auto, - #[serde(rename = "MANUAL")] - Manual, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct BlockDeviceMapping<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) connection_info: Option>, - - /// Indicates whether a config drive enables metadata injection. The - /// config_drive setting provides information about a drive that the - /// instance can mount at boot time. The instance reads files from the - /// drive to get information that is normally available through the - /// metadata service. This metadata is different from the user data. Not - /// all cloud providers enable the `config_drive`. Read more in the - /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) delete_on_termination: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_name: Option>, - - /// OpenAPI specifies the field as '{}'. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) no_device: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) snapshot_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) virtual_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_size: Option, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum DestinationType { - #[serde(rename = "local")] - Local, - #[serde(rename = "volume")] - Volume, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum SourceType { - #[serde(rename = "blank")] - Blank, - #[serde(rename = "image")] - Image, - #[serde(rename = "snapshot")] - Snapshot, - #[serde(rename = "volume")] - Volume, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct BlockDeviceMappingV2<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) boot_index: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) connection_info: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) delete_on_termination: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) destination_type: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_type: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) disk_bus: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) guest_format: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_id: Option>, - - /// OpenAPI specifies the field as '{}'. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) no_device: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) snapshot_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) source_type: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) uuid: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) virtual_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) volume_size: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Networks<'a> { - /// Schedule the server on a host in the network specified with this - /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when - /// `SimpleCIDRAffinityFilter` is available on cloud side. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ip: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) uuid: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Personality<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) contents: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) path: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SecurityGroups<'a> { - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// A `server` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Server<'a> { - /// IPv4 address that should be used to access this server. - #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv4: Option>, - - /// IPv6 address that should be used to access this server. - #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv6: Option>, - - /// The administrative password of the server. If you omit this parameter, - /// the operation generates a new password. - #[serde(rename = "adminPass", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_pass: Option>, - - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) block_device_mapping: Option>>, - - /// Enables fine grained control of the block device mapping for an - /// instance. This is typically used for booting servers from volumes. An - /// example format would look as follows: - /// - /// > ```text - /// > "block_device_mapping_v2": [{ - /// > "boot_index": "0", - /// > "uuid": "ac408821-c95a-448f-9292-73986c790911", - /// > "source_type": "image", - /// > "volume_size": "25", - /// > "destination_type": "volume", - /// > "delete_on_termination": true, - /// > "tag": "disk1", - /// > "disk_bus": "scsi"}] - /// > ``` - /// - /// In microversion 2.32, `tag` is an optional string attribute that can be - /// used to assign a tag to the block device. This tag is then exposed to - /// the guest in the metadata API and the config drive and is associated to - /// hardware metadata for that block device, such as bus (ex: SCSI), bus - /// address (ex: 1:0:2:0), and serial. - /// - /// A bug has caused the `tag` attribute to no longer be accepted starting - /// with version 2.33. It has been restored in version 2.42. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) block_device_mapping_v2: Option>>, - - /// Indicates whether a config drive enables metadata injection. The - /// config_drive setting provides information about a drive that the - /// instance can mount at boot time. The instance reads files from the - /// drive to get information that is normally available through the - /// metadata service. This metadata is different from the user data. Not - /// all cloud providers enable the `config_drive`. Read more in the - /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) config_drive: Option, - - /// The flavor reference, as an ID (including a UUID) or full URL, for the - /// flavor for your server instance. - #[serde(rename = "flavorRef")] - #[builder(setter(into))] - pub(crate) flavor_ref: Cow<'a, str>, - - /// The UUID of the image to use for your server instance. This is not - /// required in case of boot from volume. In all other cases it is required - /// and must be a valid UUID otherwise API will return 400. - #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) image_ref: Option>, - - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_count: Option, - - /// Metadata key and value pairs. The maximum size of the metadata key and - /// value is 255 bytes each. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Cow<'a, str>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_count: Option, - - /// A target cell name. Schedule the server in a host in the cell - /// specified. It is available when `TargetCellFilter` is available on - /// cloud side that is cell v1 environment. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// A list of `network` object. Required parameter when there are multiple - /// networks defined for the tenant. When you do not specify the networks - /// parameter, the server attaches to the only network created for the - /// current tenant. Optionally, you can create one or more NICs on the - /// server. To provision the server instance with a NIC for a network, - /// specify the UUID of the network in the `uuid` attribute in a `networks` - /// object. To provision the server instance with a NIC for an already - /// existing port, specify the port-id in the `port` attribute in a - /// `networks` object. - /// - /// If multiple networks are defined, the order in which they appear in the - /// guest operating system will not necessarily reflect the order in which - /// they are given in the server boot request. Guests should therefore not - /// depend on device order to deduce any information about their network - /// devices. Instead, device role tags should be used: introduced in 2.32, - /// broken in 2.37, and re-introduced and fixed in 2.42, the `tag` is an - /// optional, string attribute that can be used to assign a tag to a - /// virtual network interface. This tag is then exposed to the guest in the - /// metadata API and the config drive and is associated to hardware - /// metadata for that network interface, such as bus (ex: PCI), bus address - /// (ex: 0000:00:02.0), and MAC address. - /// - /// A bug has caused the `tag` attribute to no longer be accepted starting - /// with version 2.37. Therefore, network interfaces could only be tagged - /// in versions 2.32 to 2.36 inclusively. Version 2.42 has restored the - /// `tag` attribute. - /// - /// Starting with microversion 2.37, this field is required and the special - /// string values *auto* and *none* can be specified for networks. *auto* - /// tells the Compute service to use a network that is available to the - /// project, if one exists. If one does not exist, the Compute service will - /// attempt to automatically allocate a network for the project (if - /// possible). *none* tells the Compute service to not allocate a network - /// for the instance. The *auto* and *none* values cannot be used with any - /// other network values, including other network uuids, ports, fixed IPs - /// or device tags. These are requested as strings for the networks value, - /// not in a list. See the associated example. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) networks: Option>>, - - /// Controls how the API partitions the disk when you create, rebuild, or - /// resize servers. A server inherits the `OS-DCF:diskConfig` value from - /// the image from which it was created, and an image inherits the - /// `OS-DCF:diskConfig` value from the server from which it was created. To - /// override the inherited setting, you can include this attribute in the - /// request body of a server create, rebuild, or resize request. If the - /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a - /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. - /// A valid value is: - /// - /// - `AUTO`. The API builds the server with a single partition the size of - /// the target flavor disk. The API automatically adjusts the file system - /// to fit the entire partition. - /// - `MANUAL`. The API builds the server by using whatever partition - /// scheme and file system is in the source image. If the target flavor - /// disk is larger, the API does not partition the remaining disk space. - #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) os_dcf_disk_config: Option, - - /// The file path and contents, text only, to inject into the server at - /// launch. The maximum size of the file path data is 255 bytes. The - /// maximum limit is the number of allowed bytes in the decoded, rather - /// than encoded, data. - /// - /// **Available until version 2.56** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) personality: Option>>, - - /// Indicates whether a config drive enables metadata injection. The - /// config_drive setting provides information about a drive that the - /// instance can mount at boot time. The instance reads files from the - /// drive to get information that is normally available through the - /// metadata service. This metadata is different from the user data. Not - /// all cloud providers enable the `config_drive`. Read more in the - /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) return_reservation_id: Option, - - /// One or more security groups. Specify the name of the security group in - /// the `name` attribute. If you omit this attribute, the API creates the - /// server in the `default` security group. Requested security groups are - /// not applied to pre-existing ports. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_groups: Option>>, - - /// Configuration information or scripts to use upon launch. Must be Base64 - /// encoded. Restricted to 65535 bytes. - /// - /// Note - /// - /// The `null` value allowed in Nova legacy v2 API, but due to the strict - /// input validation, it isn’t allowed in Nova v2.1 API. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user_data: Option>, -} - -impl<'a> ServerBuilder<'a> { - /// Metadata key and value pairs. The maximum size of the metadata key and - /// value is 255 bytes each. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - pub(crate) os_sch_hnt_scheduler_hints: Option>, - - /// The dictionary of data to send to the scheduler. Alternatively, you can - /// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. - /// - /// Note - /// - /// This is a top-level key in the request body, not part of the server - /// portion of the request body. - /// - /// There are a few caveats with scheduler hints: - /// - /// - The request validation schema is per hint. For example, some require - /// a single string value, and some accept a list of values. - /// - Hints are only used based on the cloud scheduler configuration, which - /// varies per deployment. - /// - Hints are pluggable per deployment, meaning that a cloud can have - /// custom hints which may not be available in another cloud. - /// - /// For these reasons, it is important to consult each cloud’s user - /// documentation to know what is available for scheduler hints. - #[builder(default, setter(into))] - pub(crate) os_scheduler_hints: Option>, - - /// A `server` object. - #[builder(setter(into))] - pub(crate) server: Server<'a>, - - #[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 Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "servers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.os_sch_hnt_scheduler_hints { - params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); - } - if let Some(val) = &self.os_scheduler_hints { - params.push("os:scheduler_hints", serde_json::to_value(val)?); - } - params.push("server", serde_json::to_value(&self.server)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "server" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/servers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/servers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .server( - ServerBuilder::default() - .flavor_ref("foo") - .name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/delete.rs b/openstack_sdk/src/api/compute/v2/server/delete.rs deleted file mode 100644 index 7aae8bedb..000000000 --- a/openstack_sdk/src/api/compute/v2/server/delete.rs +++ /dev/null @@ -1,199 +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`. - -//! Deletes a server. -//! -//! By default, the instance is going to be (hard) deleted immediately from the -//! system, but you can set `reclaim_instance_interval` > 0 to make the API -//! soft delete the instance, so that the instance won’t be deleted until the -//! `reclaim_instance_interval` has expired since the instance was soft -//! deleted. The instance marked as `SOFT_DELETED` can be recovered via -//! `restore` action before it’s really deleted from the system. -//! -//! **Preconditions** -//! -//! **Asynchronous postconditions** -//! -//! **Troubleshooting** -//! -//! Normal response codes: 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("servers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/servers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/servers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/diagnostic/get.rs b/openstack_sdk/src/api/compute/v2/server/diagnostic/get.rs deleted file mode 100644 index 579b8d6a6..000000000 --- a/openstack_sdk/src/api/compute/v2/server/diagnostic/get.rs +++ /dev/null @@ -1,198 +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`. - -//! Shows basic usage data for a server. -//! -//! Policy defaults enable only users with the administrative role. Cloud -//! providers can change these permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), notfound(404), -//! conflict(409), notimplemented(501) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/diagnostics API - #[builder(default, setter(into))] - server_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 Diagnostic. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/diagnostics", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/diagnostics", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/diagnostics", - server_id = "server_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() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/find.rs b/openstack_sdk/src/api/compute/v2/server/find.rs deleted file mode 100644 index f9eec5dfb..000000000 --- a/openstack_sdk/src/api/compute/v2/server/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::compute::v2::server::{get as Get, list_detailed as List}; - -/// Find for server 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/get.rs b/openstack_sdk/src/api/compute/v2/server/get.rs deleted file mode 100644 index 914a07656..000000000 --- a/openstack_sdk/src/api/compute/v2/server/get.rs +++ /dev/null @@ -1,203 +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`. - -//! Shows details for a server. -//! -//! Includes server details including configuration drive, extended status, and -//! server usage information. -//! -//! The extended status information appears in the `OS-EXT-STS:vm_state`, -//! `OS-EXT-STS:power_state`, and `OS-EXT-STS:task_state` attributes. -//! -//! The server usage information appears in the `OS-SRV-USG:launched_at` and -//! `OS-SRV-USG:terminated_at` attributes. -//! -//! HostId is unique per account and is not globally unique. -//! -//! **Preconditions** -//! -//! The server must exist. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("servers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "server" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/servers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/servers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/instance_action/get.rs b/openstack_sdk/src/api/compute/v2/server/instance_action/get.rs deleted file mode 100644 index 7222f6b0a..000000000 --- a/openstack_sdk/src/api/compute/v2/server/instance_action/get.rs +++ /dev/null @@ -1,217 +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`. - -//! Shows details for a server action. -//! -//! Action details of deleted instances can be returned for requests later than -//! microversion 2.21. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/os-instance-actions/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-instance-actions/{id} API - #[builder(default, setter(into))] - server_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 Instance_Action. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-instance-actions/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("instanceAction".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "instanceAction" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-instance-actions/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "instanceAction": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-instance-actions/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "instanceAction": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/instance_action/list.rs b/openstack_sdk/src/api/compute/v2/server/instance_action/list.rs deleted file mode 100644 index cb784da57..000000000 --- a/openstack_sdk/src/api/compute/v2/server/instance_action/list.rs +++ /dev/null @@ -1,226 +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`. - -//! Lists actions for a server. -//! -//! Action information of deleted instances can be returned for requests -//! starting with microversion 2.21. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - changes_before: Option>, - - #[builder(default, setter(into))] - changes_since: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-instance-actions/{id} API - #[builder(default, setter(into))] - server_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 Instance_Action. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-instance-actions", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("changes-before", self.changes_before.as_ref()); - params.push_opt("changes-since", self.changes_since.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("instanceActions".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "instanceActions" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-instance-actions", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "instanceActions": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-instance-actions", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "instanceActions": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/interface/create_20.rs b/openstack_sdk/src/api/compute/v2/server/interface/create_20.rs deleted file mode 100644 index 8b7959f79..000000000 --- a/openstack_sdk/src/api/compute/v2/server/interface/create_20.rs +++ /dev/null @@ -1,266 +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`. - -//! Creates a port interface and uses it to attach a port to a server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409), computeFault(500), NotImplemented(501) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct FixedIps<'a> { - /// The IP address. It is required when `fixed_ips` is specified. - #[serde()] - #[builder(setter(into))] - pub(crate) ip_address: Cow<'a, str>, -} - -/// Specify the `interfaceAttachment` action in the request body. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InterfaceAttachment<'a> { - /// Fixed IP addresses. If you request a specific fixed IP address without - /// a `net_id`, the request returns a `Bad Request (400)` response code. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ips: Option>>, - - /// The ID of the network for which you want to create a port interface. - /// The `net_id` and `port_id` parameters are mutually exclusive. If you do - /// not specify the `net_id` parameter, the OpenStack Networking API v2.0 - /// uses the network information cache that is associated with the - /// instance. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) net_id: Option>, - - /// The ID of the port for which you want to create an interface. The - /// `net_id` and `port_id` parameters are mutually exclusive. If you do not - /// specify the `port_id` parameter, the OpenStack Networking API v2.0 - /// allocates a port and creates an interface for it on the network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Specify the `interfaceAttachment` action in the request body. - #[builder(setter(into))] - pub(crate) interface_attachment: InterfaceAttachment<'a>, - - /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API - #[builder(default, setter(into))] - server_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 Interface. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "servers/{server_id}/os-interface", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "interfaceAttachment", - serde_json::to_value(&self.interface_attachment)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("interfaceAttachment".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "interfaceAttachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/servers/{server_id}/os-interface", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "interfaceAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/servers/{server_id}/os-interface", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "interfaceAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/interface/create_249.rs b/openstack_sdk/src/api/compute/v2/server/interface/create_249.rs deleted file mode 100644 index c4f8a7ce1..000000000 --- a/openstack_sdk/src/api/compute/v2/server/interface/create_249.rs +++ /dev/null @@ -1,276 +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`. - -//! Creates a port interface and uses it to attach a port to a server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409), computeFault(500), NotImplemented(501) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct FixedIps<'a> { - /// The IP address. It is required when `fixed_ips` is specified. - #[serde()] - #[builder(setter(into))] - pub(crate) ip_address: Cow<'a, str>, -} - -/// Specify the `interfaceAttachment` action in the request body. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InterfaceAttachment<'a> { - /// Fixed IP addresses. If you request a specific fixed IP address without - /// a `net_id`, the request returns a `Bad Request (400)` response code. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ips: Option>>, - - /// The ID of the network for which you want to create a port interface. - /// The `net_id` and `port_id` parameters are mutually exclusive. If you do - /// not specify the `net_id` parameter, the OpenStack Networking API v2.0 - /// uses the network information cache that is associated with the - /// instance. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) net_id: Option>, - - /// The ID of the port for which you want to create an interface. The - /// `net_id` and `port_id` parameters are mutually exclusive. If you do not - /// specify the `port_id` parameter, the OpenStack Networking API v2.0 - /// allocates a port and creates an interface for it on the network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_id: Option>, - - /// A device role tag that can be applied to a network interface when - /// attaching it to the VM. The guest OS of a server that has devices - /// tagged in this manner can access hardware metadata about the tagged - /// devices from the metadata API and on the config drive, if enabled. - /// - /// **New in version 2.49** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tag: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Specify the `interfaceAttachment` action in the request body. - #[builder(setter(into))] - pub(crate) interface_attachment: InterfaceAttachment<'a>, - - /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API - #[builder(default, setter(into))] - server_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 Interface. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "servers/{server_id}/os-interface", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "interfaceAttachment", - serde_json::to_value(&self.interface_attachment)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("interfaceAttachment".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(2, 49)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "interfaceAttachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/servers/{server_id}/os-interface", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "interfaceAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/servers/{server_id}/os-interface", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "interfaceAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/interface/delete.rs b/openstack_sdk/src/api/compute/v2/server/interface/delete.rs deleted file mode 100644 index 78c52257e..000000000 --- a/openstack_sdk/src/api/compute/v2/server/interface/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Detaches a port interface from a server. -//! -//! Normal response codes: 202 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), -//! conflict(409), NotImplemented(501) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/os-interface/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API - #[builder(default, setter(into))] - server_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 Interface. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-interface/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/os-interface/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/os-interface/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/interface/get.rs b/openstack_sdk/src/api/compute/v2/server/interface/get.rs deleted file mode 100644 index 3c051ca74..000000000 --- a/openstack_sdk/src/api/compute/v2/server/interface/get.rs +++ /dev/null @@ -1,209 +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`. - -//! Shows details for a port interface that is attached to a server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/os-interface/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API - #[builder(default, setter(into))] - server_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 Interface. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-interface/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("interfaceAttachment".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "interfaceAttachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-interface/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "interfaceAttachment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-interface/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "interfaceAttachment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/interface/list.rs b/openstack_sdk/src/api/compute/v2/server/interface/list.rs deleted file mode 100644 index c3cad3b98..000000000 --- a/openstack_sdk/src/api/compute/v2/server/interface/list.rs +++ /dev/null @@ -1,195 +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`. - -//! Lists port interfaces that are attached to a server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), -//! NotImplemented(501) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API - #[builder(default, setter(into))] - server_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 Interface. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-interface", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-interface", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-interface", - server_id = "server_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() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/ip/get.rs b/openstack_sdk/src/api/compute/v2/server/ip/get.rs deleted file mode 100644 index 8413e1f93..000000000 --- a/openstack_sdk/src/api/compute/v2/server/ip/get.rs +++ /dev/null @@ -1,210 +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`. - -//! Shows IP addresses details for a network label of a server instance. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/ips/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/ips/{id} API - #[builder(default, setter(into))] - server_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 Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/ips/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/ips/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/ips/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/ip/list.rs b/openstack_sdk/src/api/compute/v2/server/ip/list.rs deleted file mode 100644 index 8fec936bb..000000000 --- a/openstack_sdk/src/api/compute/v2/server/ip/list.rs +++ /dev/null @@ -1,196 +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`. - -//! Lists IP addresses that are assigned to an instance. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/ips/{id} API - #[builder(default, setter(into))] - server_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 Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/ips", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("addresses".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "addresses" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/servers/{server_id}/ips", server_id = "server_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "addresses": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/servers/{server_id}/ips", server_id = "server_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "addresses": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/list.rs b/openstack_sdk/src/api/compute/v2/server/list.rs deleted file mode 100644 index 3bff7c44e..000000000 --- a/openstack_sdk/src/api/compute/v2/server/list.rs +++ /dev/null @@ -1,426 +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`. - -//! Lists IDs, names, and links for servers. -//! -//! By default the servers are filtered using the project ID associated with -//! the authenticated request. -//! -//! Servers contain a status attribute that indicates the current server state. -//! You can filter on the server status when you complete a list servers -//! request. The server status is returned in the response body. The possible -//! server status values are: -//! -//! There is whitelist for valid filter keys. Any filter key other than from -//! whitelist will be silently ignored. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - access_ip_v4: Option>, - - #[builder(default, setter(into))] - access_ip_v6: Option>, - - #[builder(default, setter(into))] - all_tenants: Option>, - - #[builder(default, setter(into))] - auto_disk_config: Option>, - - #[builder(default, setter(into))] - availability_zone: Option>, - - #[builder(default, setter(into))] - block_device_mapping: Option>, - - #[builder(default, setter(into))] - changes_before: Option>, - - #[builder(default, setter(into))] - changes_since: Option>, - - #[builder(default, setter(into))] - config_drive: Option>, - - #[builder(default, setter(into))] - created_at: Option>, - - #[builder(default, setter(into))] - deleted: Option>, - - #[builder(default, setter(into))] - description: Option>, - - #[builder(default, setter(into))] - display_description: Option>, - - #[builder(default, setter(into))] - display_name: Option>, - - #[builder(default, setter(into))] - flavor: Option>, - - #[builder(default, setter(into))] - host: Option>, - - #[builder(default, setter(into))] - hostname: Option>, - - #[builder(default, setter(into))] - image: Option>, - - #[builder(default, setter(into))] - image_ref: Option>, - - #[builder(default, setter(into))] - info_cache: Option>, - - #[builder(default, setter(into))] - ip: Option>, - - #[builder(default, setter(into))] - ip6: Option>, - - #[builder(default, setter(into))] - kernel_id: Option>, - - #[builder(default, setter(into))] - key_name: Option>, - - #[builder(default, setter(into))] - launch_index: Option>, - - #[builder(default, setter(into))] - launched_at: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - locked: Option>, - - #[builder(default, setter(into))] - locked_by: Option>, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - metadata: Option>, - - #[builder(default, setter(into))] - name: Option>, - - #[builder(default, setter(into))] - node: Option>, - - #[builder(default, setter(into))] - not_tags: Option>, - - #[builder(default, setter(into))] - not_tags_any: Option>, - - #[builder(default, setter(into))] - pci_devices: Option>, - - #[builder(default, setter(into))] - power_state: Option>, - - #[builder(default, setter(into))] - progress: Option>, - - #[builder(default, setter(into))] - project_id: Option>, - - #[builder(default, setter(into))] - ramdisk_id: Option>, - - #[builder(default, setter(into))] - reservation_id: Option>, - - #[builder(default, setter(into))] - root_device_name: Option>, - - #[builder(default, setter(into))] - security_groups: Option>, - - #[builder(default, setter(into))] - services: Option>, - - #[builder(default, setter(into))] - soft_deleted: Option>, - - #[builder(default, setter(into))] - sort_dir: Option>, - - #[builder(default, setter(into))] - sort_key: Option>, - - #[builder(default, setter(into))] - status: Option>, - - #[builder(default, setter(into))] - system_metadata: Option>, - - #[builder(default, setter(into))] - tags: Option>, - - #[builder(default, setter(into))] - tags_any: Option>, - - #[builder(default, setter(into))] - task_state: Option>, - - #[builder(default, setter(into))] - tenant_id: Option>, - - #[builder(default, setter(into))] - terminated_at: Option>, - - #[builder(default, setter(into))] - user_id: Option>, - - #[builder(default, setter(into))] - uuid: Option>, - - #[builder(default, setter(into))] - vm_state: 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> { - /// Add a single header to the Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "servers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("access_ip_v4", self.access_ip_v4.as_ref()); - params.push_opt("access_ip_v6", self.access_ip_v6.as_ref()); - params.push_opt("all_tenants", self.all_tenants.as_ref()); - params.push_opt("auto_disk_config", self.auto_disk_config.as_ref()); - params.push_opt("availability_zone", self.availability_zone.as_ref()); - params.push_opt("block_device_mapping", self.block_device_mapping.as_ref()); - params.push_opt("changes-before", self.changes_before.as_ref()); - params.push_opt("changes-since", self.changes_since.as_ref()); - params.push_opt("config_drive", self.config_drive.as_ref()); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("deleted", self.deleted.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("display_description", self.display_description.as_ref()); - params.push_opt("display_name", self.display_name.as_ref()); - params.push_opt("flavor", self.flavor.as_ref()); - params.push_opt("host", self.host.as_ref()); - params.push_opt("hostname", self.hostname.as_ref()); - params.push_opt("image", self.image.as_ref()); - params.push_opt("image_ref", self.image_ref.as_ref()); - params.push_opt("info_cache", self.info_cache.as_ref()); - params.push_opt("ip", self.ip.as_ref()); - params.push_opt("ip6", self.ip6.as_ref()); - params.push_opt("kernel_id", self.kernel_id.as_ref()); - params.push_opt("key_name", self.key_name.as_ref()); - params.push_opt("launch_index", self.launch_index.as_ref()); - params.push_opt("launched_at", self.launched_at.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("locked", self.locked.as_ref()); - params.push_opt("locked_by", self.locked_by.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("metadata", self.metadata.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("node", self.node.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("pci_devices", self.pci_devices.as_ref()); - params.push_opt("power_state", self.power_state.as_ref()); - params.push_opt("progress", self.progress.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("ramdisk_id", self.ramdisk_id.as_ref()); - params.push_opt("reservation_id", self.reservation_id.as_ref()); - params.push_opt("root_device_name", self.root_device_name.as_ref()); - params.push_opt("security_groups", self.security_groups.as_ref()); - params.push_opt("services", self.services.as_ref()); - params.push_opt("soft_deleted", self.soft_deleted.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("system_metadata", self.system_metadata.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("task_state", self.task_state.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - params.push_opt("terminated_at", self.terminated_at.as_ref()); - params.push_opt("user_id", self.user_id.as_ref()); - params.push_opt("uuid", self.uuid.as_ref()); - params.push_opt("vm_state", self.vm_state.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("servers".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "servers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/servers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "servers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/servers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "servers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/list_detailed.rs b/openstack_sdk/src/api/compute/v2/server/list_detailed.rs deleted file mode 100644 index 3bc25a7cd..000000000 --- a/openstack_sdk/src/api/compute/v2/server/list_detailed.rs +++ /dev/null @@ -1,424 +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`. - -//! For each server, shows server details including config drive, extended -//! status, and server usage information. -//! -//! The extended status information appears in the OS-EXT-STS:vm_state, -//! OS-EXT-STS:power_state, and OS-EXT-STS:task_state attributes. -//! -//! The server usage information appears in the OS-SRV-USG:launched_at and -//! OS-SRV-USG:terminated_at attributes. -//! -//! HostId is unique per account and is not globally unique. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - access_ip_v4: Option>, - - #[builder(default, setter(into))] - access_ip_v6: Option>, - - #[builder(default, setter(into))] - all_tenants: Option>, - - #[builder(default, setter(into))] - auto_disk_config: Option>, - - #[builder(default, setter(into))] - availability_zone: Option>, - - #[builder(default, setter(into))] - block_device_mapping: Option>, - - #[builder(default, setter(into))] - changes_before: Option>, - - #[builder(default, setter(into))] - changes_since: Option>, - - #[builder(default, setter(into))] - config_drive: Option>, - - #[builder(default, setter(into))] - created_at: Option>, - - #[builder(default, setter(into))] - deleted: Option>, - - #[builder(default, setter(into))] - description: Option>, - - #[builder(default, setter(into))] - display_description: Option>, - - #[builder(default, setter(into))] - display_name: Option>, - - #[builder(default, setter(into))] - flavor: Option>, - - #[builder(default, setter(into))] - host: Option>, - - #[builder(default, setter(into))] - hostname: Option>, - - #[builder(default, setter(into))] - image: Option>, - - #[builder(default, setter(into))] - image_ref: Option>, - - #[builder(default, setter(into))] - info_cache: Option>, - - #[builder(default, setter(into))] - ip: Option>, - - #[builder(default, setter(into))] - ip6: Option>, - - #[builder(default, setter(into))] - kernel_id: Option>, - - #[builder(default, setter(into))] - key_name: Option>, - - #[builder(default, setter(into))] - launch_index: Option>, - - #[builder(default, setter(into))] - launched_at: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - locked: Option>, - - #[builder(default, setter(into))] - locked_by: Option>, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - metadata: Option>, - - #[builder(default, setter(into))] - name: Option>, - - #[builder(default, setter(into))] - node: Option>, - - #[builder(default, setter(into))] - not_tags: Option>, - - #[builder(default, setter(into))] - not_tags_any: Option>, - - #[builder(default, setter(into))] - pci_devices: Option>, - - #[builder(default, setter(into))] - power_state: Option>, - - #[builder(default, setter(into))] - progress: Option>, - - #[builder(default, setter(into))] - project_id: Option>, - - #[builder(default, setter(into))] - ramdisk_id: Option>, - - #[builder(default, setter(into))] - reservation_id: Option>, - - #[builder(default, setter(into))] - root_device_name: Option>, - - #[builder(default, setter(into))] - security_groups: Option>, - - #[builder(default, setter(into))] - services: Option>, - - #[builder(default, setter(into))] - soft_deleted: Option>, - - #[builder(default, setter(into))] - sort_dir: Option>, - - #[builder(default, setter(into))] - sort_key: Option>, - - #[builder(default, setter(into))] - status: Option>, - - #[builder(default, setter(into))] - system_metadata: Option>, - - #[builder(default, setter(into))] - tags: Option>, - - #[builder(default, setter(into))] - tags_any: Option>, - - #[builder(default, setter(into))] - task_state: Option>, - - #[builder(default, setter(into))] - tenant_id: Option>, - - #[builder(default, setter(into))] - terminated_at: Option>, - - #[builder(default, setter(into))] - user_id: Option>, - - #[builder(default, setter(into))] - uuid: Option>, - - #[builder(default, setter(into))] - vm_state: 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> { - /// Add a single header to the Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "servers/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("access_ip_v4", self.access_ip_v4.as_ref()); - params.push_opt("access_ip_v6", self.access_ip_v6.as_ref()); - params.push_opt("all_tenants", self.all_tenants.as_ref()); - params.push_opt("auto_disk_config", self.auto_disk_config.as_ref()); - params.push_opt("availability_zone", self.availability_zone.as_ref()); - params.push_opt("block_device_mapping", self.block_device_mapping.as_ref()); - params.push_opt("changes-before", self.changes_before.as_ref()); - params.push_opt("changes-since", self.changes_since.as_ref()); - params.push_opt("config_drive", self.config_drive.as_ref()); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("deleted", self.deleted.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("display_description", self.display_description.as_ref()); - params.push_opt("display_name", self.display_name.as_ref()); - params.push_opt("flavor", self.flavor.as_ref()); - params.push_opt("host", self.host.as_ref()); - params.push_opt("hostname", self.hostname.as_ref()); - params.push_opt("image", self.image.as_ref()); - params.push_opt("image_ref", self.image_ref.as_ref()); - params.push_opt("info_cache", self.info_cache.as_ref()); - params.push_opt("ip", self.ip.as_ref()); - params.push_opt("ip6", self.ip6.as_ref()); - params.push_opt("kernel_id", self.kernel_id.as_ref()); - params.push_opt("key_name", self.key_name.as_ref()); - params.push_opt("launch_index", self.launch_index.as_ref()); - params.push_opt("launched_at", self.launched_at.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("locked", self.locked.as_ref()); - params.push_opt("locked_by", self.locked_by.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("metadata", self.metadata.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("node", self.node.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("pci_devices", self.pci_devices.as_ref()); - params.push_opt("power_state", self.power_state.as_ref()); - params.push_opt("progress", self.progress.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("ramdisk_id", self.ramdisk_id.as_ref()); - params.push_opt("reservation_id", self.reservation_id.as_ref()); - params.push_opt("root_device_name", self.root_device_name.as_ref()); - params.push_opt("security_groups", self.security_groups.as_ref()); - params.push_opt("services", self.services.as_ref()); - params.push_opt("soft_deleted", self.soft_deleted.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("system_metadata", self.system_metadata.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("task_state", self.task_state.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - params.push_opt("terminated_at", self.terminated_at.as_ref()); - params.push_opt("user_id", self.user_id.as_ref()); - params.push_opt("uuid", self.uuid.as_ref()); - params.push_opt("vm_state", self.vm_state.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("servers".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "servers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/servers/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "servers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/servers/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "servers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/metadata/create.rs b/openstack_sdk/src/api/compute/v2/server/metadata/create.rs deleted file mode 100644 index 9f37fe9c8..000000000 --- a/openstack_sdk/src/api/compute/v2/server/metadata/create.rs +++ /dev/null @@ -1,248 +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`. - -//! Create or update one or more metadata items for a server. -//! -//! Creates any metadata items that do not already exist in the server, -//! replaces exists metadata items that match keys. Does not modify items that -//! are not in the request. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Metadata key and value pairs. The maximum size for each metadata key - /// and value pair is 255 bytes. - #[builder(private, setter(into, name = "_metadata"))] - pub(crate) metadata: BTreeMap, Cow<'a, str>>, - - /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - server_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> { - /// Metadata key and value pairs. The maximum size for each metadata key - /// and value pair is 255 bytes. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "servers/{server_id}/metadata", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("metadata", serde_json::to_value(&self.metadata)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("metadata".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/servers/{server_id}/metadata", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/servers/{server_id}/metadata", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .metadata(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/metadata/delete.rs b/openstack_sdk/src/api/compute/v2/server/metadata/delete.rs deleted file mode 100644 index 4e269c6a0..000000000 --- a/openstack_sdk/src/api/compute/v2/server/metadata/delete.rs +++ /dev/null @@ -1,211 +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`. - -//! Deletes a metadata item, by key, from a server. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - server_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/metadata/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/metadata/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/metadata/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/metadata/get.rs b/openstack_sdk/src/api/compute/v2/server/metadata/get.rs deleted file mode 100644 index 9d9549752..000000000 --- a/openstack_sdk/src/api/compute/v2/server/metadata/get.rs +++ /dev/null @@ -1,213 +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`. - -//! Shows details for a metadata item, by key, for a server. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - server_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/metadata/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("meta".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "meta" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/metadata/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/metadata/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/metadata/list.rs b/openstack_sdk/src/api/compute/v2/server/metadata/list.rs deleted file mode 100644 index edf926888..000000000 --- a/openstack_sdk/src/api/compute/v2/server/metadata/list.rs +++ /dev/null @@ -1,201 +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`. - -//! Lists all metadata for a server. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - server_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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/metadata", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("metadata".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/metadata", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/metadata", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/metadata/replace.rs b/openstack_sdk/src/api/compute/v2/server/metadata/replace.rs deleted file mode 100644 index 89f04d17d..000000000 --- a/openstack_sdk/src/api/compute/v2/server/metadata/replace.rs +++ /dev/null @@ -1,248 +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`. - -//! Replaces one or more metadata items for a server. -//! -//! Creates any metadata items that do not already exist in the server. Removes -//! and completely replaces any metadata items that already exist in the server -//! with the metadata items in the request. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Metadata key and value pairs. The maximum size for each metadata key - /// and value pair is 255 bytes. - #[builder(private, setter(into, name = "_metadata"))] - pub(crate) metadata: BTreeMap, Cow<'a, str>>, - - /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - server_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> { - /// Metadata key and value pairs. The maximum size for each metadata key - /// and value pair is 255 bytes. - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.metadata - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "servers/{server_id}/metadata", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("metadata", serde_json::to_value(&self.metadata)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("metadata".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metadata" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/servers/{server_id}/metadata", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .metadata(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/servers/{server_id}/metadata", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metadata": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .metadata(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/metadata/set.rs b/openstack_sdk/src/api/compute/v2/server/metadata/set.rs deleted file mode 100644 index 8ad7f778e..000000000 --- a/openstack_sdk/src/api/compute/v2/server/metadata/set.rs +++ /dev/null @@ -1,253 +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`. - -//! Creates or replaces a metadata item, by key, for a server. -//! -//! Creates a metadata item that does not already exist in the server. Replaces -//! existing metadata items that match keys with the metadata item in the -//! request. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_meta"))] - pub(crate) meta: BTreeMap, Cow<'a, str>>, - - /// id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API - #[builder(default, setter(into))] - server_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> { - pub fn meta(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.meta - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "servers/{server_id}/metadata/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("meta", serde_json::to_value(&self.meta)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("meta".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "meta" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/servers/{server_id}/metadata/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .meta(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/servers/{server_id}/metadata/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "meta": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .meta(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/migration/delete.rs b/openstack_sdk/src/api/compute/v2/server/migration/delete.rs deleted file mode 100644 index 667efa097..000000000 --- a/openstack_sdk/src/api/compute/v2/server/migration/delete.rs +++ /dev/null @@ -1,235 +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`. - -//! Abort an in-progress live migration. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! **Preconditions** -//! -//! The server OS-EXT-STS:task_state value must be `migrating`. -//! -//! If the server is locked, you must have administrator privileges to force -//! the completion of the server migration. -//! -//! For microversions from 2.24 to 2.64 the migration status must be `running`, -//! for microversion 2.65 and greater, the migration status can also be -//! `queued` and `preparing`. -//! -//! **Asynchronous Postconditions** -//! -//! After you make this request, you typically must keep polling the server -//! status to determine whether the request succeeded. You may also monitor the -//! migration using: -//! -//! **Troubleshooting** -//! -//! If the server status remains `MIGRATING` for an inordinate amount of time, -//! the request may have failed. Ensure you meet the preconditions and run the -//! request again. If the request fails again, investigate the compute back -//! end. -//! -//! Normal response codes: 202 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/migrations/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/migrations/{id} API - #[builder(default, setter(into))] - server_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 Migration. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/migrations/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/migrations/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/migrations/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/migration/find.rs b/openstack_sdk/src/api/compute/v2/server/migration/find.rs deleted file mode 100644 index 9f0584107..000000000 --- a/openstack_sdk/src/api/compute/v2/server/migration/find.rs +++ /dev/null @@ -1,118 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use tracing::trace; - -use crate::api::find::Findable; -use crate::api::rest_endpoint_prelude::*; - -use crate::api::{ApiError, RestClient}; - -use crate::api::compute::v2::server::migration::{get as Get, list as List}; - -/// Find for server/migration by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[builder(default, setter(into))] - server_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 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<'a>; - fn get_ep(&self) -> Get::Request<'a> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.server_id(self.server_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<'a> { - let mut ep = List::Request::builder(); - ep.server_id(self.server_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().unwrap() - } - /// Locate server/migration in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // server/migration 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/compute/v2/server/migration/get.rs b/openstack_sdk/src/api/compute/v2/server/migration/get.rs deleted file mode 100644 index 698f4e62f..000000000 --- a/openstack_sdk/src/api/compute/v2/server/migration/get.rs +++ /dev/null @@ -1,213 +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 details for an in-progress live migration for a given server. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/migrations/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/migrations/{id} API - #[builder(default, setter(into))] - server_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 Migration. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/migrations/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("migration".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "migration" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/migrations/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "migration": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/migrations/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "migration": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/migration/list.rs b/openstack_sdk/src/api/compute/v2/server/migration/list.rs deleted file mode 100644 index b73b89cfe..000000000 --- a/openstack_sdk/src/api/compute/v2/server/migration/list.rs +++ /dev/null @@ -1,201 +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`. - -//! Lists in-progress live migrations for a given server. -//! -//! Policy defaults enable only users with the administrative role to perform -//! this operation. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/migrations/{id} API - #[builder(default, setter(into))] - server_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 Migration. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/migrations", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("migrations".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "migrations" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/migrations", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "migrations": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/migrations", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "migrations": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/security_group/list.rs b/openstack_sdk/src/api/compute/v2/server/security_group/list.rs deleted file mode 100644 index 75422622e..000000000 --- a/openstack_sdk/src/api/compute/v2/server/security_group/list.rs +++ /dev/null @@ -1,198 +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`. - -//! Lists security groups for a server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/os-security-groups - /// API - #[builder(default, setter(into))] - server_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 Security_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-security-groups", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("security_groups".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "security_groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-security-groups", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_groups": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-security-groups", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_groups": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/server_password/delete.rs b/openstack_sdk/src/api/compute/v2/server/server_password/delete.rs deleted file mode 100644 index 7fde1423f..000000000 --- a/openstack_sdk/src/api/compute/v2/server/server_password/delete.rs +++ /dev/null @@ -1,202 +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`. - -//! Clears the encrypted administrative password for a server, which removes it -//! from the database. -//! -//! This action does not actually change the instance server password. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/os-server-password - /// API - #[builder(default, setter(into))] - server_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 Server_Password. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-server-password", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/os-server-password", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/os-server-password", - server_id = "server_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() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/server_password/get.rs b/openstack_sdk/src/api/compute/v2/server/server_password/get.rs deleted file mode 100644 index 827b59f88..000000000 --- a/openstack_sdk/src/api/compute/v2/server/server_password/get.rs +++ /dev/null @@ -1,206 +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`. - -//! Shows the administrative password for a server. -//! -//! This operation calls the metadata service to query metadata information and -//! does not read password information from the server itself. -//! -//! The password saved in the metadata service is typically encrypted using the -//! public SSH key injected into this server, so the SSH private key is needed -//! to read the password. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of the server to perform this operation. Cloud providers can change these -//! permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/os-server-password - /// API - #[builder(default, setter(into))] - server_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 Server_Password. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-server-password", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-server-password", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-server-password", - server_id = "server_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() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/set_20.rs b/openstack_sdk/src/api/compute/v2/server/set_20.rs deleted file mode 100644 index 0aacdbae9..000000000 --- a/openstack_sdk/src/api/compute/v2/server/set_20.rs +++ /dev/null @@ -1,265 +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`. - -//! Updates the editable attributes of an existing server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum OsDcfDiskConfig { - #[serde(rename = "AUTO")] - Auto, - #[serde(rename = "MANUAL")] - Manual, -} - -/// A `server` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Server<'a> { - /// IPv4 address that should be used to access this server. - #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv4: Option>, - - /// IPv6 address that should be used to access this server. - #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv6: Option>, - - /// The server name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Controls how the API partitions the disk when you create, rebuild, or - /// resize servers. A server inherits the `OS-DCF:diskConfig` value from - /// the image from which it was created, and an image inherits the - /// `OS-DCF:diskConfig` value from the server from which it was created. To - /// override the inherited setting, you can include this attribute in the - /// request body of a server create, rebuild, or resize request. If the - /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a - /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. - /// A valid value is: - /// - /// - `AUTO`. The API builds the server with a single partition the size of - /// the target flavor disk. The API automatically adjusts the file system - /// to fit the entire partition. - /// - `MANUAL`. The API builds the server by using whatever partition - /// scheme and file system is in the source image. If the target flavor - /// disk is larger, the API does not partition the remaining disk space. - #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) os_dcf_disk_config: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `server` object. - #[builder(setter(into))] - pub(crate) server: Server<'a>, - - /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("servers/{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("server", serde_json::to_value(&self.server)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .server(ServerBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .server(ServerBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "server" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/servers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server(ServerBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/servers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server(ServerBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/set_21.rs b/openstack_sdk/src/api/compute/v2/server/set_21.rs deleted file mode 100644 index 49ecaae7a..000000000 --- a/openstack_sdk/src/api/compute/v2/server/set_21.rs +++ /dev/null @@ -1,265 +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`. - -//! Updates the editable attributes of an existing server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum OsDcfDiskConfig { - #[serde(rename = "AUTO")] - Auto, - #[serde(rename = "MANUAL")] - Manual, -} - -/// A `server` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Server<'a> { - /// IPv4 address that should be used to access this server. - #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv4: Option>, - - /// IPv6 address that should be used to access this server. - #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_ipv6: Option>, - - /// The server name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Controls how the API partitions the disk when you create, rebuild, or - /// resize servers. A server inherits the `OS-DCF:diskConfig` value from - /// the image from which it was created, and an image inherits the - /// `OS-DCF:diskConfig` value from the server from which it was created. To - /// override the inherited setting, you can include this attribute in the - /// request body of a server create, rebuild, or resize request. If the - /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a - /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. - /// A valid value is: - /// - /// - `AUTO`. The API builds the server with a single partition the size of - /// the target flavor disk. The API automatically adjusts the file system - /// to fit the entire partition. - /// - `MANUAL`. The API builds the server by using whatever partition - /// scheme and file system is in the source image. If the target flavor - /// disk is larger, the API does not partition the remaining disk space. - #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) os_dcf_disk_config: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `server` object. - #[builder(setter(into))] - pub(crate) server: Server<'a>, - - /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Server. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("servers/{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("server", serde_json::to_value(&self.server)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .server(ServerBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .server(ServerBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "server" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/servers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server(ServerBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/servers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server(ServerBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/share/delete.rs b/openstack_sdk/src/api/compute/v2/server/share/delete.rs deleted file mode 100644 index 66052c13c..000000000 --- a/openstack_sdk/src/api/compute/v2/server/share/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Detach a share from an instance. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), forbidden(403), itemNotFound(404), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/shares/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/shares/{id} API - #[builder(default, setter(into))] - server_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 Share. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/shares/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/shares/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/shares/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/share/get.rs b/openstack_sdk/src/api/compute/v2/server/share/get.rs deleted file mode 100644 index fdedcda4b..000000000 --- a/openstack_sdk/src/api/compute/v2/server/share/get.rs +++ /dev/null @@ -1,209 +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 a detail of a share attachment. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/shares/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/shares/{id} API - #[builder(default, setter(into))] - server_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 Share. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/shares/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("share".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "share" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/shares/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "share": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/shares/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "share": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/share/list.rs b/openstack_sdk/src/api/compute/v2/server/share/list.rs deleted file mode 100644 index 2b07b5827..000000000 --- a/openstack_sdk/src/api/compute/v2/server/share/list.rs +++ /dev/null @@ -1,197 +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`. - -//! List share attachments for an instance. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badrequest(400), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/shares/{id} API - #[builder(default, setter(into))] - server_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 Share. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/shares", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("shares".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "shares" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/shares", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "shares": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/shares", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "shares": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/tag/delete.rs b/openstack_sdk/src/api/compute/v2/server/tag/delete.rs deleted file mode 100644 index 4023f1094..000000000 --- a/openstack_sdk/src/api/compute/v2/server/tag/delete.rs +++ /dev/null @@ -1,206 +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`. - -//! Deletes a single tag from the specified server. -//! -//! Normal response codes: 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - server_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/tags/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/tags/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/tags/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/tag/delete_all.rs b/openstack_sdk/src/api/compute/v2/server/tag/delete_all.rs deleted file mode 100644 index 57cb03f9a..000000000 --- a/openstack_sdk/src/api/compute/v2/server/tag/delete_all.rs +++ /dev/null @@ -1,194 +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`. - -//! Deletes all tags from the specified server. -//! -//! Normal response codes: 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - server_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/tags", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/tags", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/tags", - server_id = "server_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() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/tag/get.rs b/openstack_sdk/src/api/compute/v2/server/tag/get.rs deleted file mode 100644 index 0519e2245..000000000 --- a/openstack_sdk/src/api/compute/v2/server/tag/get.rs +++ /dev/null @@ -1,207 +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`. - -//! Checks tag existence on the server. If tag exists response with 204 status -//! code will be returned. Otherwise returns 404. -//! -//! Normal response codes: 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - server_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/tags/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/tags/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/tags/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/tag/list.rs b/openstack_sdk/src/api/compute/v2/server/tag/list.rs deleted file mode 100644 index c62249fe2..000000000 --- a/openstack_sdk/src/api/compute/v2/server/tag/list.rs +++ /dev/null @@ -1,197 +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`. - -//! Lists all tags for a server. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - server_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/tags", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/tags", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/tags", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/tag/set.rs b/openstack_sdk/src/api/compute/v2/server/tag/set.rs deleted file mode 100644 index d3bc5f098..000000000 --- a/openstack_sdk/src/api/compute/v2/server/tag/set.rs +++ /dev/null @@ -1,210 +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`. - -//! Adds a single tag to the server if server has no specified tag. Response -//! code in this case is 201. -//! -//! If the server has specified tag just returns 204. -//! -//! Normal response codes: 201, 204 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API - #[builder(default, setter(into))] - server_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "servers/{server_id}/tags/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/servers/{server_id}/tags/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/servers/{server_id}/tags/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/topology/list.rs b/openstack_sdk/src/api/compute/v2/server/topology/list.rs deleted file mode 100644 index 670253777..000000000 --- a/openstack_sdk/src/api/compute/v2/server/topology/list.rs +++ /dev/null @@ -1,201 +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`. - -//! Shows NUMA topology information for a server. -//! -//! Policy defaults enable only users with the administrative role or the -//! owners of the server to perform this operation. Cloud providers can change -//! these permissions through the `policy.yaml` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), notfound(404), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/topology API - #[builder(default, setter(into))] - server_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 Topology. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/topology", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("nodes".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "nodes" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/topology", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "nodes": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/topology", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "nodes": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/virtual_interface/get.rs b/openstack_sdk/src/api/compute/v2/server/virtual_interface/get.rs deleted file mode 100644 index a6b06176f..000000000 --- a/openstack_sdk/src/api/compute/v2/server/virtual_interface/get.rs +++ /dev/null @@ -1,184 +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 - -//! Lists the virtual interfaces for an instance. -//! -//! Policy defaults enable only users with the administrative role or the owner -//! of -//! the server to perform this operation. Change these permissions through the -//! `policy.json` file. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), gone(410) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use crate::api::rest_endpoint_prelude::*; -use serde::Serialize; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// server_id parameter for /v2.1/servers/{server_id}/topology API - #[builder(default, setter(into))] - server_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 Virtual_Interface. - 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!( - "v2.1/servers/{server_id}/os-virtual-interfaces", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::api::{self, Query, RawQuery}; - use crate::test::client::MockServerClient; - use crate::types::ServiceType; - use http::{HeaderName, HeaderValue}; - use serde::Deserialize; - use serde::Serialize; - use serde_json::json; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[test] - fn endpoint() { - let client = MockServerClient::new(); - let mock = client.server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/v2.1/servers/{server_id}/os-virtual-interfaces", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[test] - fn endpoint_headers() { - let client = MockServerClient::new(); - let mock = client.server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/v2.1/servers/{server_id}/os-virtual-interfaces", - server_id = "server_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() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .iter() - .cloned(), - ) - .header("not_foo", "not_bar") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_20.rs b/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_20.rs deleted file mode 100644 index 2967e21da..000000000 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_20.rs +++ /dev/null @@ -1,273 +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`. - -//! Attach a volume to an instance. -//! -//! Normal response codes: 200 (microversions 2.0 - 2.100), 202 (microversion -//! 2.101 - ) -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A dictionary representation of a volume attachment containing the fields -/// `device` and `volumeId`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct VolumeAttachment<'a> { - /// Name of the device such as, `/dev/vdb`. Omit or set this parameter to - /// null for auto-assignment, if supported. If you specify this parameter, - /// the device must not exist in the guest operating system. Note that as - /// of the 12.0.0 Liberty release, the Nova libvirt driver no longer honors - /// a user-supplied device name. This is the same behavior as if the device - /// name parameter is not supplied on the request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device: Option>>, - - /// The UUID of the volume to attach. - #[serde(rename = "volumeId")] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary representation of a volume attachment containing the - /// fields `device` and `volumeId`. - #[builder(setter(into))] - pub(crate) volume_attachment: VolumeAttachment<'a>, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API - #[builder(default, setter(into))] - server_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 Volume_Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "servers/{server_id}/os-volume_attachments", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "volumeAttachment", - serde_json::to_value(&self.volume_attachment)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("volumeAttachment".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "volumeAttachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/servers/{server_id}/os-volume_attachments", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/servers/{server_id}/os-volume_attachments", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_249.rs b/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_249.rs deleted file mode 100644 index 2a1878ed6..000000000 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_249.rs +++ /dev/null @@ -1,288 +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`. - -//! Attach a volume to an instance. -//! -//! Normal response codes: 200 (microversions 2.0 - 2.100), 202 (microversion -//! 2.101 - ) -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A dictionary representation of a volume attachment containing the fields -/// `device` and `volumeId`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct VolumeAttachment<'a> { - /// Name of the device such as, `/dev/vdb`. Omit or set this parameter to - /// null for auto-assignment, if supported. If you specify this parameter, - /// the device must not exist in the guest operating system. Note that as - /// of the 12.0.0 Liberty release, the Nova libvirt driver no longer honors - /// a user-supplied device name. This is the same behavior as if the device - /// name parameter is not supplied on the request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device: Option>>, - - /// A device role tag that can be applied to a volume when attaching it to - /// the VM. The guest OS of a server that has devices tagged in this manner - /// can access hardware metadata about the tagged devices from the metadata - /// API and on the config drive, if enabled. - /// - /// Note - /// - /// Tagged volume attachment is not supported for shelved-offloaded - /// instances. - /// - /// **New in version 2.49** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tag: Option>, - - /// The UUID of the volume to attach. - #[serde(rename = "volumeId")] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary representation of a volume attachment containing the - /// fields `device` and `volumeId`. - #[builder(setter(into))] - pub(crate) volume_attachment: VolumeAttachment<'a>, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API - #[builder(default, setter(into))] - server_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 Volume_Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "servers/{server_id}/os-volume_attachments", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "volumeAttachment", - serde_json::to_value(&self.volume_attachment)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("volumeAttachment".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(2, 49)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "volumeAttachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/servers/{server_id}/os-volume_attachments", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/servers/{server_id}/os-volume_attachments", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/delete.rs b/openstack_sdk/src/api/compute/v2/server/volume_attachment/delete.rs deleted file mode 100644 index edc712eae..000000000 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/delete.rs +++ /dev/null @@ -1,209 +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`. - -//! Detach a volume from an instance. -//! -//! Normal response codes: 202 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/os-volume_attachments/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API - #[builder(default, setter(into))] - server_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 Volume_Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-volume_attachments/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/servers/{server_id}/os-volume_attachments/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/servers/{server_id}/os-volume_attachments/{id}", - id = "id", - server_id = "server_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") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/find.rs b/openstack_sdk/src/api/compute/v2/server/volume_attachment/find.rs deleted file mode 100644 index 7db0dd738..000000000 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/find.rs +++ /dev/null @@ -1,118 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use tracing::trace; - -use crate::api::find::Findable; -use crate::api::rest_endpoint_prelude::*; - -use crate::api::{ApiError, RestClient}; - -use crate::api::compute::v2::server::volume_attachment::{get as Get, list as List}; - -/// Find for server/volume_attachment by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[builder(default, setter(into))] - server_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 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<'a>; - fn get_ep(&self) -> Get::Request<'a> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.server_id(self.server_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<'a> { - let mut ep = List::Request::builder(); - ep.server_id(self.server_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().unwrap() - } - /// Locate server/volume_attachment in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // server/volume_attachment 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/compute/v2/server/volume_attachment/get.rs b/openstack_sdk/src/api/compute/v2/server/volume_attachment/get.rs deleted file mode 100644 index 889d5511e..000000000 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/get.rs +++ /dev/null @@ -1,211 +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 a detail of a volume attachment. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/servers/{server_id}/os-volume_attachments/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API - #[builder(default, setter(into))] - server_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 Volume_Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-volume_attachments/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("volumeAttachment".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volumeAttachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-volume_attachments/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-volume_attachments/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/list.rs b/openstack_sdk/src/api/compute/v2/server/volume_attachment/list.rs deleted file mode 100644 index d8902d3cf..000000000 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/list.rs +++ /dev/null @@ -1,210 +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`. - -//! List volume attachments for an instance. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default)] - limit: Option, - - #[builder(default)] - offset: Option, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API - #[builder(default, setter(into))] - server_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 Volume_Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "servers/{server_id}/os-volume_attachments", - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("offset", self.offset); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("volumeAttachments".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "volumeAttachments" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/servers/{server_id}/os-volume_attachments", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachments": {} })); - }); - - let endpoint = Request::builder().server_id("server_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/servers/{server_id}/os-volume_attachments", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachments": {} })); - }); - - let endpoint = Request::builder() - .server_id("server_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/set_20.rs b/openstack_sdk/src/api/compute/v2/server/volume_attachment/set_20.rs deleted file mode 100644 index d20f3baa2..000000000 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/set_20.rs +++ /dev/null @@ -1,279 +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`. - -//! Update a volume attachment. -//! -//! Policy default role is ‘rule:admin_or_owner’, its scope is [project], which -//! allow project members or admins to change the fields of an attached volume -//! of a server. Cloud providers can change these permissions through the -//! `policy.yaml` file. -//! -//! Normal response codes: 202 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A dictionary representation of a volume attachment containing the field -/// `volumeId` which is the UUID of the replacement volume, and other fields to -/// update in the attachment. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct VolumeAttachment<'a> { - /// The UUID of the attached volume. - #[serde(rename = "volumeId")] - #[builder(setter(into))] - pub(crate) volume_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary representation of a volume attachment containing the field - /// `volumeId` which is the UUID of the replacement volume, and other - /// fields to update in the attachment. - #[builder(setter(into))] - pub(crate) volume_attachment: VolumeAttachment<'a>, - - /// id parameter for /v2.1/servers/{server_id}/os-volume_attachments/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// server_id parameter for - /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API - #[builder(default, setter(into))] - server_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 Volume_Attachment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "servers/{server_id}/os-volume_attachments/{id}", - id = self.id.as_ref(), - server_id = self.server_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "volumeAttachment", - serde_json::to_value(&self.volume_attachment)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("volumeAttachment".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "volumeAttachment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/servers/{server_id}/os-volume_attachments/{id}", - id = "id", - server_id = "server_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/servers/{server_id}/os-volume_attachments/{id}", - id = "id", - server_id = "server_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "volumeAttachment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .server_id("server_id") - .volume_attachment( - VolumeAttachmentBuilder::default() - .volume_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server_external_event/create_20.rs b/openstack_sdk/src/api/compute/v2/server_external_event/create_20.rs deleted file mode 100644 index 0ce481c51..000000000 --- a/openstack_sdk/src/api/compute/v2/server_external_event/create_20.rs +++ /dev/null @@ -1,299 +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`. - -//! Creates one or more external events, which the API dispatches to the host a -//! server is assigned to. If the server is not currently assigned to a host -//! the event will not be delivered. -//! -//! You will receive back the list of events that you submitted, with an -//! updated `code` and `status` indicating their level of success. -//! -//! Normal response codes: 200, 207 -//! -//! A 200 will be returned if all events succeeded, 207 will be returned if any -//! events could not be processed. The `code` attribute for the event will -//! explain further what went wrong. -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Name { - #[serde(rename = "network-changed")] - NetworkChanged, - #[serde(rename = "network-vif-deleted")] - NetworkVifDeleted, - #[serde(rename = "network-vif-plugged")] - NetworkVifPlugged, - #[serde(rename = "network-vif-unplugged")] - NetworkVifUnplugged, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Status { - #[serde(rename = "completed")] - Completed, - #[serde(rename = "failed")] - Failed, - #[serde(rename = "in-progress")] - InProgress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Events<'a> { - /// The event name. A valid value is: - /// - /// - `network-changed` - /// - `network-vif-plugged` - /// - `network-vif-unplugged` - /// - `network-vif-deleted` - /// - `volume-extended` (since microversion `2.51`) - /// - `power-update` (since microversion `2.76`) - /// - `accelerator-request-bound` (since microversion `2.82`) - /// - `volume-reimaged` (since microversion `2.93`) - #[serde()] - #[builder()] - pub(crate) name: Name, - - /// The UUID of the server instance to which the API dispatches the event. - /// You must assign this instance to a host. Otherwise, this call does not - /// dispatch the event to the instance. - #[serde()] - #[builder(setter(into))] - pub(crate) server_uuid: Cow<'a, str>, - - /// The event status. A valid value is `failed`, `completed`, or - /// `in-progress`. Default is `completed`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) status: Option, - - /// A string value that identifies the event. Certain types of events - /// require specific tags: - /// - /// - For the `accelerator-request-bound` event, the tag must be the - /// accelerator request UUID. - /// - For the `power-update` event the tag must be either be `POWER_ON` or - /// `POWER_OFF`. - /// - For the `volume-extended` event the tag must be the volume id. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tag: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// List of external events to process. - #[builder(setter(into))] - pub(crate) events: Vec>, - - #[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 Server_External_Event. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-server-external-events".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("events", serde_json::to_value(&self.events)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .events(Vec::from([EventsBuilder::default() - .name(Name::NetworkChanged) - .server_uuid("foo") - .build() - .unwrap()])) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .events(Vec::from([EventsBuilder::default() - .name(Name::NetworkChanged) - .server_uuid("foo") - .build() - .unwrap()])) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-server-external-events".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .events(Vec::from([EventsBuilder::default() - .name(Name::NetworkChanged) - .server_uuid("foo") - .build() - .unwrap()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-server-external-events".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() - .events(Vec::from([EventsBuilder::default() - .name(Name::NetworkChanged) - .server_uuid("foo") - .build() - .unwrap()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server_group/create_20.rs b/openstack_sdk/src/api/compute/v2/server_group/create_20.rs deleted file mode 100644 index 080dbd8ac..000000000 --- a/openstack_sdk/src/api/compute/v2/server_group/create_20.rs +++ /dev/null @@ -1,274 +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`. - -//! Creates a server group. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Policies { - #[serde(rename = "affinity")] - Affinity, - #[serde(rename = "anti-affinity")] - AntiAffinity, -} - -/// The server group object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ServerGroup<'a> { - /// The name of the server group. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// A list of exactly one policy name to associate with the server group. - /// The current valid policy names are: - /// - /// - `anti-affinity` - servers in this group must be scheduled to - /// different hosts. - /// - `affinity` - servers in this group must be scheduled to the same - /// host. - /// - `soft-anti-affinity` - servers in this group should be scheduled to - /// different hosts if possible, but if not possible then they should - /// still be scheduled instead of resulting in a build failure. This - /// policy was added in microversion 2.15. - /// - `soft-affinity` - servers in this group should be scheduled to the - /// same host if possible, but if not possible then they should still be - /// scheduled instead of resulting in a build failure. This policy was - /// added in microversion 2.15. - /// - /// **Available until version 2.63** - #[serde()] - #[builder(setter(into))] - pub(crate) policies: Vec, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The server group object. - #[builder(setter(into))] - pub(crate) server_group: ServerGroup<'a>, - - #[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 Server_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-server-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("server_group", serde_json::to_value(&self.server_group)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .server_group( - ServerGroupBuilder::default() - .name("foo") - .policies(Vec::from([Policies::Affinity])) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .server_group( - ServerGroupBuilder::default() - .name("foo") - .policies(Vec::from([Policies::Affinity])) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "server_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-server-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server_group": {} })); - }); - - let endpoint = Request::builder() - .server_group( - ServerGroupBuilder::default() - .name("foo") - .policies(Vec::from([Policies::Affinity])) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/os-server-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server_group": {} })); - }); - - let endpoint = Request::builder() - .server_group( - ServerGroupBuilder::default() - .name("foo") - .policies(Vec::from([Policies::Affinity])) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server_group/delete.rs b/openstack_sdk/src/api/compute/v2/server_group/delete.rs deleted file mode 100644 index 1256165eb..000000000 --- a/openstack_sdk/src/api/compute/v2/server_group/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a server group. -//! -//! Normal response codes: 204 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-server-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Server_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-server-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-server-groups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-server-groups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server_group/find.rs b/openstack_sdk/src/api/compute/v2/server_group/find.rs deleted file mode 100644 index 67d538bac..000000000 --- a/openstack_sdk/src/api/compute/v2/server_group/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::compute::v2::server_group::{get as Get, list as List}; - -/// Find for server_group 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate server_group in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // server_group 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") - && let Some(name) = name_as_val.as_str() - && 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/compute/v2/server_group/get.rs b/openstack_sdk/src/api/compute/v2/server_group/get.rs deleted file mode 100644 index 5b65ca2cd..000000000 --- a/openstack_sdk/src/api/compute/v2/server_group/get.rs +++ /dev/null @@ -1,188 +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`. - -//! Shows details for a server group. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-server-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Server_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-server-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server_group".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "server_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-server-groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server_group": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-server-groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/server_group/list.rs b/openstack_sdk/src/api/compute/v2/server_group/list.rs deleted file mode 100644 index 96644a8a2..000000000 --- a/openstack_sdk/src/api/compute/v2/server_group/list.rs +++ /dev/null @@ -1,202 +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`. - -//! Lists all server groups for the tenant. -//! -//! Administrative users can use the `all_projects` query parameter to list all -//! server groups for all projects. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - all_projects: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default)] - offset: 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> { - /// Add a single header to the Server_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-server-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("all_projects", self.all_projects.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("offset", self.offset); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("server_groups".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(2, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "server_groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-server-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server_groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-server-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "server_groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/service/delete.rs b/openstack_sdk/src/api/compute/v2/service/delete.rs deleted file mode 100644 index ee3f23d23..000000000 --- a/openstack_sdk/src/api/compute/v2/service/delete.rs +++ /dev/null @@ -1,197 +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`. - -//! Deletes a service. If it’s a `nova-compute` service, then the corresponding -//! host will be removed from all the host aggregates as well. -//! -//! Attempts to delete a `nova-compute` service which is still hosting -//! instances will result in a 409 HTTPConflict response. The instances will -//! need to be migrated or deleted before a compute service can be deleted. -//! -//! Similarly, attempts to delete a `nova-compute` service which is involved in -//! in-progress migrations will result in a 409 HTTPConflict response. The -//! migrations will need to be completed, for example confirming or reverting a -//! resize, or the instances will need to be deleted before the compute service -//! can be deleted. -//! -//! Normal response codes: 204 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/os-services/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-services/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-services/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/os-services/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/service/list.rs b/openstack_sdk/src/api/compute/v2/service/list.rs deleted file mode 100644 index 0a3466d8b..000000000 --- a/openstack_sdk/src/api/compute/v2/service/list.rs +++ /dev/null @@ -1,195 +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`. - -//! Lists all running Compute services. -//! -//! Provides details why any services were disabled. -//! -//! Normal response codes: 200 -//! -//! Error response codes: unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - binary: Option>, - - #[builder(default, setter(into))] - host: 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> { - /// Add a single header to the Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-services".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("binary", self.binary.as_ref()); - params.push_opt("host", self.host.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("services".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "services" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-services".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "services": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-services".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "services": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/service/set_20.rs b/openstack_sdk/src/api/compute/v2/service/set_20.rs deleted file mode 100644 index 725af5dba..000000000 --- a/openstack_sdk/src/api/compute/v2/service/set_20.rs +++ /dev/null @@ -1,236 +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`. - -//! Update a compute service to enable or disable scheduling, including -//! recording a reason why a compute service was disabled from scheduling. Set -//! or unset the `forced_down` flag for the service. This operation is only -//! allowed on services whose `binary` is `nova-compute`. -//! -//! This API is available starting with microversion 2.53. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), -//! itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) binary: Cow<'a, str>, - - /// The reason for disabling a service. The minimum length is 1 and the - /// maximum length is 255. This may only be requested with - /// `status=disabled`. - #[builder(default, setter(into))] - pub(crate) disabled_reason: Option>, - - #[builder(setter(into))] - pub(crate) host: Cow<'a, str>, - - /// id parameter for /v2.1/os-services/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("os-services/{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("binary", serde_json::to_value(&self.binary)?); - if let Some(val) = &self.disabled_reason { - params.push("disabled_reason", serde_json::to_value(val)?); - } - params.push("host", serde_json::to_value(&self.host)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("service".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .binary("foo") - .host("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .binary("foo") - .host("foo") - .build() - .unwrap() - .response_key() - .unwrap(), - "service" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-services/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .binary("foo") - .host("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/os-services/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .binary("foo") - .host("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/simple_tenant_usage/get.rs b/openstack_sdk/src/api/compute/v2/simple_tenant_usage/get.rs deleted file mode 100644 index 9eecb5b84..000000000 --- a/openstack_sdk/src/api/compute/v2/simple_tenant_usage/get.rs +++ /dev/null @@ -1,205 +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`. - -//! Shows usage statistics for a tenant. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - end: Option>, - - /// id parameter for /v2.1/os-simple-tenant-usage/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - start: 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> { - /// Add a single header to the Simple_Tenant_Usage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("os-simple-tenant-usage/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("end", self.end.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("start", self.start.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-simple-tenant-usage/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/os-simple-tenant-usage/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/simple_tenant_usage/list.rs b/openstack_sdk/src/api/compute/v2/simple_tenant_usage/list.rs deleted file mode 100644 index c988dffb6..000000000 --- a/openstack_sdk/src/api/compute/v2/simple_tenant_usage/list.rs +++ /dev/null @@ -1,204 +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`. - -//! Lists usage statistics for all tenants. -//! -//! Normal response codes: 200 -//! -//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - detailed: Option>, - - #[builder(default, setter(into))] - end: Option>, - - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - start: 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> { - /// Add a single header to the Simple_Tenant_Usage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "os-simple-tenant-usage".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("detailed", self.detailed.as_ref()); - params.push_opt("end", self.end.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("start", self.start.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - 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, 1)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-simple-tenant-usage".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/os-simple-tenant-usage".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/compute/v2/version/get.rs b/openstack_sdk/src/api/compute/v2/version/get.rs deleted file mode 100644 index cf62eac0e..000000000 --- a/openstack_sdk/src/api/compute/v2/version/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.1/versions/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Version. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("versions/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("version".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(2, 1)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Compute - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "version" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/versions/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "version": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/versions/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "version": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/container_infrastructure_management.rs b/openstack_sdk/src/api/container_infrastructure_management.rs index 38fa6b6c5..e4c374ec5 100644 --- a/openstack_sdk/src/api/container_infrastructure_management.rs +++ b/openstack_sdk/src/api/container_infrastructure_management.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Container Infrastructure Management service (Magnum) bindings -pub mod v1; +//! # Container Infrastructure Management service (Magnum) bindings +pub use openstack_sdk_container_infrastructure_management::*; 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 deleted file mode 100644 index 272af729d..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/create.rs +++ /dev/null @@ -1,255 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Certificate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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.ca_cert_type { - params.push("ca_cert_type", serde_json::to_value(val)?); - } - if let Some(val) = &self.cluster_uuid { - params.push("cluster_uuid", 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.csr { - params.push("csr", serde_json::to_value(val)?); - } - if let Some(val) = &self.links { - params.push("links", serde_json::to_value(val)?); - } - if let Some(val) = &self.pem { - params.push("pem", 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 06f9b7aac..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/certificate/get.rs +++ /dev/null @@ -1,182 +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 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Certificate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/resize/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize/create.rs deleted file mode 100644 index 47f18be3b..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize/create.rs +++ /dev/null @@ -1,221 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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(setter(into))] - 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<'a> RequestBuilder<'a> { - /// Add a single header to the Resize. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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(); - - if let Some(val) = &self.created_at { - params.push("created_at", serde_json::to_value(val)?); - } - params.push("node_count", serde_json::to_value(self.node_count)?); - if let Some(val) = &self.nodegroup { - params.push("nodegroup", serde_json::to_value(val)?); - } - if let Some(val) = &self.nodes_to_remove { - params.push("nodes_to_remove", 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade/create.rs deleted file mode 100644 index bd22c7e0a..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade/create.rs +++ /dev/null @@ -1,211 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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, setter(into))] - 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<'a> RequestBuilder<'a> { - /// Add a single header to the Upgrade. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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.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.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.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 60cc7c5b7..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/create.rs +++ /dev/null @@ -1,659 +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`. - -//! Create new cluster based on cluster template. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 HealthStatus { - #[serde(rename = "HEALTHY")] - Healthy, - #[serde(rename = "UNHEALTHY")] - Unhealthy, - #[serde(rename = "UNKNOWN")] - Unknown, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum Labels<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LabelsAdded<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LabelsOverridden<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LabelsSkipped<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -/// 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) 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, setter(into))] - 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, setter(into))] - pub(crate) docker_volume_size: Option, - - #[builder(default, private, setter(into, 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(into, 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(into, name = "_labels"))] - pub(crate) labels: Option, Labels<'a>>>, - - #[builder(default, private, setter(into, name = "_labels_added"))] - pub(crate) labels_added: Option, LabelsAdded<'a>>>, - - #[builder(default, private, setter(into, name = "_labels_overridden"))] - pub(crate) labels_overridden: Option, LabelsOverridden<'a>>>, - - #[builder(default, private, setter(into, name = "_labels_skipped"))] - pub(crate) labels_skipped: Option, LabelsSkipped<'a>>>, - - #[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, setter(into))] - 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, setter(into))] - 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> { - 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 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 - } - - /// 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 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_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_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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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.api_address { - params.push("api_address", serde_json::to_value(val)?); - } - params.push( - "cluster_template_id", - serde_json::to_value(&self.cluster_template_id)?, - ); - 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.create_timeout { - params.push("create_timeout", 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.discovery_url { - params.push("discovery_url", 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.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.flavor_id { - params.push("flavor_id", 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.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.keypair { - params.push("keypair", serde_json::to_value(val)?); - } - if let Some(val) = &self.labels { - params.push("labels", 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_overridden { - params.push("labels_overridden", 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.links { - params.push("links", 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.master_count { - params.push("master_count", 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.master_lb_enabled { - params.push("master_lb_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.name { - params.push("name", 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.project_id { - params.push("project_id", 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.updated_at { - params.push("updated_at", 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.uuid { - params.push("uuid", 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 9d66fb445..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a cluster. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Cluster. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 3c32b9c5b..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/get.rs +++ /dev/null @@ -1,181 +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 all information of a cluster in Magnum. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Cluster. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 3a0e03d6f..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/list.rs +++ /dev/null @@ -1,177 +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`. - -//! List all clusters in Magnum. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/create.rs deleted file mode 100644 index 20990a4cb..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/create.rs +++ /dev/null @@ -1,498 +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`. - -//! 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 openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum Labels<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LabelsAdded<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LabelsOverridden<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LabelsSkipped<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -/// 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, setter(into))] - pub(crate) docker_volume_size: Option, - - #[builder(default, setter(into))] - pub(crate) flavor_id: Option>, - - #[builder(default, setter(into))] - 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(into, name = "_labels"))] - pub(crate) labels: Option, Labels<'a>>>, - - #[builder(default, private, setter(into, name = "_labels_added"))] - pub(crate) labels_added: Option, LabelsAdded<'a>>>, - - #[builder(default, private, setter(into, name = "_labels_overridden"))] - pub(crate) labels_overridden: Option, LabelsOverridden<'a>>>, - - #[builder(default, private, setter(into, name = "_labels_skipped"))] - pub(crate) labels_skipped: Option, LabelsSkipped<'a>>>, - - #[builder(default, setter(into))] - pub(crate) links: Option>>, - - #[builder(default, setter(into))] - pub(crate) max_node_count: Option, - - #[builder(default, setter(into))] - pub(crate) merge_labels: Option>, - - #[builder(default, setter(into))] - 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, setter(into))] - 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_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_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_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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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.cluster_id { - params.push("cluster_id", 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.docker_volume_size { - params.push("docker_volume_size", 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.id { - params.push("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.is_default { - params.push("is_default", serde_json::to_value(val)?); - } - if let Some(val) = &self.labels { - params.push("labels", 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_overridden { - params.push("labels_overridden", 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.links { - params.push("links", 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.merge_labels { - params.push("merge_labels", 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.name { - params.push("name", 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.project_id { - params.push("project_id", serde_json::to_value(val)?); - } - if let Some(val) = &self.role { - params.push("role", 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.updated_at { - params.push("updated_at", serde_json::to_value(val)?); - } - if let Some(val) = &self.uuid { - params.push("uuid", serde_json::to_value(val)?); - } - if let Some(val) = &self.version { - params.push("version", 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 8d7555878..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Nodegroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index b27c6c347..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/delete_all.rs +++ /dev/null @@ -1,177 +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`. - -//! 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 2f101558c..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/find.rs +++ /dev/null @@ -1,117 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result> { - 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().map_err(ApiError::endpoint_builder) - } - /// 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") - && let Some(name) = name_as_val.as_str() - && 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 deleted file mode 100644 index 6f7d3ae24..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/get.rs +++ /dev/null @@ -1,184 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Nodegroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 1bc2a893c..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/list.rs +++ /dev/null @@ -1,184 +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`. - -//! 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 76fd9d478..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup/set.rs +++ /dev/null @@ -1,243 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Nodegroup. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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("op", serde_json::to_value(&self.op)?); - params.push("path", serde_json::to_value(&self.path)?); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .op(Op::Add) - .path("foo") - .build() - .unwrap() - .service_type(), - ServiceType::ContainerInfrastructureManagement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .op(Op::Add) - .path("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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") - .op(Op::Add) - .path("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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") - .op(Op::Add) - .path("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 517c30bfd..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/set.rs +++ /dev/null @@ -1,241 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Cluster. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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("op", serde_json::to_value(&self.op)?); - params.push("path", serde_json::to_value(&self.path)?); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .op(Op::Add) - .path("foo") - .build() - .unwrap() - .service_type(), - ServiceType::ContainerInfrastructureManagement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .op(Op::Add) - .path("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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") - .op(Op::Add) - .path("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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") - .op(Op::Add) - .path("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/create.rs deleted file mode 100644 index febce3bf1..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/create.rs +++ /dev/null @@ -1,570 +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`. - -//! Create new cluster template. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum Labels<'a> { - F1(bool), - F2(i32), - F3(Cow<'a, str>), -} - -/// 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, setter(into))] - 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, setter(into))] - 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>, - - /// The URL pointing to users’s own private insecure docker registry to - /// deploy and run docker containers. - #[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(into, name = "_labels"))] - pub(crate) labels: Option, Labels<'a>>>, - - #[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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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.apiserver_port { - params.push("apiserver_port", 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.coe { - params.push("coe", 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.dns_nameserver { - params.push("dns_nameserver", 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.docker_volume_size { - params.push("docker_volume_size", serde_json::to_value(val)?); - } - if let Some(val) = &self.driver { - params.push("driver", 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.flavor_id { - params.push("flavor_id", 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.hidden { - params.push("hidden", 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)?); - } - params.push("image_id", serde_json::to_value(&self.image_id)?); - if let Some(val) = &self.insecure_registry { - params.push("insecure_registry", 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.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.master_flavor_id { - params.push("master_flavor_id", 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.name { - params.push("name", 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.no_proxy { - params.push("no_proxy", 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.public { - params.push("public", 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.server_type { - params.push("server_type", serde_json::to_value(val)?); - } - if let Some(val) = &self.tags { - params.push("tags", 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.updated_at { - params.push("updated_at", 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.uuid { - params.push("uuid", serde_json::to_value(val)?); - } - if let Some(val) = &self.volume_driver { - params.push("volume_driver", 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index f7927072a..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/delete.rs +++ /dev/null @@ -1,182 +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`. - -//! Delete a cluster template. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Clustertemplate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 90b0138b4..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/get.rs +++ /dev/null @@ -1,182 +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 all information of a cluster template in Magnum. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Clustertemplate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index e0fd388d7..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate/list.rs +++ /dev/null @@ -1,177 +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`. - -//! List all available cluster templates in Magnum. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/federation/create.rs deleted file mode 100644 index 334095581..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/create.rs +++ /dev/null @@ -1,309 +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`. - -//! Create a new federation. -//! -//! | param federation: | | | --- | --- | | | a federation within the request -//! body. | -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 = "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, -} - -#[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(into, 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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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.created_at { - params.push("created_at", 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.links { - params.push("links", 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.name { - params.push("name", serde_json::to_value(val)?); - } - if let Some(val) = &self.properties { - params.push("properties", 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.updated_at { - params.push("updated_at", serde_json::to_value(val)?); - } - if let Some(val) = &self.uuid { - params.push("uuid", 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 398e7bc30..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Federation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index fe5f63f52..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/get.rs +++ /dev/null @@ -1,184 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Federation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index ef68bdd8b..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/federation/list.rs +++ /dev/null @@ -1,182 +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`. - -//! 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/list.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/mservice/list.rs deleted file mode 100644 index 11492048f..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/mservice/list.rs +++ /dev/null @@ -1,181 +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`. - -//! 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/create.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/quota/create.rs deleted file mode 100644 index 7b9e80975..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/create.rs +++ /dev/null @@ -1,227 +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`. - -//! Create new quota for a project. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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, setter(into))] - pub(crate) hard_limit: Option, - - #[builder(default, setter(into))] - 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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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.created_at { - params.push("created_at", 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.id { - params.push("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.resource { - params.push("resource", 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index d57b099e5..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index d162abea1..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/get.rs +++ /dev/null @@ -1,184 +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`. - -//! 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index d29e71d97..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/quota/list.rs +++ /dev/null @@ -1,177 +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`. - -//! List all quotas in Magnum. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/stat/get.rs deleted file mode 100644 index 51d736fd9..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/stat/get.rs +++ /dev/null @@ -1,175 +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 overall Magnum system stats. If the requester is non-admin user show -//! self stats. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/get.rs b/openstack_sdk/src/api/container_infrastructure_management/v1/version/get.rs deleted file mode 100644 index 6f889d932..000000000 --- a/openstack_sdk/src/api/container_infrastructure_management/v1/version/get.rs +++ /dev/null @@ -1,171 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns.rs b/openstack_sdk/src/api/dns.rs index 7b3b53f77..63f63217e 100644 --- a/openstack_sdk/src/api/dns.rs +++ b/openstack_sdk/src/api/dns.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! DNS service (Designate) bindings -pub mod v2; +//! # DNS service (Designate) bindings +pub use openstack_sdk_dns::*; diff --git a/openstack_sdk/src/api/dns/v2/blacklist/create.rs b/openstack_sdk/src/api/dns/v2/blacklist/create.rs deleted file mode 100644 index 58e0d57e3..000000000 --- a/openstack_sdk/src/api/dns/v2/blacklist/create.rs +++ /dev/null @@ -1,202 +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`. - -//! Create a Blacklist -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Blacklist. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "blacklists".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/blacklists".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/blacklists".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/blacklist/delete.rs b/openstack_sdk/src/api/dns/v2/blacklist/delete.rs deleted file mode 100644 index d6e9547d1..000000000 --- a/openstack_sdk/src/api/dns/v2/blacklist/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a blacklist -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// blacklist_id parameter for /v2/blacklists/{blacklist_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<'a> RequestBuilder<'a> { - /// Add a single header to the Blacklist. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("blacklists/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/blacklists/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/blacklists/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/blacklist/get.rs b/openstack_sdk/src/api/dns/v2/blacklist/get.rs deleted file mode 100644 index c3443b5f1..000000000 --- a/openstack_sdk/src/api/dns/v2/blacklist/get.rs +++ /dev/null @@ -1,181 +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 a blacklist -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// blacklist_id parameter for /v2/blacklists/{blacklist_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<'a> RequestBuilder<'a> { - /// Add a single header to the Blacklist. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("blacklists/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/blacklists/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/blacklists/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/blacklist/list.rs b/openstack_sdk/src/api/dns/v2/blacklist/list.rs deleted file mode 100644 index 1449cbb47..000000000 --- a/openstack_sdk/src/api/dns/v2/blacklist/list.rs +++ /dev/null @@ -1,176 +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`. - -//! List all blacklists -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Blacklist. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "blacklists".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/blacklists".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/blacklists".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/blacklist/set.rs b/openstack_sdk/src/api/dns/v2/blacklist/set.rs deleted file mode 100644 index 87b697d0c..000000000 --- a/openstack_sdk/src/api/dns/v2/blacklist/set.rs +++ /dev/null @@ -1,212 +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`. - -//! Update a Blacklist -//! -//! Normal response codes: 200 -//! -//! Error response codes: 405,404,403,401,400,503 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// blacklist_id parameter for /v2/blacklists/{blacklist_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Blacklist. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("blacklists/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/blacklists/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/blacklists/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/limit/get.rs b/openstack_sdk/src/api/dns/v2/limit/get.rs deleted file mode 100644 index cae96f333..000000000 --- a/openstack_sdk/src/api/dns/v2/limit/get.rs +++ /dev/null @@ -1,176 +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`. - -//! List project limits -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "limits".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/pool/create.rs b/openstack_sdk/src/api/dns/v2/pool/create.rs deleted file mode 100644 index f16572a7f..000000000 --- a/openstack_sdk/src/api/dns/v2/pool/create.rs +++ /dev/null @@ -1,202 +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`. - -//! Create a Pool -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "pools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/pools".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/pools".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/pool/delete.rs b/openstack_sdk/src/api/dns/v2/pool/delete.rs deleted file mode 100644 index 6e9099624..000000000 --- a/openstack_sdk/src/api/dns/v2/pool/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete the specific pool -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// pool_id parameter for /v2/pools/{pool_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<'a> RequestBuilder<'a> { - /// Add a single header to the Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("pools/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/pools/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/pools/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/pool/get.rs b/openstack_sdk/src/api/dns/v2/pool/get.rs deleted file mode 100644 index b2858e2dc..000000000 --- a/openstack_sdk/src/api/dns/v2/pool/get.rs +++ /dev/null @@ -1,185 +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 a specific Pool -//! -//! Normal response codes: 200 -//! -//! Error response codes: 405,404,403,401,400,503 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// pool_id parameter for /v2/pools/{pool_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<'a> RequestBuilder<'a> { - /// Add a single header to the Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("pools/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/pools/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/pools/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/pool/list.rs b/openstack_sdk/src/api/dns/v2/pool/list.rs deleted file mode 100644 index 8d8602e1a..000000000 --- a/openstack_sdk/src/api/dns/v2/pool/list.rs +++ /dev/null @@ -1,176 +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 the list of Pools. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "pools".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/pools".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/pools".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/pool/set.rs b/openstack_sdk/src/api/dns/v2/pool/set.rs deleted file mode 100644 index a3f3d9722..000000000 --- a/openstack_sdk/src/api/dns/v2/pool/set.rs +++ /dev/null @@ -1,208 +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`. - -//! Update the specific pool -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// pool_id parameter for /v2/pools/{pool_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("pools/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/pools/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/pools/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/quota/delete.rs b/openstack_sdk/src/api/dns/v2/quota/delete.rs deleted file mode 100644 index b60ca7d62..000000000 --- a/openstack_sdk/src/api/dns/v2/quota/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Reset all quotas for a project to default -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v2/quotas/{project_id} API - #[builder(default, setter(into))] - project_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 Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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/{project_id}", project_id = self.project_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/quotas/{project_id}", project_id = "project_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/quotas/{project_id}", project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/quota/get.rs b/openstack_sdk/src/api/dns/v2/quota/get.rs deleted file mode 100644 index 3eec94679..000000000 --- a/openstack_sdk/src/api/dns/v2/quota/get.rs +++ /dev/null @@ -1,183 +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`. - -//! View a projects quotas -//! -//! This returns a key:value set of quotas on the system. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v2/quotas/{project_id} API - #[builder(default, setter(into))] - project_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 Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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/{project_id}", project_id = self.project_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/quotas/{project_id}", project_id = "project_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/quotas/{project_id}", project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/quota/list.rs b/openstack_sdk/src/api/dns/v2/quota/list.rs deleted file mode 100644 index a46943507..000000000 --- a/openstack_sdk/src/api/dns/v2/quota/list.rs +++ /dev/null @@ -1,164 +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`. - -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::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("/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::GET) - .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/dns/v2/quota/set.rs b/openstack_sdk/src/api/dns/v2/quota/set.rs deleted file mode 100644 index 7a1e1caeb..000000000 --- a/openstack_sdk/src/api/dns/v2/quota/set.rs +++ /dev/null @@ -1,222 +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`. - -//! Set a projects quotas -//! -//! The request should be a key:value set of quotas to be set -//! -//! This returns a key:value set of quotas on the system. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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) api_export_size: Option, - - #[builder(default, setter(into))] - pub(crate) recordset_records: Option, - - #[builder(default, setter(into))] - pub(crate) zone_records: Option, - - #[builder(default, setter(into))] - pub(crate) zone_recordsets: Option, - - #[builder(default, setter(into))] - pub(crate) zones: Option, - - /// project_id parameter for /v2/quotas/{project_id} API - #[builder(default, setter(into))] - project_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 Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("quotas/{project_id}", project_id = self.project_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.api_export_size { - params.push("api_export_size", serde_json::to_value(val)?); - } - if let Some(val) = &self.recordset_records { - params.push("recordset_records", serde_json::to_value(val)?); - } - if let Some(val) = &self.zone_records { - params.push("zone_records", serde_json::to_value(val)?); - } - if let Some(val) = &self.zone_recordsets { - params.push("zone_recordsets", serde_json::to_value(val)?); - } - if let Some(val) = &self.zones { - params.push("zones", serde_json::to_value(val)?); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/quotas/{project_id}", project_id = "project_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/quotas/{project_id}", project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/recordset/get.rs b/openstack_sdk/src/api/dns/v2/recordset/get.rs deleted file mode 100644 index 76d6c82af..000000000 --- a/openstack_sdk/src/api/dns/v2/recordset/get.rs +++ /dev/null @@ -1,181 +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 RecordSet -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// recordset_id parameter for /v2/recordsets/{recordset_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<'a> RequestBuilder<'a> { - /// Add a single header to the Recordset. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("recordsets/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/recordsets/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/recordsets/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/recordset/list.rs b/openstack_sdk/src/api/dns/v2/recordset/list.rs deleted file mode 100644 index 4b628f808..000000000 --- a/openstack_sdk/src/api/dns/v2/recordset/list.rs +++ /dev/null @@ -1,254 +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`. - -//! This lists all recordsets owned by a project in Designate -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filter results to only show zones that have a type matching the filter - #[builder(default, setter(into))] - _type: Option>, - - /// Filter results to only show recordsets that have a record with data - /// matching the filter - #[builder(default, setter(into))] - data: Option>, - - /// Filter results to only show zones that have a description matching the - /// filter - #[builder(default, setter(into))] - description: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Filter results to only show zones that have a name matching the filter - #[builder(default, setter(into))] - name: Option>, - - /// Sorts the response by the requested sort direction. A valid value is - /// asc (ascending) or desc (descending). Default is asc. You can specify - /// multiple pairs of sort key and sort direction query parameters. If you - /// omit the sort direction in a pair, the API uses the natural sorting - /// direction of the server attribute that is provided as the sort_key. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts the response by the this attribute value. Default is id. You can - /// specify multiple pairs of sort key and sort direction query parameters. - /// If you omit the sort direction in a pair, the API uses the natural - /// sorting direction of the server attribute that is provided as the - /// sort_key. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filter results to only show zones that have a status matching the - /// filter - #[builder(default, setter(into))] - status: Option>, - - /// Filter results to only show zones that have a ttl matching the filter - #[builder(default)] - ttl: Option, - - /// ID for the zone - #[builder(default, setter(into))] - zone_id: 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> { - /// Add a single header to the Recordset. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "recordsets".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("data", self.data.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("ttl", self.ttl); - params.push_opt("type", self._type.as_ref()); - params.push_opt("zone_id", self.zone_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Dns - } - - fn response_key(&self) -> Option> { - Some("recordsets".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Dns - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "recordsets" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/recordsets".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "recordsets": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/recordsets".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "recordsets": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/reverse/floatingip/get.rs b/openstack_sdk/src/api/dns/v2/reverse/floatingip/get.rs deleted file mode 100644 index b402f4c0a..000000000 --- a/openstack_sdk/src/api/dns/v2/reverse/floatingip/get.rs +++ /dev/null @@ -1,190 +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`. - -//! Shows a particular FloatingIP PTR -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// fip_key parameter for /v2/reverse/floatingips/{fip_key} API - #[builder(default, setter(into))] - fip_key: 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 Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "reverse/floatingips/{fip_key}", - fip_key = self.fip_key.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/reverse/floatingips/{fip_key}", - fip_key = "fip_key", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().fip_key("fip_key").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/reverse/floatingips/{fip_key}", - fip_key = "fip_key", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .fip_key("fip_key") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/reverse/floatingip/list.rs b/openstack_sdk/src/api/dns/v2/reverse/floatingip/list.rs deleted file mode 100644 index fd1e633e4..000000000 --- a/openstack_sdk/src/api/dns/v2/reverse/floatingip/list.rs +++ /dev/null @@ -1,179 +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`. - -//! List FloatingIP PTR records -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "reverse/floatingips".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Dns - } - - fn response_key(&self) -> Option> { - Some("floatingips".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Dns - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floatingips" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/reverse/floatingips".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingips": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/reverse/floatingips".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingips": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/reverse/floatingip/set.rs b/openstack_sdk/src/api/dns/v2/reverse/floatingip/set.rs deleted file mode 100644 index c04438926..000000000 --- a/openstack_sdk/src/api/dns/v2/reverse/floatingip/set.rs +++ /dev/null @@ -1,226 +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`. - -//! Set a PTR record for the given FloatingIP. The domain if it does not exist -//! will be provisioned automatically. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The floatingip address for this PTR record. - #[builder(default, setter(into))] - pub(crate) address: Option>, - - /// Description for this PTR record - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Domain name for this PTR record - #[builder(default, setter(into))] - pub(crate) ptrdname: Option>>, - - /// Time to live for this PTR record - #[builder(default, setter(into))] - pub(crate) ttl: Option, - - /// fip_key parameter for /v2/reverse/floatingips/{fip_key} API - #[builder(default, setter(into))] - fip_key: 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 Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "reverse/floatingips/{fip_key}", - fip_key = self.fip_key.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.address { - params.push("address", serde_json::to_value(val)?); - } - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self.ptrdname { - params.push("ptrdname", serde_json::to_value(val)?); - } - if let Some(val) = &self.ttl { - params.push("ttl", serde_json::to_value(val)?); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH).path(format!( - "/reverse/floatingips/{fip_key}", - fip_key = "fip_key", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().fip_key("fip_key").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!( - "/reverse/floatingips/{fip_key}", - fip_key = "fip_key", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .fip_key("fip_key") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/service_status/get.rs b/openstack_sdk/src/api/dns/v2/service_status/get.rs deleted file mode 100644 index 499eba414..000000000 --- a/openstack_sdk/src/api/dns/v2/service_status/get.rs +++ /dev/null @@ -1,190 +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 status of a service. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_id parameter for /v2/service_statuses/{service_id} API - #[builder(default, setter(into))] - service_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 Service_Status. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "service_statuses/{service_id}", - service_id = self.service_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/service_statuses/{service_id}", - service_id = "service_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().service_id("service_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/service_statuses/{service_id}", - service_id = "service_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() - .service_id("service_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/service_status/list.rs b/openstack_sdk/src/api/dns/v2/service_status/list.rs deleted file mode 100644 index 9b09869b2..000000000 --- a/openstack_sdk/src/api/dns/v2/service_status/list.rs +++ /dev/null @@ -1,176 +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`. - -//! List all Services and statuses. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Service_Status. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "service_statuses".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/service_statuses".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/service_statuses".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tld/create.rs b/openstack_sdk/src/api/dns/v2/tld/create.rs deleted file mode 100644 index 707fcabf3..000000000 --- a/openstack_sdk/src/api/dns/v2/tld/create.rs +++ /dev/null @@ -1,202 +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`. - -//! Create a tld -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Tld. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "tlds".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/tlds".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/tlds".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tld/delete.rs b/openstack_sdk/src/api/dns/v2/tld/delete.rs deleted file mode 100644 index 98bfb48ab..000000000 --- a/openstack_sdk/src/api/dns/v2/tld/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a tld -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// tld_id parameter for /v2/tlds/{tld_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<'a> RequestBuilder<'a> { - /// Add a single header to the Tld. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("tlds/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/tlds/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/tlds/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tld/get.rs b/openstack_sdk/src/api/dns/v2/tld/get.rs deleted file mode 100644 index 7d2c24ff9..000000000 --- a/openstack_sdk/src/api/dns/v2/tld/get.rs +++ /dev/null @@ -1,181 +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 a tld -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// tld_id parameter for /v2/tlds/{tld_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<'a> RequestBuilder<'a> { - /// Add a single header to the Tld. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("tlds/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/tlds/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/tlds/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tld/list.rs b/openstack_sdk/src/api/dns/v2/tld/list.rs deleted file mode 100644 index f642533ff..000000000 --- a/openstack_sdk/src/api/dns/v2/tld/list.rs +++ /dev/null @@ -1,175 +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`. - -//! List the tlds associated with the Project -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Tld. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "tlds".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path("/tlds".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/tlds".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tld/set.rs b/openstack_sdk/src/api/dns/v2/tld/set.rs deleted file mode 100644 index a77c4228b..000000000 --- a/openstack_sdk/src/api/dns/v2/tld/set.rs +++ /dev/null @@ -1,208 +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`. - -//! Update a tld -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// tld_id parameter for /v2/tlds/{tld_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Tld. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("tlds/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/tlds/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/tlds/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tsigkey/create.rs b/openstack_sdk/src/api/dns/v2/tsigkey/create.rs deleted file mode 100644 index 9f151adf9..000000000 --- a/openstack_sdk/src/api/dns/v2/tsigkey/create.rs +++ /dev/null @@ -1,202 +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`. - -//! Create a new Tsigkey -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Tsigkey. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "tsigkeys".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/tsigkeys".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/tsigkeys".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tsigkey/delete.rs b/openstack_sdk/src/api/dns/v2/tsigkey/delete.rs deleted file mode 100644 index 1e662c8a6..000000000 --- a/openstack_sdk/src/api/dns/v2/tsigkey/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a tsigkey -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// tsigkey_id parameter for /v2/tsigkeys/{tsigkey_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<'a> RequestBuilder<'a> { - /// Add a single header to the Tsigkey. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("tsigkeys/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/tsigkeys/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/tsigkeys/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tsigkey/get.rs b/openstack_sdk/src/api/dns/v2/tsigkey/get.rs deleted file mode 100644 index 9b6964977..000000000 --- a/openstack_sdk/src/api/dns/v2/tsigkey/get.rs +++ /dev/null @@ -1,181 +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 a tsigkey -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// tsigkey_id parameter for /v2/tsigkeys/{tsigkey_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<'a> RequestBuilder<'a> { - /// Add a single header to the Tsigkey. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("tsigkeys/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/tsigkeys/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/tsigkeys/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tsigkey/list.rs b/openstack_sdk/src/api/dns/v2/tsigkey/list.rs deleted file mode 100644 index 4c2ae8f75..000000000 --- a/openstack_sdk/src/api/dns/v2/tsigkey/list.rs +++ /dev/null @@ -1,176 +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`. - -//! List all tsigkeys -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Tsigkey. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "tsigkeys".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/tsigkeys".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/tsigkeys".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/tsigkey/set.rs b/openstack_sdk/src/api/dns/v2/tsigkey/set.rs deleted file mode 100644 index 56e9c4da9..000000000 --- a/openstack_sdk/src/api/dns/v2/tsigkey/set.rs +++ /dev/null @@ -1,208 +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`. - -//! Update the attribute(s) of an existing tsigkey -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// tsigkey_id parameter for /v2/tsigkeys/{tsigkey_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Tsigkey. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("tsigkeys/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/tsigkeys/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/tsigkeys/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/create.rs b/openstack_sdk/src/api/dns/v2/zone/create.rs deleted file mode 100644 index 1d2d84bac..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/create.rs +++ /dev/null @@ -1,266 +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`. - -//! Create a zone -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Type { - #[serde(rename = "CATALOG")] - Catalog, - #[serde(rename = "PRIMARY")] - Primary, - #[serde(rename = "SECONDARY")] - Secondary, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Key:Value pairs of information about this zone, and the pool the user - /// would like to place the zone in. This information can be used by the - /// scheduler to place zones on the correct pool. - #[builder(default, private, setter(into, name = "_attributes"))] - pub(crate) attributes: Option, Cow<'a, str>>>, - - /// Description for this zone - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// e-mail for the zone. Used in SOA records for the zone. Mandatory for - /// PRIMARY zones, forbidden for SECONDARY zones. - #[builder(default, setter(into))] - pub(crate) email: Option>, - - /// Mandatory for secondary zones. The servers to slave from to get DNS - /// information - #[builder(default, setter(into))] - pub(crate) masters: Option>>, - - /// DNS Name for the zone - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// TTL (Time to Live) for the zone. - #[builder(default, setter(into))] - pub(crate) ttl: Option, - - /// Type of zone. PRIMARY is controlled by Designate, SECONDARY zones are - /// slaved from another DNS Server. Defaults to PRIMARY - #[builder(default)] - pub(crate) _type: 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> { - /// Key:Value pairs of information about this zone, and the pool the user - /// would like to place the zone in. This information can be used by the - /// scheduler to place zones on the correct pool. - pub fn attributes(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.attributes - .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 Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "zones".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.attributes { - params.push("attributes", serde_json::to_value(val)?); - } - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self.email { - params.push("email", serde_json::to_value(val)?); - } - if let Some(val) = &self.masters { - params.push("masters", serde_json::to_value(val)?); - } - if let Some(val) = &self.name { - params.push("name", serde_json::to_value(val)?); - } - if let Some(val) = &self.ttl { - params.push("ttl", serde_json::to_value(val)?); - } - if let Some(val) = &self._type { - params.push("type", serde_json::to_value(val)?); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/zones".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/zones".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/delete.rs b/openstack_sdk/src/api/dns/v2/zone/delete.rs deleted file mode 100644 index 270faeb9a..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete a zone -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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} 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<'a> RequestBuilder<'a> { - /// Add a single header to the Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/zones/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/zones/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/find.rs b/openstack_sdk/src/api/dns/v2/zone/find.rs deleted file mode 100644 index bfa816828..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::dns::v2::zone::{get as Get, list as List}; - -/// Find for zone 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/get.rs b/openstack_sdk/src/api/dns/v2/zone/get.rs deleted file mode 100644 index 74cbb6320..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/get.rs +++ /dev/null @@ -1,181 +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 a zone -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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} 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<'a> RequestBuilder<'a> { - /// Add a single header to the Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/list.rs b/openstack_sdk/src/api/dns/v2/zone/list.rs deleted file mode 100644 index 4e2a06727..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/list.rs +++ /dev/null @@ -1,249 +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`. - -//! List all zones -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filter results to only show zones that have a type matching the filter - #[builder(default, setter(into))] - _type: Option>, - - /// Filter results to only show zones that have a description matching the - /// filter - #[builder(default, setter(into))] - description: Option>, - - /// Filter results to only show zones that have an email matching the - /// filter - #[builder(default, setter(into))] - email: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Filter results to only show zones that have a name matching the filter - #[builder(default, setter(into))] - name: Option>, - - /// Sorts the response by the requested sort direction. A valid value is - /// asc (ascending) or desc (descending). Default is asc. You can specify - /// multiple pairs of sort key and sort direction query parameters. If you - /// omit the sort direction in a pair, the API uses the natural sorting - /// direction of the server attribute that is provided as the sort_key. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts the response by the this attribute value. Default is id. You can - /// specify multiple pairs of sort key and sort direction query parameters. - /// If you omit the sort direction in a pair, the API uses the natural - /// sorting direction of the server attribute that is provided as the - /// sort_key. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filter results to only show zones that have a status matching the - /// filter - #[builder(default, setter(into))] - status: Option>, - - /// Filter results to only show zones that have a ttl matching the filter - #[builder(default)] - ttl: 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> { - /// Add a single header to the Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "zones".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("description", self.description.as_ref()); - params.push_opt("email", self.email.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("ttl", self.ttl); - params.push_opt("type", self._type.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Dns - } - - fn response_key(&self) -> Option> { - Some("zones".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Dns - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "zones" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "zones": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "zones": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/nameserver/list.rs b/openstack_sdk/src/api/dns/v2/zone/nameserver/list.rs deleted file mode 100644 index 3cfcefc16..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/nameserver/list.rs +++ /dev/null @@ -1,188 +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 openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "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> { - Some("nameservers".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Dns - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "nameservers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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!({ "nameservers": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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!({ "nameservers": {} })); - }); - - let endpoint = Request::builder() - .zone_id("zone_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/create.rs b/openstack_sdk/src/api/dns/v2/zone/recordset/create.rs deleted file mode 100644 index 08338d7f3..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/recordset/create.rs +++ /dev/null @@ -1,264 +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`. - -//! Create a recordset in a zone -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "A")] - A, - #[serde(rename = "AAAA")] - Aaaa, - #[serde(rename = "CAA")] - Caa, - #[serde(rename = "CERT")] - Cert, - #[serde(rename = "CNAME")] - Cname, - #[serde(rename = "MX")] - Mx, - #[serde(rename = "NAPTR")] - Naptr, - #[serde(rename = "NS")] - Ns, - #[serde(rename = "PTR")] - Ptr, - #[serde(rename = "SOA")] - Soa, - #[serde(rename = "SPF")] - Spf, - #[serde(rename = "SRV")] - Srv, - #[serde(rename = "SSHFP")] - Sshfp, - #[serde(rename = "TXT")] - Txt, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Description for this recordset - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// DNS Name for the recordset - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of data for this recordset. Each item will be a separate record - /// in Designate These items should conform to the DNS spec for the record - /// type - e.g. A records must be IPv4 addresses, CNAME records must be a - /// hostname. - #[builder(default, setter(into))] - pub(crate) records: Option>>, - - /// TTL (Time to Live) for the recordset. - #[builder(default, setter(into))] - pub(crate) ttl: Option, - - /// They RRTYPE of the recordset. - #[builder(default)] - pub(crate) _type: Option, - - /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "zones/{zone_id}/recordsets", - zone_id = self.zone_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self.name { - params.push("name", serde_json::to_value(val)?); - } - if let Some(val) = &self.records { - params.push("records", serde_json::to_value(val)?); - } - if let Some(val) = &self.ttl { - params.push("ttl", serde_json::to_value(val)?); - } - if let Some(val) = &self._type { - params.push("type", serde_json::to_value(val)?); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/zones/{zone_id}/recordsets", 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/zones/{zone_id}/recordsets", 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/delete.rs b/openstack_sdk/src/api/dns/v2/zone/recordset/delete.rs deleted file mode 100644 index 4f5f78e25..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/recordset/delete.rs +++ /dev/null @@ -1,203 +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`. - -//! Delete a recordset -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// recordset_id parameter for - /// /v2/zones/{zone_id}/recordsets/{recordset_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/{zone_id}/recordsets/{id}", - id = self.id.as_ref(), - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/zones/{zone_id}/recordsets/{id}", - id = "id", - zone_id = "zone_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .zone_id("zone_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/zones/{zone_id}/recordsets/{id}", - id = "id", - 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() - .id("id") - .zone_id("zone_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/find.rs b/openstack_sdk/src/api/dns/v2/zone/recordset/find.rs deleted file mode 100644 index 82babd1c7..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/recordset/find.rs +++ /dev/null @@ -1,96 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::dns::v2::zone::recordset::{get as Get, list as List}; - -/// Find for zone/recordset by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[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 Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.zone_id(self.zone_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - let mut ep = List::Request::builder(); - ep.zone_id(self.zone_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/recordset/get.rs b/openstack_sdk/src/api/dns/v2/zone/recordset/get.rs deleted file mode 100644 index 713992e39..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/recordset/get.rs +++ /dev/null @@ -1,203 +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 an single recordset -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// recordset_id parameter for - /// /v2/zones/{zone_id}/recordsets/{recordset_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/{zone_id}/recordsets/{id}", - id = self.id.as_ref(), - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/zones/{zone_id}/recordsets/{id}", - id = "id", - zone_id = "zone_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .zone_id("zone_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/zones/{zone_id}/recordsets/{id}", - id = "id", - 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() - .id("id") - .zone_id("zone_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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 deleted file mode 100644 index 940dfa83a..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/recordset/list.rs +++ /dev/null @@ -1,258 +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`. - -//! This lists all recordsets in a zone -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filter results to only show zones that have a type matching the filter - #[builder(default, setter(into))] - _type: Option>, - - /// Filter results to only show recordsets that have a record with data - /// matching the filter - #[builder(default, setter(into))] - data: Option>, - - /// Filter results to only show zones that have a description matching the - /// filter - #[builder(default, setter(into))] - description: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Filter results to only show zones that have a name matching the filter - #[builder(default, setter(into))] - name: Option>, - - /// Sorts the response by the requested sort direction. A valid value is - /// asc (ascending) or desc (descending). Default is asc. You can specify - /// multiple pairs of sort key and sort direction query parameters. If you - /// omit the sort direction in a pair, the API uses the natural sorting - /// direction of the server attribute that is provided as the sort_key. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts the response by the this attribute value. Default is id. You can - /// specify multiple pairs of sort key and sort direction query parameters. - /// If you omit the sort direction in a pair, the API uses the natural - /// sorting direction of the server attribute that is provided as the - /// sort_key. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filter results to only show zones that have a status matching the - /// filter - #[builder(default, setter(into))] - status: Option>, - - /// Filter results to only show zones that have a ttl matching the filter - #[builder(default)] - ttl: Option, - - /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/{zone_id}/recordsets", - zone_id = self.zone_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("data", self.data.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("ttl", self.ttl); - params.push_opt("type", self._type.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Dns - } - - fn response_key(&self) -> Option> { - Some("recordsets".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Dns - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "recordsets" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .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().zone_id("zone_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/{zone_id}/recordsets", zone_id = "zone_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "recordsets": {} })); - }); - - let endpoint = Request::builder() - .zone_id("zone_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("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/set.rs b/openstack_sdk/src/api/dns/v2/zone/recordset/set.rs deleted file mode 100644 index 4a8a7b11f..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/recordset/set.rs +++ /dev/null @@ -1,234 +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`. - -//! Update a recordset -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Description for this recordset - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// A list of data for this recordset. Each item will be a separate record - /// in Designate These items should conform to the DNS spec for the record - /// type - e.g. A records must be IPv4 addresses, CNAME records must be a - /// hostname. - #[builder(default, setter(into))] - pub(crate) records: Option>>, - - /// TTL (Time to Live) for the recordset. - #[builder(default, setter(into))] - pub(crate) ttl: Option, - - /// recordset_id parameter for - /// /v2/zones/{zone_id}/recordsets/{recordset_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "zones/{zone_id}/recordsets/{id}", - id = self.id.as_ref(), - zone_id = self.zone_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self.records { - params.push("records", serde_json::to_value(val)?); - } - if let Some(val) = &self.ttl { - params.push("ttl", serde_json::to_value(val)?); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/zones/{zone_id}/recordsets/{id}", - id = "id", - zone_id = "zone_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .zone_id("zone_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/zones/{zone_id}/recordsets/{id}", - id = "id", - 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() - .id("id") - .zone_id("zone_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/set.rs b/openstack_sdk/src/api/dns/v2/zone/set.rs deleted file mode 100644 index d5f3bffe6..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/set.rs +++ /dev/null @@ -1,210 +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`. - -//! Update the attribute(s) for an existing zone. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Description for this zone - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// e-mail for the zone. Used in SOA records for the zone. Forbidden for - /// SECONDARY zones. - #[builder(default, setter(into))] - pub(crate) email: Option>, - - /// TTL (Time to Live) for the zone. - #[builder(default, setter(into))] - pub(crate) ttl: Option, - - /// zone_id parameter for /v2/zones/{zone_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<'a> RequestBuilder<'a> { - /// Add a single header to the Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self.email { - params.push("email", serde_json::to_value(val)?); - } - if let Some(val) = &self.ttl { - params.push("ttl", serde_json::to_value(val)?); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/zones/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/zones/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/share/create.rs b/openstack_sdk/src/api/dns/v2/zone/share/create.rs deleted file mode 100644 index 74eec8614..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/share/create.rs +++ /dev/null @@ -1,216 +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`. - -//! Share a zone with another project. -//! -//! **New in version 2.1** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The project ID the zone will be shared with. - /// - /// **New in version 2.1** - #[builder(setter(into))] - pub(crate) target_project_id: Cow<'a, str>, - - /// zone_id parameter for /v2/zones/{zone_id}/shares 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 Share. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("zones/{zone_id}/shares", zone_id = self.zone_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "target_project_id", - serde_json::to_value(&self.target_project_id)?, - ); - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .target_project_id("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Dns - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .target_project_id("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/zones/{zone_id}/shares", zone_id = "zone_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_id("zone_id") - .target_project_id("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/zones/{zone_id}/shares", 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") - .target_project_id("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/share/delete.rs b/openstack_sdk/src/api/dns/v2/zone/share/delete.rs deleted file mode 100644 index 6fd09e058..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/share/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! Delete a zone share. -//! -//! **New in version 2.1** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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}/shares API - #[builder(default, setter(into))] - zone_id: Cow<'a, str>, - - /// zone_share_id parameter for /v2/zones/{zone_id}/shares/{zone_share_id} - /// API - #[builder(default, setter(into))] - zone_share_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 Share. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/{zone_id}/shares/{zone_share_id}", - zone_id = self.zone_id.as_ref(), - zone_share_id = self.zone_share_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/zones/{zone_id}/shares/{zone_share_id}", - zone_id = "zone_id", - zone_share_id = "zone_share_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_id("zone_id") - .zone_share_id("zone_share_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/zones/{zone_id}/shares/{zone_share_id}", - zone_id = "zone_id", - zone_share_id = "zone_share_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") - .zone_share_id("zone_share_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/share/get.rs b/openstack_sdk/src/api/dns/v2/zone/share/get.rs deleted file mode 100644 index 78e901b22..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/share/get.rs +++ /dev/null @@ -1,205 +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 a single zone share. -//! -//! **New in version 2.1** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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}/shares API - #[builder(default, setter(into))] - zone_id: Cow<'a, str>, - - /// zone_share_id parameter for /v2/zones/{zone_id}/shares/{zone_share_id} - /// API - #[builder(default, setter(into))] - zone_share_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 Share. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/{zone_id}/shares/{zone_share_id}", - zone_id = self.zone_id.as_ref(), - zone_share_id = self.zone_share_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/zones/{zone_id}/shares/{zone_share_id}", - zone_id = "zone_id", - zone_share_id = "zone_share_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_id("zone_id") - .zone_share_id("zone_share_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/zones/{zone_id}/shares/{zone_share_id}", - zone_id = "zone_id", - zone_share_id = "zone_share_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") - .zone_share_id("zone_share_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/share/list.rs b/openstack_sdk/src/api/dns/v2/zone/share/list.rs deleted file mode 100644 index 354e03894..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/share/list.rs +++ /dev/null @@ -1,208 +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`. - -//! List all zone shares. -//! -//! **New in version 2.1** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Filter results to only show resources that have a matching - /// target_project_id - #[builder(default, setter(into))] - target_project_id: Option>, - - /// zone_id parameter for /v2/zones/{zone_id}/shares 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 Share. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/{zone_id}/shares", zone_id = self.zone_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("target_project_id", self.target_project_id.as_ref()); - - params - } - - 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)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/{zone_id}/shares", 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/{zone_id}/shares", 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} 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 deleted file mode 100644 index c60706df6..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/export/create.rs +++ /dev/null @@ -1,217 +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`. - -//! Export a zone. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// zone_id parameter for /v2/zones/{zone_id}/tasks/export API - #[builder(default, setter(into))] - zone_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Export. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "zones/{zone_id}/tasks/export", - zone_id = self.zone_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/zones/{zone_id}/tasks/export", - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/zones/{zone_id}/tasks/export", - 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/export/delete.rs b/openstack_sdk/src/api/dns/v2/zone/task/export/delete.rs deleted file mode 100644 index 47b0c3878..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/export/delete.rs +++ /dev/null @@ -1,196 +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`. - -//! This will just delete the record of the zone export, not the exported zone. -//! -//! The zone will have to be deleted from the zone delete API -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// zone_export_id parameter for /v2/zones/tasks/exports/{zone_export_id} - /// API - #[builder(default, setter(into))] - zone_export_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 Export. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/tasks/exports/{zone_export_id}", - zone_export_id = self.zone_export_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/zones/tasks/exports/{zone_export_id}", - zone_export_id = "zone_export_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_export_id("zone_export_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/zones/tasks/exports/{zone_export_id}", - zone_export_id = "zone_export_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_export_id("zone_export_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/export/export/get.rs b/openstack_sdk/src/api/dns/v2/zone/task/export/export/get.rs deleted file mode 100644 index c4d991430..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/export/export/get.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// export_id parameter for /v2/zones/tasks/exports/{export_id}/export 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<'a> RequestBuilder<'a> { - /// Add a single header to the Export. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/tasks/exports/{id}/export", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/exports/{id}/export", 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/exports/{id}/export", 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/export/get.rs b/openstack_sdk/src/api/dns/v2/zone/task/export/get.rs deleted file mode 100644 index 0ccd322a8..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/export/get.rs +++ /dev/null @@ -1,181 +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 Zone Exports -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// export_id parameter for /v2/zones/tasks/exports/{export_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<'a> RequestBuilder<'a> { - /// Add a single header to the Export. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/tasks/exports/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/exports/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/exports/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/export/list.rs b/openstack_sdk/src/api/dns/v2/zone/task/export/list.rs deleted file mode 100644 index a3f119cbe..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/export/list.rs +++ /dev/null @@ -1,174 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Export. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "zones/tasks/exports".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/exports".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/exports".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} 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 deleted file mode 100644 index 2ed1302ea..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/import/create.rs +++ /dev/null @@ -1,202 +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`. - -//! Import a zone. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Import. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "zones/tasks/imports".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/zones/tasks/imports".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/zones/tasks/imports".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/import/delete.rs b/openstack_sdk/src/api/dns/v2/zone/task/import/delete.rs deleted file mode 100644 index 0136814d2..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/import/delete.rs +++ /dev/null @@ -1,196 +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`. - -//! This will just delete the record of the zone import, not the imported zone. -//! -//! The zone will have to be deleted from the zone delete API -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// zone_import_id parameter for /v2/zones/tasks/imports/{zone_import_id} - /// API - #[builder(default, setter(into))] - zone_import_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 Import. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/tasks/imports/{zone_import_id}", - zone_import_id = self.zone_import_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/zones/tasks/imports/{zone_import_id}", - zone_import_id = "zone_import_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_import_id("zone_import_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/zones/tasks/imports/{zone_import_id}", - zone_import_id = "zone_import_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_import_id("zone_import_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/import/get.rs b/openstack_sdk/src/api/dns/v2/zone/task/import/get.rs deleted file mode 100644 index c575ef9c8..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/import/get.rs +++ /dev/null @@ -1,181 +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 Zone Imports -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// import_id parameter for /v2/zones/tasks/imports/{import_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<'a> RequestBuilder<'a> { - /// Add a single header to the Import. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/tasks/imports/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/imports/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/imports/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/import/list.rs b/openstack_sdk/src/api/dns/v2/zone/task/import/list.rs deleted file mode 100644 index b4c419077..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/import/list.rs +++ /dev/null @@ -1,174 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Import. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "zones/tasks/imports".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/imports".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/imports".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} 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 deleted file mode 100644 index 9a63ceef4..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/create.rs +++ /dev/null @@ -1,202 +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`. - -//! This accepts an offer of a ownership transfer -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Transfer_Accept. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "zones/tasks/transfer_accepts".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/zones/tasks/transfer_accepts".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/zones/tasks/transfer_accepts".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/get.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/get.rs deleted file mode 100644 index 1c916467c..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/get.rs +++ /dev/null @@ -1,182 +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 transfer_accepts -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// transfer_accept_id parameter for - /// /v2/zones/tasks/transfer_accepts/{transfer_accept_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<'a> RequestBuilder<'a> { - /// Add a single header to the Transfer_Accept. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("zones/tasks/transfer_accepts/{id}", id = self.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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/transfer_accepts/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/zones/tasks/transfer_accepts/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/list.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/list.rs deleted file mode 100644 index 1eadd2110..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept/list.rs +++ /dev/null @@ -1,176 +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`. - -//! This will list all your accepted ownership transfer. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Transfer_Accept. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "zones/tasks/transfer_accepts".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/transfer_accepts".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/transfer_accepts".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} 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 deleted file mode 100644 index 067c3560f..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/create.rs +++ /dev/null @@ -1,219 +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`. - -//! This creates an offer to transfer the zone to a different project. The -//! request can be scoped to single project if the `project_id` parameter is -//! supplied. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// zone_id parameter for /v2/zones/{zone_id}/tasks/transfer_requests API - #[builder(default, setter(into))] - zone_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Transfer_Request. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "zones/{zone_id}/tasks/transfer_requests", - zone_id = self.zone_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/zones/{zone_id}/tasks/transfer_requests", - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/zones/{zone_id}/tasks/transfer_requests", - 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/delete.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/delete.rs deleted file mode 100644 index 1e689c7f7..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/delete.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// zone_transfer_request_id parameter for - /// /v2/zones/tasks/transfer_requests/{zone_transfer_request_id} API - #[builder(default, setter(into))] - zone_transfer_request_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 Transfer_Request. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = self.zone_transfer_request_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = "zone_transfer_request_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_transfer_request_id("zone_transfer_request_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = "zone_transfer_request_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_transfer_request_id("zone_transfer_request_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/get.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/get.rs deleted file mode 100644 index 507d75cbf..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/get.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// zone_transfer_request_id parameter for - /// /v2/zones/tasks/transfer_requests/{zone_transfer_request_id} API - #[builder(default, setter(into))] - zone_transfer_request_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 Transfer_Request. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = self.zone_transfer_request_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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = "zone_transfer_request_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_transfer_request_id("zone_transfer_request_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = "zone_transfer_request_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_transfer_request_id("zone_transfer_request_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/list.rs b/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/list.rs deleted file mode 100644 index e41a07501..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/list.rs +++ /dev/null @@ -1,177 +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`. - -//! This will list all your outgoing requests, and any incoming requests that -//! have been scoped to your project. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Transfer_Request. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "zones/tasks/transfer_requests".to_string().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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/transfer_requests".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/zones/tasks/transfer_requests".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} 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 deleted file mode 100644 index da2290979..000000000 --- a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request/set.rs +++ /dev/null @@ -1,219 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// zone_transfer_request_id parameter for - /// /v2/zones/tasks/transfer_requests/{zone_transfer_request_id} API - #[builder(default, setter(into))] - zone_transfer_request_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Transfer_Request. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = self.zone_transfer_request_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH).path(format!( - "/zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = "zone_transfer_request_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .zone_transfer_request_id("zone_transfer_request_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!( - "/zones/tasks/transfer_requests/{zone_transfer_request_id}", - zone_transfer_request_id = "zone_transfer_request_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_transfer_request_id("zone_transfer_request_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/find.rs b/openstack_sdk/src/api/find.rs deleted file mode 100644 index 0abb76f01..000000000 --- a/openstack_sdk/src/api/find.rs +++ /dev/null @@ -1,13 +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 diff --git a/openstack_sdk/src/api/identity.rs b/openstack_sdk/src/api/identity.rs index f9770bff5..3bbfd5cc4 100644 --- a/openstack_sdk/src/api/identity.rs +++ b/openstack_sdk/src/api/identity.rs @@ -12,7 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Identity API (Keystone) bindings -pub mod v3; -#[cfg(feature = "keystone_ng")] -pub mod v4; +//! # Identity API (Keystone) bindings +pub use openstack_sdk_identity::*; diff --git a/openstack_sdk/src/api/identity/v3/auth/catalog/head.rs b/openstack_sdk/src/api/identity/v3/auth/catalog/head.rs deleted file mode 100644 index fa706418a..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/catalog/head.rs +++ /dev/null @@ -1,171 +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 service catalog for token. -//! -//! GET/HEAD /v3/auth/catalog -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Catalog. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/catalog".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/catalog".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/catalog".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/catalog/list.rs b/openstack_sdk/src/api/identity/v3/auth/catalog/list.rs deleted file mode 100644 index 221886c78..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/catalog/list.rs +++ /dev/null @@ -1,187 +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`. - -//! New in version 3.3 -//! -//! This call returns a service catalog for the X-Auth-Token provided in the -//! request, even if the token does not contain a catalog itself (for example, -//! if it was generated using ?nocatalog). -//! -//! The structure of the catalog object is identical to that contained in a -//! token. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_catalog` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Catalog. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/catalog".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("catalog".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "catalog" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/catalog".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "catalog": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/catalog".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "catalog": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/domain/head.rs b/openstack_sdk/src/api/identity/v3/auth/domain/head.rs deleted file mode 100644 index a7b7708c9..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/domain/head.rs +++ /dev/null @@ -1,171 +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 possible domain scopes for token. -//! -//! GET/HEAD /v3/auth/domains GET/HEAD /v3/OS-FEDERATION/domains -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/domains".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/domains".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/domains".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/domain/list.rs b/openstack_sdk/src/api/identity/v3/auth/domain/list.rs deleted file mode 100644 index 65ec0d0ef..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/domain/list.rs +++ /dev/null @@ -1,185 +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`. - -//! New in version 3.3 -//! -//! This call returns the list of domains that are available to be scoped to -//! based on the X-Auth-Token provided in the request. -//! -//! The structure is the same as listing domains. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_domains` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/domains".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("domains".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "domains" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/domains".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domains": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/domains".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domains": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/create.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/create.rs deleted file mode 100644 index 5f216e5f6..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/create.rs +++ /dev/null @@ -1,210 +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`. - -//! POST operation on -//! /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso - /// API - #[builder(default, setter(into))] - idp_id: Cow<'a, str>, - - /// protocol_id parameter for - /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso - /// API - #[builder(default, setter(into))] - protocol_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 Websso. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = self.idp_id.as_ref(), - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = "idp_id", - protocol_id = "protocol_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = "idp_id", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/get.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/get.rs deleted file mode 100644 index 5c95aeee3..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/get.rs +++ /dev/null @@ -1,210 +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 operation on -//! /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso - /// API - #[builder(default, setter(into))] - idp_id: Cow<'a, str>, - - /// protocol_id parameter for - /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso - /// API - #[builder(default, setter(into))] - protocol_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 Websso. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = self.idp_id.as_ref(), - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = "idp_id", - protocol_id = "protocol_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = "idp_id", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/head.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/head.rs deleted file mode 100644 index aa3cd0db4..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso/head.rs +++ /dev/null @@ -1,202 +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`. - -//! HEAD operation on -//! /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso - /// API - #[builder(default, setter(into))] - idp_id: Cow<'a, str>, - - /// protocol_id parameter for - /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso - /// API - #[builder(default, setter(into))] - protocol_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 Websso. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = self.idp_id.as_ref(), - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = "idp_id", - protocol_id = "protocol_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", - idp_id = "idp_id", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/create.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/create.rs deleted file mode 100644 index 5c84a8b10..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/create.rs +++ /dev/null @@ -1,555 +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`. - -//! Exchange a scoped token for a SAML assertion. -//! -//! POST /v3/auth/OS-FEDERATION/saml2 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::serialize_sensitive_optional_string; -use openstack_sdk_core::api::common::serialize_sensitive_string; -use secrecy::SecretString; -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `domain` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - /// User Domain ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// User Domain Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// A user object, required if an application credential is identified by name -/// and not ID. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// An application credential object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ApplicationCredential<'a> { - /// The ID of the application credential used for authentication. If not - /// provided, the application credential must be identified by its name and - /// its owning user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The name of the application credential used for authentication. If - /// provided, must be accompanied by a user object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The secret for authenticating the application credential. - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) secret: SecretString, - - /// A user object, required if an application credential is identified by - /// name and not ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Methods { - #[serde(rename = "application_credential")] - ApplicationCredential, - #[serde(rename = "password")] - Password, - #[serde(rename = "token")] - Token, - #[serde(rename = "totp")] - Totp, -} - -/// A `user` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PasswordUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The ID of the user. Required if you do not specify the user name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name. Required if you do not specify the ID of the user. If - /// you specify the user name, you must also specify the domain, by ID or - /// name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// User Password - #[serde( - serialize_with = "serialize_sensitive_optional_string", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) password: Option, -} - -/// The `password` object, contains the authentication information. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Password<'a> { - /// A `user` object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -/// A `token` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Token { - /// Authorization Token value - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) id: SecretString, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct TotpUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// MFA passcode - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) passcode: SecretString, -} - -/// Multi Factor Authentication information -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Totp<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) user: TotpUser<'a>, -} - -/// An `identity` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Identity<'a> { - /// An application credential object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) application_credential: Option>, - - /// The authentication method. For password authentication, specify - /// `password`. - #[serde()] - #[builder(setter(into))] - pub(crate) methods: Vec, - - /// The `password` object, contains the authentication information. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) password: Option>, - - /// A `token` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token: Option, - - /// Multi Factor Authentication information - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) totp: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsTrustTrust<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ScopeDomain<'a> { - /// Domain id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Domain name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ProjectDomain<'a> { - /// Project domain Id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Project domain Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Project<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// Project Id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Project Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct System { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all: Option, -} - -/// The authorization scope, including the system (Since v3.10), a project, or -/// a domain (Since v3.4). If multiple scopes are specified in the same request -/// (e.g. project and domain or domain and system) an HTTP 400 Bad Request will -/// be returned, as a token cannot be simultaneously scoped to multiple -/// authorization targets. An ID is sufficient to uniquely identify a project -/// but if a project is specified by name, then the domain of the project must -/// also be specified in order to uniquely identify the project by name. A -/// domain scope may be specified by either the domain’s ID or name with -/// equivalent results. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Scope<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(rename = "OS-TRUST:trust", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) os_trust_trust: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) system: Option, -} - -/// An `auth` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Auth<'a> { - /// An `identity` object. - #[serde()] - #[builder(setter(into))] - pub(crate) identity: Identity<'a>, - - /// The authorization scope, including the system (Since v3.10), a project, - /// or a domain (Since v3.4). If multiple scopes are specified in the same - /// request (e.g. project and domain or domain and system) an HTTP 400 Bad - /// Request will be returned, as a token cannot be simultaneously scoped to - /// multiple authorization targets. An ID is sufficient to uniquely - /// identify a project but if a project is specified by name, then the - /// domain of the project must also be specified in order to uniquely - /// identify the project by name. A domain scope may be specified by either - /// the domain’s ID or name with equivalent results. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) scope: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `auth` object. - #[builder(setter(into))] - pub(crate) auth: Auth<'a>, - - #[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 Saml2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/OS-FEDERATION/saml2".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("auth", serde_json::to_value(&self.auth)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/OS-FEDERATION/saml2".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/OS-FEDERATION/saml2".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() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/create.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/create.rs deleted file mode 100644 index faf1a8c67..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/create.rs +++ /dev/null @@ -1,555 +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`. - -//! Exchange a scoped token for an ECP assertion. -//! -//! POST /v3/auth/OS-FEDERATION/saml2/ecp -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::serialize_sensitive_optional_string; -use openstack_sdk_core::api::common::serialize_sensitive_string; -use secrecy::SecretString; -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `domain` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - /// User Domain ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// User Domain Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// A user object, required if an application credential is identified by name -/// and not ID. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// An application credential object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ApplicationCredential<'a> { - /// The ID of the application credential used for authentication. If not - /// provided, the application credential must be identified by its name and - /// its owning user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The name of the application credential used for authentication. If - /// provided, must be accompanied by a user object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The secret for authenticating the application credential. - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) secret: SecretString, - - /// A user object, required if an application credential is identified by - /// name and not ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Methods { - #[serde(rename = "application_credential")] - ApplicationCredential, - #[serde(rename = "password")] - Password, - #[serde(rename = "token")] - Token, - #[serde(rename = "totp")] - Totp, -} - -/// A `user` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PasswordUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The ID of the user. Required if you do not specify the user name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name. Required if you do not specify the ID of the user. If - /// you specify the user name, you must also specify the domain, by ID or - /// name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// User Password - #[serde( - serialize_with = "serialize_sensitive_optional_string", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) password: Option, -} - -/// The `password` object, contains the authentication information. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Password<'a> { - /// A `user` object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -/// A `token` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Token { - /// Authorization Token value - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) id: SecretString, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct TotpUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// MFA passcode - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) passcode: SecretString, -} - -/// Multi Factor Authentication information -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Totp<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) user: TotpUser<'a>, -} - -/// An `identity` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Identity<'a> { - /// An application credential object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) application_credential: Option>, - - /// The authentication method. For password authentication, specify - /// `password`. - #[serde()] - #[builder(setter(into))] - pub(crate) methods: Vec, - - /// The `password` object, contains the authentication information. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) password: Option>, - - /// A `token` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token: Option, - - /// Multi Factor Authentication information - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) totp: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsTrustTrust<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ScopeDomain<'a> { - /// Domain id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Domain name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ProjectDomain<'a> { - /// Project domain Id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Project domain Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Project<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// Project Id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Project Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct System { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all: Option, -} - -/// The authorization scope, including the system (Since v3.10), a project, or -/// a domain (Since v3.4). If multiple scopes are specified in the same request -/// (e.g. project and domain or domain and system) an HTTP 400 Bad Request will -/// be returned, as a token cannot be simultaneously scoped to multiple -/// authorization targets. An ID is sufficient to uniquely identify a project -/// but if a project is specified by name, then the domain of the project must -/// also be specified in order to uniquely identify the project by name. A -/// domain scope may be specified by either the domain’s ID or name with -/// equivalent results. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Scope<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(rename = "OS-TRUST:trust", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) os_trust_trust: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) system: Option, -} - -/// An `auth` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Auth<'a> { - /// An `identity` object. - #[serde()] - #[builder(setter(into))] - pub(crate) identity: Identity<'a>, - - /// The authorization scope, including the system (Since v3.10), a project, - /// or a domain (Since v3.4). If multiple scopes are specified in the same - /// request (e.g. project and domain or domain and system) an HTTP 400 Bad - /// Request will be returned, as a token cannot be simultaneously scoped to - /// multiple authorization targets. An ID is sufficient to uniquely - /// identify a project but if a project is specified by name, then the - /// domain of the project must also be specified in order to uniquely - /// identify the project by name. A domain scope may be specified by either - /// the domain’s ID or name with equivalent results. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) scope: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `auth` object. - #[builder(setter(into))] - pub(crate) auth: Auth<'a>, - - #[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 Ecp. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/OS-FEDERATION/saml2/ecp".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("auth", serde_json::to_value(&self.auth)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/OS-FEDERATION/saml2/ecp".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/OS-FEDERATION/saml2/ecp".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() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/get.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/get.rs deleted file mode 100644 index 04b01da00..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/auth/OS-FEDERATION/saml2/ecp -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Ecp. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/OS-FEDERATION/saml2/ecp".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/OS-FEDERATION/saml2/ecp".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/OS-FEDERATION/saml2/ecp".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/head.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/head.rs deleted file mode 100644 index b8f039952..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/auth/OS-FEDERATION/saml2/ecp -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Ecp. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/OS-FEDERATION/saml2/ecp".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/OS-FEDERATION/saml2/ecp".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/OS-FEDERATION/saml2/ecp".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/get.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/get.rs deleted file mode 100644 index 9d7c850d0..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/auth/OS-FEDERATION/saml2 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Saml2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/OS-FEDERATION/saml2".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/OS-FEDERATION/saml2".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/OS-FEDERATION/saml2".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/head.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/head.rs deleted file mode 100644 index 97dd086ed..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/auth/OS-FEDERATION/saml2 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Saml2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/OS-FEDERATION/saml2".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/OS-FEDERATION/saml2".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/OS-FEDERATION/saml2".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/create.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/create.rs deleted file mode 100644 index 13d94c2ec..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/create.rs +++ /dev/null @@ -1,197 +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`. - -//! POST operation on /v3/auth/OS-FEDERATION/websso/{protocol_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// protocol_id parameter for /v3/auth/OS-FEDERATION/websso/{protocol_id} - /// API - #[builder(default, setter(into))] - protocol_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 Websso. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = "protocol_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .protocol_id("protocol_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/get.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/get.rs deleted file mode 100644 index 8caa8730a..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/get.rs +++ /dev/null @@ -1,197 +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 operation on /v3/auth/OS-FEDERATION/websso/{protocol_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// protocol_id parameter for /v3/auth/OS-FEDERATION/websso/{protocol_id} - /// API - #[builder(default, setter(into))] - protocol_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 Websso. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = "protocol_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .protocol_id("protocol_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/head.rs b/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/head.rs deleted file mode 100644 index 422e5764b..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/os_federation/websso/head.rs +++ /dev/null @@ -1,189 +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`. - -//! HEAD operation on /v3/auth/OS-FEDERATION/websso/{protocol_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// protocol_id parameter for /v3/auth/OS-FEDERATION/websso/{protocol_id} - /// API - #[builder(default, setter(into))] - protocol_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 Websso. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = "protocol_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .protocol_id("protocol_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/auth/OS-FEDERATION/websso/{protocol_id}", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/project/head.rs b/openstack_sdk/src/api/identity/v3/auth/project/head.rs deleted file mode 100644 index 2a7fb4a9f..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/project/head.rs +++ /dev/null @@ -1,171 +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 possible project scopes for token. -//! -//! GET/HEAD /v3/auth/projects GET/HEAD /v3/OS-FEDERATION/projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/projects".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/projects".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/projects".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/project/list.rs b/openstack_sdk/src/api/identity/v3/auth/project/list.rs deleted file mode 100644 index 64a14d321..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/project/list.rs +++ /dev/null @@ -1,186 +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`. - -//! New in version 3.3 -//! -//! This call returns the list of projects that are available to be scoped to -//! based on the X-Auth-Token provided in the request. -//! -//! The structure of the response is exactly the same as listing projects for a -//! user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/projects".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("projects".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "projects" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/projects".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/projects".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/system/head.rs b/openstack_sdk/src/api/identity/v3/auth/system/head.rs deleted file mode 100644 index e75f998ee..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/system/head.rs +++ /dev/null @@ -1,171 +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 possible system scopes for token. -//! -//! GET/HEAD /v3/auth/system -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 System. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/system".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/system".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/system".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/system/list.rs b/openstack_sdk/src/api/identity/v3/auth/system/list.rs deleted file mode 100644 index 57c074392..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/system/list.rs +++ /dev/null @@ -1,183 +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`. - -//! New in version 3.10 -//! -//! This call returns the list of systems that are available to be scoped to -//! based on the X-Auth-Token provided in the request. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_system` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 System. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/system".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("system".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "system" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/system".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "system": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/system".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "system": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/token/create.rs b/openstack_sdk/src/api/identity/v3/auth/token/create.rs deleted file mode 100644 index 782a1a572..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/token/create.rs +++ /dev/null @@ -1,562 +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`. - -//! Authenticates an identity and generates a token. Uses the password -//! authentication method. Authorization is unscoped. -//! -//! The request body must include a payload that specifies the authentication -//! method, which is `password`, and the user, by ID or name, and password -//! credentials. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::serialize_sensitive_optional_string; -use openstack_sdk_core::api::common::serialize_sensitive_string; -use secrecy::SecretString; -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `domain` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - /// User Domain ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// User Domain Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// A user object, required if an application credential is identified by name -/// and not ID. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// An application credential object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ApplicationCredential<'a> { - /// The ID of the application credential used for authentication. If not - /// provided, the application credential must be identified by its name and - /// its owning user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The name of the application credential used for authentication. If - /// provided, must be accompanied by a user object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The secret for authenticating the application credential. - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) secret: SecretString, - - /// A user object, required if an application credential is identified by - /// name and not ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Methods { - #[serde(rename = "application_credential")] - ApplicationCredential, - #[serde(rename = "password")] - Password, - #[serde(rename = "token")] - Token, - #[serde(rename = "totp")] - Totp, -} - -/// A `user` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PasswordUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The ID of the user. Required if you do not specify the user name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name. Required if you do not specify the ID of the user. If - /// you specify the user name, you must also specify the domain, by ID or - /// name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// User Password - #[serde( - serialize_with = "serialize_sensitive_optional_string", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) password: Option, -} - -/// The `password` object, contains the authentication information. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Password<'a> { - /// A `user` object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -/// A `token` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Token { - /// Authorization Token value - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) id: SecretString, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct TotpUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// MFA passcode - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) passcode: SecretString, -} - -/// Multi Factor Authentication information -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Totp<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) user: TotpUser<'a>, -} - -/// An `identity` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Identity<'a> { - /// An application credential object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) application_credential: Option>, - - /// The authentication method. For password authentication, specify - /// `password`. - #[serde()] - #[builder(setter(into))] - pub(crate) methods: Vec, - - /// The `password` object, contains the authentication information. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) password: Option>, - - /// A `token` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token: Option, - - /// Multi Factor Authentication information - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) totp: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct OsTrustTrust<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ScopeDomain<'a> { - /// Domain id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Domain name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ProjectDomain<'a> { - /// Project domain Id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Project domain Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Project<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// Project Id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Project Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct System { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all: Option, -} - -/// The authorization scope, including the system (Since v3.10), a project, or -/// a domain (Since v3.4). If multiple scopes are specified in the same request -/// (e.g. project and domain or domain and system) an HTTP 400 Bad Request will -/// be returned, as a token cannot be simultaneously scoped to multiple -/// authorization targets. An ID is sufficient to uniquely identify a project -/// but if a project is specified by name, then the domain of the project must -/// also be specified in order to uniquely identify the project by name. A -/// domain scope may be specified by either the domain’s ID or name with -/// equivalent results. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Scope<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(rename = "OS-TRUST:trust", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) os_trust_trust: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) system: Option, -} - -/// An `auth` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Auth<'a> { - /// An `identity` object. - #[serde()] - #[builder(setter(into))] - pub(crate) identity: Identity<'a>, - - /// The authorization scope, including the system (Since v3.10), a project, - /// or a domain (Since v3.4). If multiple scopes are specified in the same - /// request (e.g. project and domain or domain and system) an HTTP 400 Bad - /// Request will be returned, as a token cannot be simultaneously scoped to - /// multiple authorization targets. An ID is sufficient to uniquely - /// identify a project but if a project is specified by name, then the - /// domain of the project must also be specified in order to uniquely - /// identify the project by name. A domain scope may be specified by either - /// the domain’s ID or name with equivalent results. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) scope: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `auth` object. - #[builder(setter(into))] - pub(crate) auth: Auth<'a>, - - #[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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("auth", serde_json::to_value(&self.auth)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/tokens".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/tokens".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/token/delete.rs b/openstack_sdk/src/api/identity/v3/auth/token/delete.rs deleted file mode 100644 index 48285dfa4..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/token/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Revokes a token. -//! -//! This call is similar to the HEAD `/auth/tokens` call except that the -//! `X-Subject-Token` token is immediately not valid, regardless of the -//! `expires_at` attribute value. An additional `X-Auth-Token` is not required. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path("/auth/tokens".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path("/auth/tokens".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/token/get.rs b/openstack_sdk/src/api/identity/v3/auth/token/get.rs deleted file mode 100644 index d794f165f..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/token/get.rs +++ /dev/null @@ -1,188 +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`. - -//! Validates and shows information for a token, including its expiration date -//! and authorization scope. -//! -//! Pass your own token in the `X-Auth-Token` request header. -//! -//! Pass the token that you want to validate in the `X-Subject-Token` request -//! header. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/tokens".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/tokens".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/token/head.rs b/openstack_sdk/src/api/identity/v3/auth/token/head.rs deleted file mode 100644 index 25bbff59d..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/token/head.rs +++ /dev/null @@ -1,180 +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`. - -//! Validates a token. -//! -//! This call is similar to `GET /auth/tokens` but no response body is provided -//! even in the `X-Subject-Token` header. -//! -//! The Identity API returns the same response as when the subject token was -//! issued by `POST /auth/tokens` even if an error occurs because the token is -//! not valid. An HTTP `204` response code indicates that the `X-Subject-Token` -//! is valid. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/tokens".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/tokens".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked/get.rs b/openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked/get.rs deleted file mode 100644 index d94e5a60c..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked/get.rs +++ /dev/null @@ -1,177 +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`. - -//! Lists revoked PKI tokens. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/tokens/OS-PKI/revoked` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Revoked. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auth/tokens/OS-PKI/revoked".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/tokens/OS-PKI/revoked".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auth/tokens/OS-PKI/revoked".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked/head.rs b/openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked/head.rs deleted file mode 100644 index 45b2e5d27..000000000 --- a/openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked/head.rs +++ /dev/null @@ -1,171 +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`. - -//! Deprecated; get revoked token list. -//! -//! GET/HEAD /v3/auth/tokens/OS-PKI/revoked -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Revoked. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "auth/tokens/OS-PKI/revoked".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/tokens/OS-PKI/revoked".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/auth/tokens/OS-PKI/revoked".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/credential/create.rs b/openstack_sdk/src/api/identity/v3/credential/create.rs deleted file mode 100644 index 919a41546..000000000 --- a/openstack_sdk/src/api/identity/v3/credential/create.rs +++ /dev/null @@ -1,294 +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`. - -//! Creates a credential. -//! -//! The following example shows how to create an EC2-style credential. The -//! credential blob is a string that contains a JSON-serialized dictionary with -//! the `access` and `secret` keys. This format is required when you specify -//! the `ec2` type. To specify other credentials, such as `access_key`, change -//! the type and contents of the data blob. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/credentials` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `credential` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Credential<'a> { - /// The credential itself, as a serialized blob. - #[serde()] - #[builder(setter(into))] - pub(crate) blob: Cow<'a, str>, - - /// The UUID for the credential. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The ID for the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>>, - - /// The credential type, such as `ec2` or `cert`. The implementation - /// determines the list of supported types. - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, - - /// The ID of the user who owns the credential. - #[serde()] - #[builder(setter(into))] - pub(crate) user_id: Cow<'a, str>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> CredentialBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `credential` object. - #[builder(setter(into))] - pub(crate) credential: Credential<'a>, - - #[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 Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "credentials".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("credential", serde_json::to_value(&self.credential)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("credential".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .credential( - CredentialBuilder::default() - ._type("foo") - .blob("foo") - .user_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .credential( - CredentialBuilder::default() - ._type("foo") - .blob("foo") - .user_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "credential" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/credentials".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credential": {} })); - }); - - let endpoint = Request::builder() - .credential( - CredentialBuilder::default() - ._type("foo") - .blob("foo") - .user_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/credentials".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credential": {} })); - }); - - let endpoint = Request::builder() - .credential( - CredentialBuilder::default() - ._type("foo") - .blob("foo") - .user_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/credential/delete.rs b/openstack_sdk/src/api/identity/v3/credential/delete.rs deleted file mode 100644 index 5d6930dd7..000000000 --- a/openstack_sdk/src/api/identity/v3/credential/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes a credential. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/credential` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { - /// Add a single header to the Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("credentials/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/credentials/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/credentials/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/credential/get.rs b/openstack_sdk/src/api/identity/v3/credential/get.rs deleted file mode 100644 index 52758da8e..000000000 --- a/openstack_sdk/src/api/identity/v3/credential/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a credential. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/credential` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { - /// Add a single header to the Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("credentials/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("credential".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "credential" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/credentials/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credential": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/credentials/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credential": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/credential/head.rs b/openstack_sdk/src/api/identity/v3/credential/head.rs deleted file mode 100644 index 4a673dc46..000000000 --- a/openstack_sdk/src/api/identity/v3/credential/head.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`. - -//! Retrieve existing credentials. -//! -//! GET /v3/credentials/{credential_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { - /// Add a single header to the Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("credentials/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/credentials/{id}", id = "id",)); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().id("id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/credentials/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/credential/list.rs b/openstack_sdk/src/api/identity/v3/credential/list.rs deleted file mode 100644 index 6e884f56c..000000000 --- a/openstack_sdk/src/api/identity/v3/credential/list.rs +++ /dev/null @@ -1,198 +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`. - -//! Lists all credentials. -//! -//! Optionally, you can include the `user_id` or `type` query parameter in the -//! URI to filter the response by a user or credential type. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/credentials` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The credential type, such as ec2 or cert. The implementation determines - /// the list of supported types. - #[builder(default, setter(into))] - _type: Option>, - - /// Filters the response by a user ID. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "credentials".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("type", self._type.as_ref()); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("credentials".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "credentials" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/credentials".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credentials": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/credentials".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credentials": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/credential/set.rs b/openstack_sdk/src/api/identity/v3/credential/set.rs deleted file mode 100644 index 0ef061cde..000000000 --- a/openstack_sdk/src/api/identity/v3/credential/set.rs +++ /dev/null @@ -1,261 +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`. - -//! Updates a credential. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/credential` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `credential` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Credential<'a> { - /// The credential itself, as a serialized blob. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) blob: Option>, - - /// The ID for the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>>, - - /// The credential type, such as `ec2` or `cert`. The implementation - /// determines the list of supported types. - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _type: Option>, - - /// The ID of the user who owns the credential. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user_id: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> CredentialBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `credential` object. - #[builder(setter(into))] - pub(crate) credential: Credential<'a>, - - /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { - /// Add a single header to the Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("credentials/{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("credential", serde_json::to_value(&self.credential)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("credential".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .credential(CredentialBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .credential(CredentialBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "credential" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/credentials/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credential": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .credential(CredentialBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/credentials/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "credential": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .credential(CredentialBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/default.rs b/openstack_sdk/src/api/identity/v3/domain/config/default.rs deleted file mode 100644 index 3e519cd13..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/default.rs +++ /dev/null @@ -1,181 +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`. - -//! The default configuration settings for the options that can be overridden -//! can be retrieved. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Config. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "domains/config/default".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/domains/config/default".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/domains/config/default".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/delete_all.rs b/openstack_sdk/src/api/identity/v3/domain/config/delete_all.rs deleted file mode 100644 index 8b044cbe6..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/delete_all.rs +++ /dev/null @@ -1,194 +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`. - -//! Deletes a domain configuration. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_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 Config. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config", - domain_id = self.domain_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().domain_id("domain_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_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() - .domain_id("domain_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/default.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/default.rs deleted file mode 100644 index 2fe039a33..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/default.rs +++ /dev/null @@ -1,193 +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`. - -//! Reads the default configuration settings for a specific group. -//! -//! The API supports only the `identity` and `ldap` groups. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group parameter for /v3/domains/config/{group}/{option}/default API - #[builder(default, setter(into))] - group: 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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/config/{group}/default", - group = self.group.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/domains/config/{group}/default", group = "group",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder().group("group").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/domains/config/{group}/default", group = "group",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .group("group") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/delete.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/delete.rs deleted file mode 100644 index 13aabfff9..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/delete.rs +++ /dev/null @@ -1,211 +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`. - -//! Deletes a domain group configuration. -//! -//! The API supports only the `identity` and `ldap` groups. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: 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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config/{group}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/get.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/get.rs deleted file mode 100644 index 3b32ca3cd..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/get.rs +++ /dev/null @@ -1,211 +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`. - -//! Shows details for a domain group configuration. -//! -//! The API supports only the `identity` and `ldap` groups. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: 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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config/{group}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/head.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/head.rs deleted file mode 100644 index 22b7ccf62..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/head.rs +++ /dev/null @@ -1,205 +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`. - -//! Check if config option exists. -//! -//! GET/HEAD /v3/domains/{domain_id}/config GET/HEAD -//! /v3/domains/{domain_id}/config/{group} GET/HEAD -//! /v3/domains/{domain_id}/config/{group}/{option} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: 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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/config/{group}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/option/default.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/option/default.rs deleted file mode 100644 index 0a1fa58aa..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/option/default.rs +++ /dev/null @@ -1,212 +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`. - -//! Reads the default configuration setting for an option within a group. -//! -//! The API supports only the `identity` and `ldap` groups. For the `ldap` -//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, -//! a valid value is `driver`. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group parameter for /v3/domains/config/{group}/{option}/default API - #[builder(default, setter(into))] - group: Cow<'a, str>, - - /// option parameter for /v3/domains/config/{group}/{option}/default API - #[builder(default, setter(into))] - option: 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 Option. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/config/{group}/{option}/default", - group = self.group.as_ref(), - option = self.option.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/config/{group}/{option}/default", - group = "group", - option = "option", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .group("group") - .option("option") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/config/{group}/{option}/default", - group = "group", - option = "option", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .group("group") - .option("option") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/option/delete.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/option/delete.rs deleted file mode 100644 index 95cf95638..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/option/delete.rs +++ /dev/null @@ -1,223 +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`. - -//! Deletes a domain group option configuration. -//! -//! The API supports only the `identity` and `ldap` groups. For the `ldap` -//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, -//! a valid value is `driver`. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: Cow<'a, str>, - - /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - option: 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 Option. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config/{group}/{option}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - option = self.option.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/option/get.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/option/get.rs deleted file mode 100644 index 2f235a351..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/option/get.rs +++ /dev/null @@ -1,223 +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`. - -//! Shows details for a domain group option configuration. -//! -//! The API supports only the `identity` and `ldap` groups. For the `ldap` -//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, -//! a valid value is `driver`. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: Cow<'a, str>, - - /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - option: 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 Option. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config/{group}/{option}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - option = self.option.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/option/head.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/option/head.rs deleted file mode 100644 index 5e40e896e..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/option/head.rs +++ /dev/null @@ -1,215 +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`. - -//! Check if config option exists. -//! -//! GET/HEAD /v3/domains/{domain_id}/config GET/HEAD -//! /v3/domains/{domain_id}/config/{group} GET/HEAD -//! /v3/domains/{domain_id}/config/{group}/{option} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: Cow<'a, str>, - - /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - option: 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 Option. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/config/{group}/{option}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - option = self.option.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/option/set.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/option/set.rs deleted file mode 100644 index 4d7732efa..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/option/set.rs +++ /dev/null @@ -1,261 +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`. - -//! Updates a domain group option configuration. -//! -//! The API supports only the `identity` and `ldap` groups. For the `ldap` -//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, -//! a valid value is `driver`. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `config` object. - #[builder(private, setter(into, name = "_config"))] - pub(crate) config: BTreeMap, Value>, - - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: Cow<'a, str>, - - /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - option: 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> { - /// A `config` object. - pub fn config(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.config - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Option. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config/{group}/{option}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - option = self.option.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("config", serde_json::to_value(&self.config)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .config(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .config(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH).path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .config(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!( - "/domains/{domain_id}/config/{group}/{option}", - domain_id = "domain_id", - group = "group", - option = "option", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .option("option") - .config(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/set.rs b/openstack_sdk/src/api/identity/v3/domain/config/group/set.rs deleted file mode 100644 index 6b83851a4..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/group/set.rs +++ /dev/null @@ -1,274 +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`. - -//! Updates a domain group configuration. -//! -//! The API supports only the `identity` and `ldap` groups. If you try to set -//! configuration options for other groups, this call fails with the -//! `Forbidden (403)` response code. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `config` object. - #[builder(private, setter(into, name = "_config"))] - pub(crate) config: BTreeMap, BTreeMap, Value>>, - - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API - #[builder(default, setter(into))] - group: 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> { - /// A `config` object. - pub fn config(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Iterator, - K1: Into>, - V1: Into, - { - self.config - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| { - ( - k.into(), - BTreeMap::from_iter(v.into_iter().map(|(k1, v1)| (k1.into(), v1.into()))), - ) - })); - self - } - - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config/{group}", - domain_id = self.domain_id.as_ref(), - group = self.group.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("config", serde_json::to_value(&self.config)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())) - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())) - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH).path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!( - "/domains/{domain_id}/config/{group}", - domain_id = "domain_id", - group = "group", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group("group") - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/head.rs b/openstack_sdk/src/api/identity/v3/domain/config/head.rs deleted file mode 100644 index 649abd41b..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/head.rs +++ /dev/null @@ -1,190 +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`. - -//! Check if config option exists. -//! -//! GET/HEAD /v3/domains/{domain_id}/config GET/HEAD -//! /v3/domains/{domain_id}/config/{group} GET/HEAD -//! /v3/domains/{domain_id}/config/{group}/{option} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_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 Config. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/config", - domain_id = self.domain_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().domain_id("domain_id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/list.rs b/openstack_sdk/src/api/identity/v3/domain/config/list.rs deleted file mode 100644 index a8749995e..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/list.rs +++ /dev/null @@ -1,197 +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`. - -//! Shows details for a domain configuration. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_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 Config. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config", - domain_id = self.domain_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder().domain_id("domain_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/replace.rs b/openstack_sdk/src/api/identity/v3/domain/config/replace.rs deleted file mode 100644 index ec65e2de1..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/replace.rs +++ /dev/null @@ -1,261 +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`. - -//! Creates a domain configuration. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `config` object. - #[builder(private, setter(into, name = "_config"))] - pub(crate) config: BTreeMap, BTreeMap, Value>>, - - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_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> { - /// A `config` object. - pub fn config(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Iterator, - K1: Into>, - V1: Into, - { - self.config - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| { - ( - k.into(), - BTreeMap::from_iter(v.into_iter().map(|(k1, v1)| (k1.into(), v1.into()))), - ) - })); - self - } - - /// Add a single header to the Config. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/config", - domain_id = self.domain_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("config", serde_json::to_value(&self.config)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())) - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())) - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/set.rs b/openstack_sdk/src/api/identity/v3/domain/config/set.rs deleted file mode 100644 index 81b84fccd..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/config/set.rs +++ /dev/null @@ -1,261 +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`. - -//! Updates a domain configuration. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `config` object. - #[builder(private, setter(into, name = "_config"))] - pub(crate) config: BTreeMap, BTreeMap, Value>>, - - /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} - /// API - #[builder(default, setter(into))] - domain_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> { - /// A `config` object. - pub fn config(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Iterator, - K1: Into>, - V1: Into, - { - self.config - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| { - ( - k.into(), - BTreeMap::from_iter(v.into_iter().map(|(k1, v1)| (k1.into(), v1.into()))), - ) - })); - self - } - - /// Add a single header to the Config. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/config", - domain_id = self.domain_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("config", serde_json::to_value(&self.config)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("config".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())) - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())) - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "config" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH).path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!( - "/domains/{domain_id}/config", - domain_id = "domain_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "config": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .config( - BTreeMap::>::new() - .into_iter() - .map(|(k, v)| (k, v.into_iter())), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/create.rs b/openstack_sdk/src/api/identity/v3/domain/create.rs deleted file mode 100644 index 126323964..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/create.rs +++ /dev/null @@ -1,263 +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`. - -//! Creates a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domains` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The resource options for the domain. Available resource options are -/// `immutable`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) immutable: Option, -} - -/// A `domain` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - /// The description of the domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// If set to `true`, domain is created enabled. If set to `false`, domain - /// is created disabled. The default is `true`. - /// - /// Users can only authorize against an enabled domain (and any of its - /// projects). In addition, users can only authenticate if the domain that - /// owns them is also enabled. Disabling a domain prevents both of these - /// things. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The ID of the domain. A domain created this way will not use an - /// auto-generated ID, but will use the ID passed in instead. Identifiers - /// passed in this way must conform to the existing ID generation scheme: - /// UUID4 without dashes. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) explicit_domain_id: Option>, - - /// The name of the domain. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The resource options for the domain. Available resource options are - /// `immutable`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `domain` object - #[builder(setter(into))] - pub(crate) domain: Domain<'a>, - - #[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 Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "domains".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("domain", serde_json::to_value(&self.domain)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("domain".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .domain(DomainBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .domain(DomainBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "domain" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/domains".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domain": {} })); - }); - - let endpoint = Request::builder() - .domain(DomainBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/domains".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domain": {} })); - }); - - let endpoint = Request::builder() - .domain(DomainBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/delete.rs b/openstack_sdk/src/api/identity/v3/domain/delete.rs deleted file mode 100644 index 8bd5d2b37..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/delete.rs +++ /dev/null @@ -1,192 +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`. - -//! Deletes a domain. To minimize the risk of accidentally deleting a domain, -//! you must first disable the domain by using the update domain method. -//! -//! When you delete a domain, this call also deletes all entities owned by it, -//! such as users, groups, and projects, and any credentials and granted roles -//! that relate to those entities. -//! -//! If you try to delete an enabled domain, this call returns the -//! `Forbidden (403)` response code. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { - /// Add a single header to the Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("domains/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/domains/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/domains/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/find.rs b/openstack_sdk/src/api/identity/v3/domain/find.rs deleted file mode 100644 index efff32468..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::identity::v3::domain::{get as Get, list as List}; - -/// Find for domain 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/get.rs b/openstack_sdk/src/api/identity/v3/domain/get.rs deleted file mode 100644 index 27546559c..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domains` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { - /// Add a single header to the Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("domains/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("domain".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "domain" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/domains/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domain": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/domains/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domain": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/group/role/delete.rs b/openstack_sdk/src/api/identity/v3/domain/group/role/delete.rs deleted file mode 100644 index 069cdccf0..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/group/role/delete.rs +++ /dev/null @@ -1,217 +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`. - -//! Unassigns a role from a group on a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_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() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/group/role/get.rs b/openstack_sdk/src/api/identity/v3/domain/group/role/get.rs deleted file mode 100644 index fa9b90373..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/group/role/get.rs +++ /dev/null @@ -1,216 +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`. - -//! Check if a group has a specific role on a domain. -//! -//! GET/HEAD /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_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() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/group/role/head.rs b/openstack_sdk/src/api/identity/v3/domain/group/role/head.rs deleted file mode 100644 index c46aac5e7..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/group/role/head.rs +++ /dev/null @@ -1,212 +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`. - -//! Validates that a group has a role assignment on a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_id", - id = "id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/group/role/list.rs b/openstack_sdk/src/api/identity/v3/domain/group/role/list.rs deleted file mode 100644 index 52e20f8b5..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/group/role/list.rs +++ /dev/null @@ -1,210 +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`. - -//! Lists role assignments for a group on a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_roles` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/groups/{group_id}/roles", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("roles".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "roles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/{domain_id}/groups/{group_id}/roles", - domain_id = "domain_id", - group_id = "group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/{domain_id}/groups/{group_id}/roles", - domain_id = "domain_id", - group_id = "group_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/group/role/set.rs b/openstack_sdk/src/api/identity/v3/domain/group/role/set.rs deleted file mode 100644 index 02d126a92..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/group/role/set.rs +++ /dev/null @@ -1,217 +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`. - -//! Assigns a role to a group on a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/domains/{domain_id}/groups/{group_id}/roles/{id}", - domain_id = "domain_id", - group_id = "group_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() - .domain_id("domain_id") - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/head.rs b/openstack_sdk/src/api/identity/v3/domain/head.rs deleted file mode 100644 index 80f86ecd9..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/head.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`. - -//! Get domain -//! -//! GET/HEAD /v3/domains/{domain_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { - /// Add a single header to the Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("domains/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/domains/{id}", id = "id",)); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().id("id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/domains/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/list.rs b/openstack_sdk/src/api/identity/v3/domain/list.rs deleted file mode 100644 index 21fec91df..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/list.rs +++ /dev/null @@ -1,207 +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`. - -//! Lists all domains. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domains` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// If set to true, then only domains that are enabled will be returned, if - /// set to false only that are disabled will be returned. Any value other - /// than 0, including no value, will be interpreted as true. - #[builder(default)] - enabled: Option, - - #[builder(default)] - limit: Option, - - /// ID of the last fetched entry - #[builder(default, setter(into))] - marker: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "domains".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("enabled", self.enabled); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("domains".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "domains" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/domains".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domains": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/domains".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domains": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/set.rs b/openstack_sdk/src/api/identity/v3/domain/set.rs deleted file mode 100644 index fc778e4e9..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/set.rs +++ /dev/null @@ -1,263 +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`. - -//! Updates a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The resource options for the domain. Available resource options are -/// `immutable`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) immutable: Option, -} - -/// A `domain` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - /// The new description of the domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// If set to `true`, domain is enabled. If set to `false`, domain is - /// disabled. The default is `true`. - /// - /// Users can only authorize against an enabled domain (and any of its - /// projects). In addition, users can only authenticate if the domain that - /// owns them is also enabled. Disabling a domain prevents both of these - /// things. When you disable a domain, all tokens that are authorized for - /// that domain become invalid. However, if you reenable the domain, these - /// tokens become valid again, providing that they haven’t expired. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The new name of the domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The resource options for the domain. Available resource options are - /// `immutable`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `domain` object - #[builder(setter(into))] - pub(crate) domain: Domain<'a>, - - /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { - /// Add a single header to the Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("domains/{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("domain", serde_json::to_value(&self.domain)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("domain".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .domain(DomainBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .domain(DomainBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "domain" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/domains/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domain": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .domain(DomainBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/domains/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domain": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .domain(DomainBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/user/role/delete.rs b/openstack_sdk/src/api/identity/v3/domain/user/role/delete.rs deleted file mode 100644 index b165801d9..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/user/role/delete.rs +++ /dev/null @@ -1,217 +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`. - -//! Unassigns a role from a user on a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_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() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/user/role/get.rs b/openstack_sdk/src/api/identity/v3/domain/user/role/get.rs deleted file mode 100644 index f71eae14c..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/user/role/get.rs +++ /dev/null @@ -1,216 +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`. - -//! Check if a user has a specific role on the domain. -//! -//! GET/HEAD /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_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() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/user/role/head.rs b/openstack_sdk/src/api/identity/v3/domain/user/role/head.rs deleted file mode 100644 index eecb07411..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/user/role/head.rs +++ /dev/null @@ -1,212 +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`. - -//! Validates that a user has a role assignment on a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/user/role/list.rs b/openstack_sdk/src/api/identity/v3/domain/user/role/list.rs deleted file mode 100644 index 16e66e3d9..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/user/role/list.rs +++ /dev/null @@ -1,210 +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`. - -//! Lists role assignments for a user on a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_user_roles` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "domains/{domain_id}/users/{user_id}/roles", - domain_id = self.domain_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("roles".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "roles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/domains/{domain_id}/users/{user_id}/roles", - domain_id = "domain_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/domains/{domain_id}/users/{user_id}/roles", - domain_id = "domain_id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/domain/user/role/set.rs b/openstack_sdk/src/api/identity/v3/domain/user/role/set.rs deleted file mode 100644 index ec11f23af..000000000 --- a/openstack_sdk/src/api/identity/v3/domain/user/role/set.rs +++ /dev/null @@ -1,217 +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`. - -//! Assigns a role to a user on a domain. -//! -//! Relationship: -//! `https://developer.openstack.org/api-ref/identity/v3/index.html#assign-role-to-user-on-domain` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = self.domain_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/domains/{domain_id}/users/{user_id}/roles/{id}", - domain_id = "domain_id", - id = "id", - user_id = "user_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() - .domain_id("domain_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/ec2token/create.rs b/openstack_sdk/src/api/identity/v3/ec2token/create.rs deleted file mode 100644 index 9d7b9576e..000000000 --- a/openstack_sdk/src/api/identity/v3/ec2token/create.rs +++ /dev/null @@ -1,204 +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`. - -//! Authenticate ec2 token. -//! -//! POST /v3/ec2tokens -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Ec2Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "ec2tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/ec2tokens".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/ec2tokens".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/ec2token/get.rs b/openstack_sdk/src/api/identity/v3/ec2token/get.rs deleted file mode 100644 index fb8fdb357..000000000 --- a/openstack_sdk/src/api/identity/v3/ec2token/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/ec2tokens -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Ec2Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "ec2tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/ec2tokens".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/ec2tokens".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/ec2token/head.rs b/openstack_sdk/src/api/identity/v3/ec2token/head.rs deleted file mode 100644 index 8273eeff6..000000000 --- a/openstack_sdk/src/api/identity/v3/ec2token/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/ec2tokens -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Ec2Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "ec2tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/ec2tokens".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/ec2tokens".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/create.rs b/openstack_sdk/src/api/identity/v3/endpoint/create.rs deleted file mode 100644 index 91fc03eb0..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/create.rs +++ /dev/null @@ -1,328 +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`. - -//! Creates an endpoint. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoints` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Interface { - #[serde(rename = "admin")] - Admin, - #[serde(rename = "internal")] - Internal, - #[serde(rename = "public")] - Public, -} - -/// An `endpoint` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Endpoint<'a> { - /// The endpoint description. It is returned only when set on the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Defines whether the endpoint appears in the service catalog: - `false`. - /// The endpoint does not appear in the service catalog. - `true`. The - /// endpoint appears in the service catalog. Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The endpoint ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The interface type, which describes the visibility of the endpoint. - /// Value is: - `public`. Visible by end users on a publicly available - /// network interface. - `internal`. Visible by end users on an unmetered - /// internal network interface. - `admin`. Visible by administrative users - /// on a secure network interface. - #[serde()] - #[builder()] - pub(crate) interface: Interface, - - /// (Deprecated) The endpoint name. The field will only be returned in - /// responses when set on the resource. - /// - /// This field is deprecated as it provides no value. Endpoints are better - /// described by the combination of service, region and interface they - /// describe or by their ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// (Deprecated in v3.2) The geographic location of the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region: Option>>, - - /// (Since v3.2) The ID of the region that contains the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region_id: Option>>, - - /// The UUID of the service to which the endpoint belongs. - #[serde()] - #[builder(setter(into))] - pub(crate) service_id: Cow<'a, str>, - - /// The endpoint URL. - #[serde()] - #[builder(setter(into))] - pub(crate) url: Cow<'a, str>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> EndpointBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `endpoint` object. - #[builder(setter(into))] - pub(crate) endpoint: Endpoint<'a>, - - #[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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "endpoints".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("endpoint", serde_json::to_value(&self.endpoint)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoint".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .endpoint( - EndpointBuilder::default() - .interface(Interface::Admin) - .service_id("foo") - .url("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .endpoint( - EndpointBuilder::default() - .interface(Interface::Admin) - .service_id("foo") - .url("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "endpoint" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/endpoints".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint": {} })); - }); - - let endpoint = Request::builder() - .endpoint( - EndpointBuilder::default() - .interface(Interface::Admin) - .service_id("foo") - .url("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/endpoints".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint": {} })); - }); - - let endpoint = Request::builder() - .endpoint( - EndpointBuilder::default() - .interface(Interface::Admin) - .service_id("foo") - .url("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/delete.rs b/openstack_sdk/src/api/identity/v3/endpoint/delete.rs deleted file mode 100644 index 3bcbe2adf..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes an endpoint. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoint` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for /v3/endpoints/{endpoint_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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("endpoints/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/endpoints/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/endpoints/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/get.rs b/openstack_sdk/src/api/identity/v3/endpoint/get.rs deleted file mode 100644 index 66ebd14b6..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for an endpoint. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoints` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for /v3/endpoints/{endpoint_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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("endpoints/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoint".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "endpoint" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/endpoints/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/endpoints/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/head.rs b/openstack_sdk/src/api/identity/v3/endpoint/head.rs deleted file mode 100644 index 9fb8ac10d..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/head.rs +++ /dev/null @@ -1,194 +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`. - -//! List all endpoints. -//! -//! GET /v3/endpoints -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The interface type, which describes the visibility of the endpoint. - /// Value is: -public. Visible by end users on a publicly available network - /// interface. -internal. Visible by end users on an unmetered internal - /// network interface.-admin. Visible by administrative users on a secure - /// network interface. - #[builder(default, setter(into))] - interface: Option>, - - /// (Since v3.2) The ID of the region that contains the service endpoint. - #[builder(default, setter(into))] - region_id: Option>, - - /// The UUID of the service to which the endpoint belongs - #[builder(default, setter(into))] - service_id: 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> { - /// Add a single header to the Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "endpoints".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("interface", self.interface.as_ref()); - params.push_opt("region_id", self.region_id.as_ref()); - params.push_opt("service_id", self.service_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/endpoints".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/endpoints".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/list.rs b/openstack_sdk/src/api/identity/v3/endpoint/list.rs deleted file mode 100644 index ed8e1eb52..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/list.rs +++ /dev/null @@ -1,203 +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`. - -//! Lists all available endpoints. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoints` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The interface type, which describes the visibility of the endpoint. - /// Value is: -public. Visible by end users on a publicly available network - /// interface. -internal. Visible by end users on an unmetered internal - /// network interface.-admin. Visible by administrative users on a secure - /// network interface. - #[builder(default, setter(into))] - interface: Option>, - - /// (Since v3.2) The ID of the region that contains the service endpoint. - #[builder(default, setter(into))] - region_id: Option>, - - /// The UUID of the service to which the endpoint belongs - #[builder(default, setter(into))] - service_id: 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> { - /// Add a single header to the Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "endpoints".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("interface", self.interface.as_ref()); - params.push_opt("region_id", self.region_id.as_ref()); - params.push_opt("service_id", self.service_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoints".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "endpoints" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/endpoints".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoints": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/endpoints".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoints": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy/get.rs b/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy/get.rs deleted file mode 100644 index d61859ecf..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy/get.rs +++ /dev/null @@ -1,194 +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 operation on /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy API - #[builder(default, setter(into))] - endpoint_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 Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", - endpoint_id = self.endpoint_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", - endpoint_id = "endpoint_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .endpoint_id("endpoint_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", - endpoint_id = "endpoint_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() - .endpoint_id("endpoint_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy/head.rs b/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy/head.rs deleted file mode 100644 index edafa7687..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy/head.rs +++ /dev/null @@ -1,189 +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`. - -//! HEAD operation on /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy API - #[builder(default, setter(into))] - endpoint_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 Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", - endpoint_id = self.endpoint_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", - endpoint_id = "endpoint_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_id("endpoint_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", - endpoint_id = "endpoint_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_id("endpoint_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/set.rs b/openstack_sdk/src/api/identity/v3/endpoint/set.rs deleted file mode 100644 index 2c850b400..000000000 --- a/openstack_sdk/src/api/identity/v3/endpoint/set.rs +++ /dev/null @@ -1,301 +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`. - -//! Updates an endpoint. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoint` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Interface { - #[serde(rename = "admin")] - Admin, - #[serde(rename = "internal")] - Internal, - #[serde(rename = "public")] - Public, -} - -/// An `endpoint` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Endpoint<'a> { - /// The endpoint description. It is returned only when set on the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Indicates whether the endpoint appears in the service catalog: - - /// `false`. The endpoint does not appear in the service catalog. - `true`. - /// The endpoint appears in the service catalog. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The interface type, which describes the visibility of the endpoint. - /// Value is: - `public`. Visible by end users on a publicly available - /// network interface. - `internal`. Visible by end users on an unmetered - /// internal network interface. - `admin`. Visible by administrative users - /// on a secure network interface. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) interface: Option, - - /// (Deprecated) The endpoint name. The field will only be returned in - /// responses when set on the resource. - /// - /// This field is deprecated as it provides no value. Endpoints are better - /// described by the combination of service, region and interface they - /// describe or by their ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// (Deprecated in v3.2) The geographic location of the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region: Option>>, - - /// (Since v3.2) The ID of the region that contains the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region_id: Option>>, - - /// The UUID of the service to which the endpoint belongs. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_id: Option>, - - /// The endpoint URL. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> EndpointBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `endpoint` object. - #[builder(setter(into))] - pub(crate) endpoint: Endpoint<'a>, - - /// endpoint_id parameter for /v3/endpoints/{endpoint_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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("endpoints/{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("endpoint", serde_json::to_value(&self.endpoint)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoint".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .endpoint(EndpointBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .endpoint(EndpointBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "endpoint" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/endpoints/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .endpoint(EndpointBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/endpoints/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .endpoint(EndpointBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/create.rs b/openstack_sdk/src/api/identity/v3/group/create.rs deleted file mode 100644 index 6e56edef2..000000000 --- a/openstack_sdk/src/api/identity/v3/group/create.rs +++ /dev/null @@ -1,252 +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`. - -//! Creates a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/groups` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `group` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Group<'a> { - /// The description of the group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the domain of the group. If the domain ID is not provided in - /// the request, the Identity service will attempt to pull the domain ID - /// from the token used in the request. Note that this requires the use of - /// a domain-scoped token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>, - - /// The name of the group. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> GroupBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `group` object - #[builder(setter(into))] - pub(crate) group: Group<'a>, - - #[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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("group", serde_json::to_value(&self.group)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("group".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .group(GroupBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .group(GroupBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .group(GroupBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .group(GroupBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/delete.rs b/openstack_sdk/src/api/identity/v3/group/delete.rs deleted file mode 100644 index 9bff83e0b..000000000 --- a/openstack_sdk/src/api/identity/v3/group/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/group` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/groups/{group_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<'a> RequestBuilder<'a> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/groups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/groups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/find.rs b/openstack_sdk/src/api/identity/v3/group/find.rs deleted file mode 100644 index b89f031c8..000000000 --- a/openstack_sdk/src/api/identity/v3/group/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::identity::v3::group::{get as Get, list as List}; - -/// Find for group 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate group in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // group 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") - && let Some(name) = name_as_val.as_str() - && 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/identity/v3/group/get.rs b/openstack_sdk/src/api/identity/v3/group/get.rs deleted file mode 100644 index d378e1006..000000000 --- a/openstack_sdk/src/api/identity/v3/group/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/group` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/groups/{group_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<'a> RequestBuilder<'a> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("group".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/head.rs b/openstack_sdk/src/api/identity/v3/group/head.rs deleted file mode 100644 index 8958be499..000000000 --- a/openstack_sdk/src/api/identity/v3/group/head.rs +++ /dev/null @@ -1,206 +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`. - -//! List groups. -//! -//! GET/HEAD /groups -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - #[builder(default)] - limit: Option, - - /// ID of the last fetched entry - #[builder(default, setter(into))] - marker: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: Option>, - - /// Sort direction. A valid value is asc (ascending) or desc (descending). - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts resources by attribute. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/groups".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/list.rs b/openstack_sdk/src/api/identity/v3/group/list.rs deleted file mode 100644 index cdc05ad21..000000000 --- a/openstack_sdk/src/api/identity/v3/group/list.rs +++ /dev/null @@ -1,215 +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`. - -//! Lists groups. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/groups` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - #[builder(default)] - limit: Option, - - /// ID of the last fetched entry - #[builder(default, setter(into))] - marker: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: Option>, - - /// Sort direction. A valid value is asc (ascending) or desc (descending). - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts resources by attribute. - #[builder(default, setter(into))] - sort_key: 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> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("groups".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/set.rs b/openstack_sdk/src/api/identity/v3/group/set.rs deleted file mode 100644 index 6ec8bbdc4..000000000 --- a/openstack_sdk/src/api/identity/v3/group/set.rs +++ /dev/null @@ -1,253 +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`. - -//! Updates a group. -//! -//! If the back-end driver does not support this functionality, the call -//! returns the `Not Implemented (501)` response code. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/group` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `group` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Group<'a> { - /// The new description of the group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The new name of the group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> GroupBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `group` object - #[builder(setter(into))] - pub(crate) group: Group<'a>, - - /// group_id parameter for /v3/groups/{group_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<'a> RequestBuilder<'a> { - /// Add a single header to the Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("groups/{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("group", serde_json::to_value(&self.group)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("group".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .group(GroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .group(GroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .group(GroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .group(GroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/user/delete.rs b/openstack_sdk/src/api/identity/v3/group/user/delete.rs deleted file mode 100644 index 3a54a07c6..000000000 --- a/openstack_sdk/src/api/identity/v3/group/user/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! Removes a user from a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_user` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "groups/{group_id}/users/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_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() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/user/get.rs b/openstack_sdk/src/api/identity/v3/group/user/get.rs deleted file mode 100644 index 2b97971af..000000000 --- a/openstack_sdk/src/api/identity/v3/group/user/get.rs +++ /dev/null @@ -1,204 +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`. - -//! Check if a user is in a group. -//! -//! GET/HEAD /groups/{group_id}/users/{user_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "groups/{group_id}/users/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_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() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/user/head.rs b/openstack_sdk/src/api/identity/v3/group/user/head.rs deleted file mode 100644 index ad305f124..000000000 --- a/openstack_sdk/src/api/identity/v3/group/user/head.rs +++ /dev/null @@ -1,200 +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`. - -//! Validates that a user belongs to a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_user` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "groups/{group_id}/users/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/user/list.rs b/openstack_sdk/src/api/identity/v3/group/user/list.rs deleted file mode 100644 index 8af81eabd..000000000 --- a/openstack_sdk/src/api/identity/v3/group/user/list.rs +++ /dev/null @@ -1,198 +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`. - -//! Lists the users that belong to a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_users` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// Filter results based on which user passwords have expired. The query - /// should include an operator and a timestamp with a colon (:) separating - /// the two, for example: `password_expires_at={operator}:{timestamp}`. - /// Valid operators are: `lt`, `lte`, `gt`, `gte`, `eq`, and `neq`. Valid - /// timestamps are of the form: YYYY-MM-DDTHH:mm:ssZ. - #[builder(default, setter(into))] - password_expires_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("groups/{group_id}/users", group_id = self.group_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("password_expires_at", self.password_expires_at.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("users".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "users" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/groups/{group_id}/users", group_id = "group_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "users": {} })); - }); - - let endpoint = Request::builder().group_id("group_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/groups/{group_id}/users", group_id = "group_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "users": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/group/user/set.rs b/openstack_sdk/src/api/identity/v3/group/user/set.rs deleted file mode 100644 index 6ecdca3fe..000000000 --- a/openstack_sdk/src/api/identity/v3/group/user/set.rs +++ /dev/null @@ -1,205 +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`. - -//! Adds a user to a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_user` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "groups/{group_id}/users/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/groups/{group_id}/users/{id}", - group_id = "group_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() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/create.rs b/openstack_sdk/src/api/identity/v3/limit/create.rs deleted file mode 100644 index 79496c929..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/create.rs +++ /dev/null @@ -1,268 +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`. - -//! Creates limits. It supports to create more than one limit in one request. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/limits` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Limits<'a> { - /// The limit description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The name of the domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>>, - - /// The ID for the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>>, - - /// The ID of the region that contains the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region_id: Option>>, - - /// The override limit. - #[serde()] - #[builder(setter(into))] - pub(crate) resource_limit: i32, - - /// The resource name. - #[serde()] - #[builder(setter(into))] - pub(crate) resource_name: Cow<'a, str>, - - /// The UUID of the service to which the limit belongs. - #[serde()] - #[builder(setter(into))] - pub(crate) service_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A list of `limits` objects - #[builder(setter(into))] - pub(crate) limits: Vec>, - - #[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 Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "limits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("limits", serde_json::to_value(&self.limits)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("limits".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .limits(Vec::from([LimitsBuilder::default() - .resource_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .limits(Vec::from([LimitsBuilder::default() - .resource_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "limits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/limits".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder() - .limits(Vec::from([LimitsBuilder::default() - .resource_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/limits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder() - .limits(Vec::from([LimitsBuilder::default() - .resource_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/delete.rs b/openstack_sdk/src/api/identity/v3/limit/delete.rs deleted file mode 100644 index 16d524ef0..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes a limit. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { - /// Add a single header to the Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("limits/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/limits/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/limits/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/get.rs b/openstack_sdk/src/api/identity/v3/limit/get.rs deleted file mode 100644 index 5e843e7f9..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a limit. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { - /// Add a single header to the Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("limits/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("limit".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "limit" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/limits/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limit": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/limits/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limit": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/head.rs b/openstack_sdk/src/api/identity/v3/limit/head.rs deleted file mode 100644 index 61d5c9e77..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/head.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`. - -//! Retrieve an existing limit. -//! -//! GET /v3/limits/{limit_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { - /// Add a single header to the Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("limits/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/limits/{id}", id = "id",)); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().id("id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/limits/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/list.rs b/openstack_sdk/src/api/identity/v3/limit/list.rs deleted file mode 100644 index 3d30c21f5..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/list.rs +++ /dev/null @@ -1,209 +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`. - -//! Lists Limits. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/limits` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - /// The ID of the project. - #[builder(default, setter(into))] - project_id: Option>, - - /// The ID of the region. - #[builder(default, setter(into))] - region_id: Option>, - - /// The resource name. - #[builder(default, setter(into))] - resource_name: Option>, - - /// Filters the response by a service ID. - #[builder(default, setter(into))] - service_id: 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> { - /// Add a single header to the Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "limits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("region_id", self.region_id.as_ref()); - params.push_opt("resource_name", self.resource_name.as_ref()); - params.push_opt("service_id", self.service_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("limits".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "limits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limits": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/model/get.rs b/openstack_sdk/src/api/identity/v3/limit/model/get.rs deleted file mode 100644 index bed48b2c5..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/model/get.rs +++ /dev/null @@ -1,180 +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`. - -//! Return the configured limit enforcement model. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit_model` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Model. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "limits/model".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("model".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "model" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits/model".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "model": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/limits/model".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "model": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/model/head.rs b/openstack_sdk/src/api/identity/v3/limit/model/head.rs deleted file mode 100644 index c1b2e83b4..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/model/head.rs +++ /dev/null @@ -1,171 +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`. - -//! Retrieve enforcement model. -//! -//! GET /v3/limits/model -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Model. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "limits/model".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/limits/model".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/limits/model".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/limit/set.rs b/openstack_sdk/src/api/identity/v3/limit/set.rs deleted file mode 100644 index 7bcd1ff8c..000000000 --- a/openstack_sdk/src/api/identity/v3/limit/set.rs +++ /dev/null @@ -1,231 +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`. - -//! Updates the specified limit. It only supports to update `resource_limit` or -//! `description` for the limit. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `limit` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Limit<'a> { - /// The limit description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The override limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) resource_limit: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `limit` object - #[builder(setter(into))] - pub(crate) limit: Limit<'a>, - - /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { - /// Add a single header to the Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("limits/{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("limit", serde_json::to_value(&self.limit)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("limit".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .limit(LimitBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .limit(LimitBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "limit" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/limits/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limit": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .limit(LimitBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/limits/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "limit": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .limit(LimitBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project/get.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project/get.rs deleted file mode 100644 index 30c459521..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project/get.rs +++ /dev/null @@ -1,194 +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`. - -//! Return a list of projects associated with the endpoint. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/OS-EP-FILTER/endpoints/{endpoint_id}/projects API - #[builder(default, setter(into))] - endpoint_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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/endpoints/{endpoint_id}/projects", - endpoint_id = self.endpoint_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", - endpoint_id = "endpoint_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .endpoint_id("endpoint_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", - endpoint_id = "endpoint_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() - .endpoint_id("endpoint_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project/head.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project/head.rs deleted file mode 100644 index d14c50306..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project/head.rs +++ /dev/null @@ -1,189 +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`. - -//! Return a list of projects associated with the endpoint. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/OS-EP-FILTER/endpoints/{endpoint_id}/projects API - #[builder(default, setter(into))] - endpoint_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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-EP-FILTER/endpoints/{endpoint_id}/projects", - endpoint_id = self.endpoint_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", - endpoint_id = "endpoint_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_id("endpoint_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", - endpoint_id = "endpoint_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_id("endpoint_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/create.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/create.rs deleted file mode 100644 index fefd59b14..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/create.rs +++ /dev/null @@ -1,300 +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`. - -//! Create new endpoint groups. -//! -//! POST /v3/OS-EP-FILTER/endpoint_groups -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Interface { - #[serde(rename = "admin")] - Admin, - #[serde(rename = "internal")] - Internal, - #[serde(rename = "public")] - Public, -} - -/// Describes the filtering performed by the endpoint group. The filter used -/// must be an endpoint property, such as interface, service_id, region, and -/// enabled. Note that if using interface as a filter, the only available -/// values are public, internal, and admin. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Filters<'a> { - /// Indicates whether the endpoint appears in the service catalog -false. - /// The endpoint does not appear in the service catalog. -true. The - /// endpoint appears in the service catalog. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The interface type, which describes the visibility of the endpoint. - /// Value is: -public. Visible by end users on a publicly available network - /// interface. -internal. Visible by end users on an unmetered internal - /// network interface. -admin. Visible by administrative users on a secure - /// network interface. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) interface: Option, - - /// (Since v3.2) The ID of the region that contains the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region_id: Option>>, - - /// The UUID of the service to which the endpoint belongs - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_id: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct EndpointGroup<'a> { - /// The endpoint group description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Describes the filtering performed by the endpoint group. The filter - /// used must be an endpoint property, such as interface, service_id, - /// region, and enabled. Note that if using interface as a filter, the only - /// available values are public, internal, and admin. - #[serde()] - #[builder(setter(into))] - pub(crate) filters: Filters<'a>, - - /// The name of the endpoint group. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) endpoint_group: EndpointGroup<'a>, - - #[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 Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-EP-FILTER/endpoint_groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "endpoint_group", - serde_json::to_value(&self.endpoint_group)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoint_group".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .endpoint_group( - EndpointGroupBuilder::default() - .filters(FiltersBuilder::default().build().unwrap()) - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .endpoint_group( - EndpointGroupBuilder::default() - .filters(FiltersBuilder::default().build().unwrap()) - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "endpoint_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-EP-FILTER/endpoint_groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group( - EndpointGroupBuilder::default() - .filters(FiltersBuilder::default().build().unwrap()) - .name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-EP-FILTER/endpoint_groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group( - EndpointGroupBuilder::default() - .filters(FiltersBuilder::default().build().unwrap()) - .name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/delete.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/delete.rs deleted file mode 100644 index bc85965c8..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/delete.rs +++ /dev/null @@ -1,182 +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`. - -//! DELETE operation on /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-EP-FILTER/endpoint_groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-EP-FILTER/endpoint_groups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-EP-FILTER/endpoint_groups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint/get.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint/get.rs deleted file mode 100644 index da6aa45c1..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint/get.rs +++ /dev/null @@ -1,195 +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 operation on -//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints API - #[builder(default, setter(into))] - endpoint_group_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", - endpoint_group_id = self.endpoint_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", - endpoint_group_id = "endpoint_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", - endpoint_group_id = "endpoint_group_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() - .endpoint_group_id("endpoint_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint/head.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint/head.rs deleted file mode 100644 index e57f20d79..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint/head.rs +++ /dev/null @@ -1,190 +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`. - -//! HEAD operation on -//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints API - #[builder(default, setter(into))] - endpoint_group_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", - endpoint_group_id = self.endpoint_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", - endpoint_group_id = "endpoint_group_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", - endpoint_group_id = "endpoint_group_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/get.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/get.rs deleted file mode 100644 index 179aceb9c..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/get.rs +++ /dev/null @@ -1,187 +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 Endpoint Group -//! -//! GET /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-EP-FILTER/endpoint_groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoint_group".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "endpoint_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/head.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/head.rs deleted file mode 100644 index 9f09baf94..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/head.rs +++ /dev/null @@ -1,180 +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`. - -//! List all endpoint groups. -//! -//! GET /v3/OS-EP-FILTER/endpoint_groups -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The name of the endpoint group. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-EP-FILTER/endpoint_groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("name", self.name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-EP-FILTER/endpoint_groups".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-EP-FILTER/endpoint_groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/list.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/list.rs deleted file mode 100644 index 520965fe2..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/list.rs +++ /dev/null @@ -1,188 +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`. - -//! List all endpoint groups. -//! -//! GET /v3/OS-EP-FILTER/endpoint_groups -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The name of the endpoint group. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-EP-FILTER/endpoint_groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("name", self.name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoint_groups".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "endpoint_groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-EP-FILTER/endpoint_groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-EP-FILTER/endpoint_groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/delete.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/delete.rs deleted file mode 100644 index e047d997d..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! DELETE operation on -//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} - /// API - #[builder(default, setter(into))] - endpoint_group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_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<'a> RequestBuilder<'a> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = self.endpoint_group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_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() - .endpoint_group_id("endpoint_group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/get.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/get.rs deleted file mode 100644 index 219d317d5..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/get.rs +++ /dev/null @@ -1,207 +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 operation on -//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} - /// API - #[builder(default, setter(into))] - endpoint_group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_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<'a> RequestBuilder<'a> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = self.endpoint_group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_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() - .endpoint_group_id("endpoint_group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/head.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/head.rs deleted file mode 100644 index 3a80dafeb..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/head.rs +++ /dev/null @@ -1,202 +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`. - -//! HEAD operation on -//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} - /// API - #[builder(default, setter(into))] - endpoint_group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_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<'a> RequestBuilder<'a> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = self.endpoint_group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_id", - id = "id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .id("id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/list.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/list.rs deleted file mode 100644 index d07fa27ff..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/list.rs +++ /dev/null @@ -1,196 +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 operation on -//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} - /// API - #[builder(default, setter(into))] - endpoint_group_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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects", - endpoint_group_id = self.endpoint_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects", - endpoint_group_id = "endpoint_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects", - endpoint_group_id = "endpoint_group_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() - .endpoint_group_id("endpoint_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/set.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/set.rs deleted file mode 100644 index 1023b69ba..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project/set.rs +++ /dev/null @@ -1,234 +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`. - -//! PUT operation on -//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} - /// API - #[builder(default, setter(into))] - endpoint_group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = self.endpoint_group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group_id("endpoint_group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", - endpoint_group_id = "endpoint_group_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() - .endpoint_group_id("endpoint_group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/set.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/set.rs deleted file mode 100644 index 2eaebb707..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/set.rs +++ /dev/null @@ -1,283 +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`. - -//! Update existing endpoint groups -//! -//! PATCH /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Interface { - #[serde(rename = "admin")] - Admin, - #[serde(rename = "internal")] - Internal, - #[serde(rename = "public")] - Public, -} - -/// Describes the filtering performed by the endpoint group. The filter used -/// must be an endpoint property, such as interface, service_id, region, and -/// enabled. Note that if using interface as a filter, the only available -/// values are public, internal, and admin. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Filters<'a> { - /// Indicates whether the endpoint appears in the service catalog -false. - /// The endpoint does not appear in the service catalog. -true. The - /// endpoint appears in the service catalog. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The interface type, which describes the visibility of the endpoint. - /// Value is: -public. Visible by end users on a publicly available network - /// interface. -internal. Visible by end users on an unmetered internal - /// network interface. -admin. Visible by administrative users on a secure - /// network interface. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) interface: Option, - - /// (Since v3.2) The ID of the region that contains the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region_id: Option>>, - - /// The UUID of the service to which the endpoint belongs - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_id: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct EndpointGroup<'a> { - /// The endpoint group description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Describes the filtering performed by the endpoint group. The filter - /// used must be an endpoint property, such as interface, service_id, - /// region, and enabled. Note that if using interface as a filter, the only - /// available values are public, internal, and admin. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) filters: Option>, - - /// The name of the endpoint group. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) endpoint_group: EndpointGroup<'a>, - - /// endpoint_group_id parameter for - /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-EP-FILTER/endpoint_groups/{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( - "endpoint_group", - serde_json::to_value(&self.endpoint_group)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("endpoint_group".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "endpoint_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/delete.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/delete.rs deleted file mode 100644 index f7595b4b0..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! DELETE operation on -//! /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API - #[builder(default, setter(into))] - project_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = self.id.as_ref(), - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = "id", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .project_id("project_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = "id", - project_id = "project_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") - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/get.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/get.rs deleted file mode 100644 index 40d473afe..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/get.rs +++ /dev/null @@ -1,205 +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 operation on -//! /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API - #[builder(default, setter(into))] - project_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = self.id.as_ref(), - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = "id", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .project_id("project_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = "id", - project_id = "project_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") - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/head.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/head.rs deleted file mode 100644 index 3635124b9..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/head.rs +++ /dev/null @@ -1,186 +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`. - -//! HEAD operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoints -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API - #[builder(default, setter(into))] - project_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-EP-FILTER/projects/{project_id}/endpoints", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints", - project_id = "project_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/list.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/list.rs deleted file mode 100644 index 5493f7684..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/list.rs +++ /dev/null @@ -1,191 +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 operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoints -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API - #[builder(default, setter(into))] - project_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/projects/{project_id}/endpoints", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints", - project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/set.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/set.rs deleted file mode 100644 index b4044724b..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint/set.rs +++ /dev/null @@ -1,232 +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`. - -//! PUT operation on -//! /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = self.id.as_ref(), - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = "id", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .project_id("project_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", - id = "id", - project_id = "project_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") - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group/get.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group/get.rs deleted file mode 100644 index b64f928de..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group/get.rs +++ /dev/null @@ -1,191 +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 operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups API - #[builder(default, setter(into))] - project_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 Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-EP-FILTER/projects/{project_id}/endpoint_groups", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", - project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group/head.rs b/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group/head.rs deleted file mode 100644 index ac04f5053..000000000 --- a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group/head.rs +++ /dev/null @@ -1,186 +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`. - -//! HEAD operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups API - #[builder(default, setter(into))] - project_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 Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-EP-FILTER/projects/{project_id}/endpoint_groups", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", - project_id = "project_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/domain/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/domain/head.rs deleted file mode 100644 index 3ea8bc2e2..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/domain/head.rs +++ /dev/null @@ -1,171 +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 possible domain scopes for token. -//! -//! GET/HEAD /v3/auth/domains GET/HEAD /v3/OS-FEDERATION/domains -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-FEDERATION/domains".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/domains".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/domains".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/domain/list.rs b/openstack_sdk/src/api/identity/v3/os_federation/domain/list.rs deleted file mode 100644 index d74117700..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/domain/list.rs +++ /dev/null @@ -1,179 +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 possible domain scopes for token. -//! -//! GET/HEAD /v3/auth/domains GET/HEAD /v3/OS-FEDERATION/domains -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Domain. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-FEDERATION/domains".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("domains".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "domains" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/domains".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domains": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/domains".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "domains": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/create.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/create.rs deleted file mode 100644 index 2ea4c1a5c..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/create.rs +++ /dev/null @@ -1,258 +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`. - -//! Create an idp resource for federated authentication. -//! -//! PUT /OS-FEDERATION/identity_providers/{idp_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct IdentityProvider<'a> { - /// The length of validity in minutes for group memberships carried over - /// through mapping and persisted in the database. If left unset, the - /// default value configured in keystone will be used, if enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) authorization_ttl: Option>, - - /// The identity provider description - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of a domain that is associated with the identity provider. - /// Federated users that authenticate with the identity provider will be - /// created under the domain specified. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>>, - - /// Whether the identity provider is enabled or not - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// List of the unique identity provider's remote IDs - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_ids: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) identity_provider: IdentityProvider<'a>, - - /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API - #[builder(default, setter(into))] - idp_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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-FEDERATION/identity_providers/{idp_id}", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "identity_provider", - serde_json::to_value(&self.identity_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_provider".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "identity_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/delete.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/delete.rs deleted file mode 100644 index 5ade04ff8..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/delete.rs +++ /dev/null @@ -1,190 +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`. - -//! DELETE operation on /v3/OS-FEDERATION/identity_providers/{idp_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API - #[builder(default, setter(into))] - idp_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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_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() - .idp_id("idp_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/get.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/get.rs deleted file mode 100644 index a36cf575a..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/get.rs +++ /dev/null @@ -1,195 +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 an IDP resource. -//! -//! GET/HEAD /OS-FEDERATION/identity_providers/{idp_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API - #[builder(default, setter(into))] - idp_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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_provider".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "identity_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/head.rs deleted file mode 100644 index e98ab0a4c..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/head.rs +++ /dev/null @@ -1,185 +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`. - -//! List all identity providers. -//! -//! GET/HEAD /OS-FEDERATION/identity_providers -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Whether the identity provider is enabled or not - #[builder(default)] - enabled: Option, - - /// The identity provider ID - #[builder(default, setter(into))] - id: 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> { - /// Add a single header to the Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-FEDERATION/identity_providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("enabled", self.enabled); - params.push_opt("id", self.id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/identity_providers".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/identity_providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/list.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/list.rs deleted file mode 100644 index 72ff3b4be..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/list.rs +++ /dev/null @@ -1,193 +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`. - -//! List all identity providers. -//! -//! GET/HEAD /OS-FEDERATION/identity_providers -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Whether the identity provider is enabled or not - #[builder(default)] - enabled: Option, - - /// The identity provider ID - #[builder(default, setter(into))] - id: 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> { - /// Add a single header to the Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-FEDERATION/identity_providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("enabled", self.enabled); - params.push_opt("id", self.id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_providers".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "identity_providers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/identity_providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_providers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/identity_providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_providers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/create.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/create.rs deleted file mode 100644 index 6ee3e3cd6..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/create.rs +++ /dev/null @@ -1,239 +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`. - -//! Authenticate from dedicated uri endpoint. -//! -//! POST /OS-FEDERATION/identity_providers/ -//! {idp_id}/protocols/{protocol_id}/auth -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth - /// API - #[builder(default, setter(into))] - idp_id: Cow<'a, str>, - - /// protocol_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth - /// API - #[builder(default, setter(into))] - protocol_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Auth. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = self.idp_id.as_ref(), - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = "idp_id", - protocol_id = "protocol_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = "idp_id", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/get.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/get.rs deleted file mode 100644 index 779ed4c9b..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/get.rs +++ /dev/null @@ -1,212 +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`. - -//! Authenticate from dedicated uri endpoint. -//! -//! GET/HEAD /OS-FEDERATION/identity_providers/ -//! {idp_id}/protocols/{protocol_id}/auth -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth - /// API - #[builder(default, setter(into))] - idp_id: Cow<'a, str>, - - /// protocol_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth - /// API - #[builder(default, setter(into))] - protocol_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 Auth. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = self.idp_id.as_ref(), - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = "idp_id", - protocol_id = "protocol_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = "idp_id", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/head.rs deleted file mode 100644 index 8f5cfc1ec..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth/head.rs +++ /dev/null @@ -1,204 +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`. - -//! Authenticate from dedicated uri endpoint. -//! -//! GET/HEAD /OS-FEDERATION/identity_providers/ -//! {idp_id}/protocols/{protocol_id}/auth -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth - /// API - #[builder(default, setter(into))] - idp_id: Cow<'a, str>, - - /// protocol_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth - /// API - #[builder(default, setter(into))] - protocol_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 Auth. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = self.idp_id.as_ref(), - protocol_id = self.protocol_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = "idp_id", - protocol_id = "protocol_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", - idp_id = "idp_id", - protocol_id = "protocol_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .protocol_id("protocol_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/create.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/create.rs deleted file mode 100644 index 91ea92541..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/create.rs +++ /dev/null @@ -1,266 +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`. - -//! Create protocol for an IDP. -//! -//! PUT /OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Protocol<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) mapping_id: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_id_attribute: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) protocol: Protocol<'a>, - - /// protocol_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API - #[builder(default, setter(into))] - idp_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 Protocol. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = self.idp_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("protocol", serde_json::to_value(&self.protocol)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("protocol".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "protocol" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocol": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .id("id") - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocol": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .id("id") - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/delete.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/delete.rs deleted file mode 100644 index cd69b0d12..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Delete a protocol from an IDP. -//! -//! DELETE /OS-FEDERATION/identity_providers/ {idp_id}/protocols/{protocol_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// protocol_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API - #[builder(default, setter(into))] - idp_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 Protocol. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = self.idp_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_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() - .idp_id("idp_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/get.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/get.rs deleted file mode 100644 index 3532274ce..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/get.rs +++ /dev/null @@ -1,211 +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 protocols for an IDP. -//! -//! HEAD/GET /OS-FEDERATION/identity_providers/ -//! {idp_id}/protocols/{protocol_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// protocol_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API - #[builder(default, setter(into))] - idp_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 Protocol. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = self.idp_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("protocol".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "protocol" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocol": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocol": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/head.rs deleted file mode 100644 index 20bef4115..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/head.rs +++ /dev/null @@ -1,188 +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`. - -//! List protocols for an IDP. -//! -//! HEAD/GET /OS-FEDERATION/identity_providers/{idp_id}/protocols -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API - #[builder(default, setter(into))] - idp_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 Protocol. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols", - idp_id = "idp_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols", - idp_id = "idp_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/list.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/list.rs deleted file mode 100644 index 361b00ba6..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/list.rs +++ /dev/null @@ -1,196 +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`. - -//! List protocols for an IDP. -//! -//! HEAD/GET /OS-FEDERATION/identity_providers/{idp_id}/protocols -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API - #[builder(default, setter(into))] - idp_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 Protocol. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("protocols".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "protocols" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocols": {} })); - }); - - let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols", - idp_id = "idp_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocols": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/set.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/set.rs deleted file mode 100644 index dcae8e123..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/set.rs +++ /dev/null @@ -1,266 +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`. - -//! Update protocol for an IDP. -//! -//! PATCH /OS-FEDERATION/identity_providers/ {idp_id}/protocols/{protocol_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Protocol<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) mapping_id: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_id_attribute: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) protocol: Protocol<'a>, - - /// protocol_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// idp_id parameter for - /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API - #[builder(default, setter(into))] - idp_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 Protocol. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = self.idp_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("protocol", serde_json::to_value(&self.protocol)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("protocol".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "protocol" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocol": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .id("id") - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", - idp_id = "idp_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "protocol": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .id("id") - .protocol( - ProtocolBuilder::default() - .mapping_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/set.rs b/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/set.rs deleted file mode 100644 index b7c65b163..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/set.rs +++ /dev/null @@ -1,249 +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`. - -//! PATCH operation on /v3/OS-FEDERATION/identity_providers/{idp_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct IdentityProvider<'a> { - /// The length of validity in minutes for group memberships carried over - /// through mapping and persisted in the database. If left unset, the - /// default value configured in keystone will be used, if enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) authorization_ttl: Option>, - - /// The identity provider description - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Whether the identity provider is enabled or not - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// List of the unique identity provider's remote IDs - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_ids: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) identity_provider: IdentityProvider<'a>, - - /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API - #[builder(default, setter(into))] - idp_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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/identity_providers/{idp_id}", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "identity_provider", - serde_json::to_value(&self.identity_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_provider".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "identity_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH).path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!( - "/OS-FEDERATION/identity_providers/{idp_id}", - idp_id = "idp_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .identity_provider(IdentityProviderBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/mapping/create.rs b/openstack_sdk/src/api/identity/v3/os_federation/mapping/create.rs deleted file mode 100644 index b6645820f..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/mapping/create.rs +++ /dev/null @@ -1,503 +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`. - -//! Create a mapping. -//! -//! PUT /OS-FEDERATION/mappings/{mapping_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Group<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct GroupStruct<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) domain: Domain<'a>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LocalGroup<'a> { - F1(Group<'a>), - F2(GroupStruct<'a>), -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Roles<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Projects<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) roles: Vec>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "ephemeral")] - Ephemeral, - #[serde(rename = "local")] - Local, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) email: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Local<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group_ids: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) groups: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) projects: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteAnyOneOfRegexType<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) any_one_of: Vec>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteBlacklistRegexType<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) blacklist: Vec>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteNotAnyOfRegexType<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) not_any_of: Vec>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteRegexTypeWhitelist<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) whitelist: Vec>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteType<'a> { - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum RulesRemote<'a> { - F1(RemoteAnyOneOfRegexType<'a>), - F2(RemoteBlacklistRegexType<'a>), - F3(RemoteNotAnyOfRegexType<'a>), - F4(RemoteRegexTypeWhitelist<'a>), - F5(RemoteType<'a>), -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Rules<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) local: Vec>, - - #[serde()] - #[builder(setter(into))] - pub(crate) remote: Vec>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Mapping<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) rules: Vec>, - - /// Mapping schema version - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) schema_version: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) mapping: Mapping<'a>, - - /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("OS-FEDERATION/mappings/{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("mapping", serde_json::to_value(&self.mapping)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mapping".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap() - )])) - .build() - .unwrap()])) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap() - )])) - .build() - .unwrap()])) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "mapping" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap(), - )])) - .build() - .unwrap()])) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap(), - )])) - .build() - .unwrap()])) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/mapping/delete.rs b/openstack_sdk/src/api/identity/v3/os_federation/mapping/delete.rs deleted file mode 100644 index 89e856a3c..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/mapping/delete.rs +++ /dev/null @@ -1,183 +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`. - -//! Delete a mapping. -//! -//! DELETE /OS-FEDERATION/mappings/{mapping_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-FEDERATION/mappings/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-FEDERATION/mappings/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-FEDERATION/mappings/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/mapping/get.rs b/openstack_sdk/src/api/identity/v3/os_federation/mapping/get.rs deleted file mode 100644 index 82ac09bab..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/mapping/get.rs +++ /dev/null @@ -1,184 +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 operation on /v3/OS-FEDERATION/mappings/{mapping_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-FEDERATION/mappings/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mapping".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "mapping" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/mapping/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/mapping/head.rs deleted file mode 100644 index e9e2c8e2e..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/mapping/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/OS-FEDERATION/mappings -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-FEDERATION/mappings".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/mappings".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/mappings".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/mapping/list.rs b/openstack_sdk/src/api/identity/v3/os_federation/mapping/list.rs deleted file mode 100644 index 2e20fe805..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/mapping/list.rs +++ /dev/null @@ -1,177 +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 operation on /v3/OS-FEDERATION/mappings -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-FEDERATION/mappings".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mappings".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "mappings" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/mappings".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mappings": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/mappings".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mappings": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/mapping/set.rs b/openstack_sdk/src/api/identity/v3/os_federation/mapping/set.rs deleted file mode 100644 index b1a812a02..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/mapping/set.rs +++ /dev/null @@ -1,503 +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`. - -//! Update an attribute mapping for identity federation. -//! -//! PATCH /OS-FEDERATION/mappings/{mapping_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Group<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct GroupStruct<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) domain: Domain<'a>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum LocalGroup<'a> { - F1(Group<'a>), - F2(GroupStruct<'a>), -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Roles<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Projects<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) roles: Vec>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "ephemeral")] - Ephemeral, - #[serde(rename = "local")] - Local, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) email: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Local<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) group_ids: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) groups: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) projects: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteAnyOneOfRegexType<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) any_one_of: Vec>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteBlacklistRegexType<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) blacklist: Vec>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteNotAnyOfRegexType<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) not_any_of: Vec>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteRegexTypeWhitelist<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) regex: Option, - - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) whitelist: Vec>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RemoteType<'a> { - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -#[serde(untagged)] -pub enum RulesRemote<'a> { - F1(RemoteAnyOneOfRegexType<'a>), - F2(RemoteBlacklistRegexType<'a>), - F3(RemoteNotAnyOfRegexType<'a>), - F4(RemoteRegexTypeWhitelist<'a>), - F5(RemoteType<'a>), -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Rules<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) local: Vec>, - - #[serde()] - #[builder(setter(into))] - pub(crate) remote: Vec>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Mapping<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) rules: Vec>, - - /// Mapping schema version - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) schema_version: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) mapping: Mapping<'a>, - - /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-FEDERATION/mappings/{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("mapping", serde_json::to_value(&self.mapping)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mapping".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap() - )])) - .build() - .unwrap()])) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap() - )])) - .build() - .unwrap()])) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "mapping" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap(), - )])) - .build() - .unwrap()])) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .mapping( - MappingBuilder::default() - .rules(Vec::from([RulesBuilder::default() - .local(Vec::from([LocalBuilder::default().build().unwrap()])) - .remote(Vec::from([RulesRemote::F1( - RemoteAnyOneOfRegexTypeBuilder::default() - ._type("foo") - .any_one_of(Vec::from(["foo".into()])) - .build() - .unwrap(), - )])) - .build() - .unwrap()])) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/project/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/project/head.rs deleted file mode 100644 index e41f10779..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/project/head.rs +++ /dev/null @@ -1,171 +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 possible project scopes for token. -//! -//! GET/HEAD /v3/auth/projects GET/HEAD /v3/OS-FEDERATION/projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-FEDERATION/projects".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/projects".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/projects".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/project/list.rs b/openstack_sdk/src/api/identity/v3/os_federation/project/list.rs deleted file mode 100644 index d23555f79..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/project/list.rs +++ /dev/null @@ -1,179 +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 possible project scopes for token. -//! -//! GET/HEAD /v3/auth/projects GET/HEAD /v3/OS-FEDERATION/projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-FEDERATION/projects".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("projects".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "projects" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/projects".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/projects".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata/get.rs b/openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata/get.rs deleted file mode 100644 index 4cddc3fac..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata/get.rs +++ /dev/null @@ -1,176 +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 SAML2 metadata. -//! -//! GET/HEAD /OS-FEDERATION/saml2/metadata -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-FEDERATION/saml2/metadata".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/saml2/metadata".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/saml2/metadata".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata/head.rs deleted file mode 100644 index f1a7601c6..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata/head.rs +++ /dev/null @@ -1,171 +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 SAML2 metadata. -//! -//! GET/HEAD /OS-FEDERATION/saml2/metadata -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Metadata. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-FEDERATION/saml2/metadata".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/saml2/metadata".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/saml2/metadata".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/create.rs b/openstack_sdk/src/api/identity/v3/os_federation/service_provider/create.rs deleted file mode 100644 index f0aeba71a..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/create.rs +++ /dev/null @@ -1,274 +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`. - -//! Create a service provider. -//! -//! PUT /OS-FEDERATION/service_providers/{service_provider_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ServiceProvider<'a> { - /// The URL to authenticate against - #[serde()] - #[builder(setter(into))] - pub(crate) auth_url: Cow<'a, str>, - - /// The description of the service provider - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Whether the service provider is enabled or not - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The prefix of the RelayState SAML attribute - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) relay_state_prefix: Option>>, - - /// The service provider's URL - #[serde()] - #[builder(setter(into))] - pub(crate) sp_url: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) service_provider: ServiceProvider<'a>, - - /// service_provider_id parameter for - /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-FEDERATION/service_providers/{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( - "service_provider", - serde_json::to_value(&self.service_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("service_provider".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_provider( - ServiceProviderBuilder::default() - .auth_url("foo") - .sp_url("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_provider( - ServiceProviderBuilder::default() - .auth_url("foo") - .sp_url("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_provider( - ServiceProviderBuilder::default() - .auth_url("foo") - .sp_url("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_provider( - ServiceProviderBuilder::default() - .auth_url("foo") - .sp_url("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/delete.rs b/openstack_sdk/src/api/identity/v3/os_federation/service_provider/delete.rs deleted file mode 100644 index a0b81fd39..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/delete.rs +++ /dev/null @@ -1,188 +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`. - -//! Delete a service provider. -//! -//! DELETE /OS-FEDERATION/service_providers/{service_provider_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_provider_id parameter for - /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/service_providers/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-FEDERATION/service_providers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-FEDERATION/service_providers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/get.rs b/openstack_sdk/src/api/identity/v3/os_federation/service_provider/get.rs deleted file mode 100644 index 8b8ef8b87..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/get.rs +++ /dev/null @@ -1,191 +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 a service provider. -//! -//! GET/HEAD /OS-FEDERATION/service_providers/{service_provider_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_provider_id parameter for - /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/service_providers/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("service_provider".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/head.rs b/openstack_sdk/src/api/identity/v3/os_federation/service_provider/head.rs deleted file mode 100644 index ee7b80a97..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/head.rs +++ /dev/null @@ -1,185 +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`. - -//! List service providers. -//! -//! GET/HEAD /OS-FEDERATION/service_providers -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Whether the service provider is enabled or not - #[builder(default)] - enabled: Option, - - /// The service provider ID - #[builder(default, setter(into))] - id: 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> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-FEDERATION/service_providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("enabled", self.enabled); - params.push_opt("id", self.id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/service_providers".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-FEDERATION/service_providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/list.rs b/openstack_sdk/src/api/identity/v3/os_federation/service_provider/list.rs deleted file mode 100644 index 854c90a3b..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/list.rs +++ /dev/null @@ -1,193 +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`. - -//! List service providers. -//! -//! GET/HEAD /OS-FEDERATION/service_providers -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Whether the service provider is enabled or not - #[builder(default)] - enabled: Option, - - /// The service provider ID - #[builder(default, setter(into))] - id: 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> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-FEDERATION/service_providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("enabled", self.enabled); - params.push_opt("id", self.id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("service_providers".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_providers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/service_providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_providers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-FEDERATION/service_providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_providers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/set.rs b/openstack_sdk/src/api/identity/v3/os_federation/service_provider/set.rs deleted file mode 100644 index 3375f88fb..000000000 --- a/openstack_sdk/src/api/identity/v3/os_federation/service_provider/set.rs +++ /dev/null @@ -1,250 +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`. - -//! Update a service provider. -//! -//! PATCH /OS-FEDERATION/service_providers/{service_provider_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ServiceProvider<'a> { - /// The URL to authenticate against - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) auth_url: Option>, - - /// The description of the service provider - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Whether the service provider is enabled or not - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The prefix of the RelayState SAML attribute - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) relay_state_prefix: Option>>, - - /// The service provider's URL - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) sp_url: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) service_provider: ServiceProvider<'a>, - - /// service_provider_id parameter for - /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-FEDERATION/service_providers/{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( - "service_provider", - serde_json::to_value(&self.service_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("service_provider".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_provider(ServiceProviderBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_provider(ServiceProviderBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_provider(ServiceProviderBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_provider(ServiceProviderBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/delete.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/delete.rs deleted file mode 100644 index 52deb767d..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/delete.rs +++ /dev/null @@ -1,220 +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`. - -//! Revokes an inherited project role from a group in a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_group_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - role_id = self.role_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_id", - role_id = "role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .role_id("role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_id", - role_id = "role_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() - .domain_id("domain_id") - .group_id("group_id") - .role_id("role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/get.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/get.rs deleted file mode 100644 index 227d8ca1b..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/get.rs +++ /dev/null @@ -1,210 +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`. - -//! The list only contains those role assignments to the domain that were -//! specified as being inherited to projects within that domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_group_roles_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_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() - .domain_id("domain_id") - .group_id("group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/head.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/head.rs deleted file mode 100644 index 714c5ff80..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/head.rs +++ /dev/null @@ -1,204 +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`. - -//! List roles (inherited) for a group on a domain. -//! -//! GET/HEAD /OS-INHERIT/domains/{domain_id}/groups/{group_id} -//! /roles/inherited_to_projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/inherited_to_projects.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/inherited_to_projects.rs deleted file mode 100644 index 5075a81a2..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project/inherited_to_projects.rs +++ /dev/null @@ -1,248 +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`. - -//! The inherited role is only applied to the owned projects (both existing and -//! future projects), and will not appear as a role in a domain scoped token. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_group_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// group_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - group_id = self.group_id.as_ref(), - role_id = self.role_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_id", - role_id = "role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .group_id("group_id") - .role_id("role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - group_id = "group_id", - role_id = "role_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() - .domain_id("domain_id") - .group_id("group_id") - .role_id("role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/delete.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/delete.rs deleted file mode 100644 index 5347eaa5d..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/delete.rs +++ /dev/null @@ -1,221 +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`. - -//! Revokes an inherited project role from a user in a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_user_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - role_id = self.role_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - role_id = "role_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .role_id("role_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - role_id = "role_id", - user_id = "user_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() - .domain_id("domain_id") - .role_id("role_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/get.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/get.rs deleted file mode 100644 index 2942fb0a7..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/get.rs +++ /dev/null @@ -1,210 +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`. - -//! The list only contains those role assignments to the domain that were -//! specified as being inherited to projects within that domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_user_roles_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", - domain_id = "domain_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", - domain_id = "domain_id", - user_id = "user_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() - .domain_id("domain_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/head.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/head.rs deleted file mode 100644 index 03f3f6801..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/head.rs +++ /dev/null @@ -1,204 +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`. - -//! List roles (inherited) for a user on a domain. -//! -//! GET/HEAD /OS-INHERIT/domains/{domain_id}/users/{user_id} -//! /roles/inherited_to_projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", - domain_id = "domain_id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", - domain_id = "domain_id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/inherited_to_projects.rs b/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/inherited_to_projects.rs deleted file mode 100644 index e050798c6..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project/inherited_to_projects.rs +++ /dev/null @@ -1,251 +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`. - -//! Assigns a role to a user in projects owned by a domain. -//! -//! The inherited role is only applied to the owned projects (both existing and -//! future projects), and will not appear as a role in a domain scoped token. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_user_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// domain_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - domain_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - domain_id = self.domain_id.as_ref(), - role_id = self.role_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - role_id = "role_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .domain_id("domain_id") - .role_id("role_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - domain_id = "domain_id", - role_id = "role_id", - user_id = "user_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() - .domain_id("domain_id") - .role_id("role_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/delete.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/delete.rs deleted file mode 100644 index b8d39d578..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/delete.rs +++ /dev/null @@ -1,218 +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`. - -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_group_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_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() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/get.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/get.rs deleted file mode 100644 index 3a017d573..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/get.rs +++ /dev/null @@ -1,220 +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`. - -//! Check for an inherited grant for a group on a project. -//! -//! GET/HEAD /OS-INHERIT/projects/{project_id}/groups/{group_id} -//! /roles/{role_id}/inherited_to_projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_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() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/head.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/head.rs deleted file mode 100644 index 82b97d6c3..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/head.rs +++ /dev/null @@ -1,216 +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`. - -//! Checks whether a group has a role assignment with the -//! `inherited_to_projects` flag in a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_group_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/inherited_to_projects.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/inherited_to_projects.rs deleted file mode 100644 index d0378926c..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project/inherited_to_projects.rs +++ /dev/null @@ -1,248 +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`. - -//! The inherited role assignment is anchored to a project and applied to its -//! subtree in the projects hierarchy (both existing and future projects). -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_group_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", - group_id = "group_id", - project_id = "project_id", - role_id = "role_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() - .group_id("group_id") - .project_id("project_id") - .role_id("role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/delete.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/delete.rs deleted file mode 100644 index bb08df373..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/delete.rs +++ /dev/null @@ -1,218 +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`. - -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_user_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - user_id = self.user_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_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() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/get.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/get.rs deleted file mode 100644 index f8ef6c095..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/get.rs +++ /dev/null @@ -1,220 +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`. - -//! Check for an inherited grant for a user on a project. -//! -//! GET/HEAD /OS-INHERIT/projects/{project_id}/users/{user_id} -//! /roles/{role_id}/inherited_to_projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - user_id = self.user_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_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() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/head.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/head.rs deleted file mode 100644 index 21d5923f0..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/head.rs +++ /dev/null @@ -1,216 +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`. - -//! Checks whether a user has a role assignment with the -//! `inherited_to_projects` flag in a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_user_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - user_id = self.user_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/inherited_to_projects.rs b/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/inherited_to_projects.rs deleted file mode 100644 index 5b3230ce4..000000000 --- a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project/inherited_to_projects.rs +++ /dev/null @@ -1,248 +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`. - -//! The inherited role assignment is anchored to a project and applied to its -//! subtree in the projects hierarchy (both existing and future projects). -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_user_role_inherited_to_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - role_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects - /// API - #[builder(default, setter(into))] - user_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Inherited_To_Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = self.project_id.as_ref(), - role_id = self.role_id.as_ref(), - user_id = self.user_id.as_ref(), - ).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", - project_id = "project_id", - role_id = "role_id", - user_id = "user_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() - .project_id("project_id") - .role_id("role_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/create.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/create.rs deleted file mode 100644 index 2c6b35da3..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/create.rs +++ /dev/null @@ -1,202 +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`. - -//! POST operation on /v3/OS-OAUTH1/access_token -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Access_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH1/access_token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH1/access_token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH1/access_token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/get.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/get.rs deleted file mode 100644 index e0fca241e..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/OS-OAUTH1/access_token -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Access_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-OAUTH1/access_token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH1/access_token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH1/access_token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/head.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/head.rs deleted file mode 100644 index 9d5f231b4..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/access_token/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/OS-OAUTH1/access_token -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Access_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH1/access_token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH1/access_token".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH1/access_token".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/authorize/set.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/authorize/set.rs deleted file mode 100644 index 6aaf03d57..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/authorize/set.rs +++ /dev/null @@ -1,221 +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`. - -//! PUT operation on /v3/OS-OAUTH1/authorize/{request_token_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// request_token_id parameter for - /// /v3/OS-OAUTH1/authorize/{request_token_id} API - #[builder(default, setter(into))] - request_token_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Authorize. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-OAUTH1/authorize/{request_token_id}", - request_token_id = self.request_token_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/OS-OAUTH1/authorize/{request_token_id}", - request_token_id = "request_token_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .request_token_id("request_token_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/OS-OAUTH1/authorize/{request_token_id}", - request_token_id = "request_token_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() - .request_token_id("request_token_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/create.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/create.rs deleted file mode 100644 index 256b806fa..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/create.rs +++ /dev/null @@ -1,202 +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`. - -//! POST operation on /v3/OS-OAUTH1/consumers -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Consumer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH1/consumers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH1/consumers".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH1/consumers".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/delete.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/delete.rs deleted file mode 100644 index 6261c53db..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! DELETE operation on /v3/OS-OAUTH1/consumers/{consumer_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// consumer_id parameter for /v3/OS-OAUTH1/consumers/{consumer_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<'a> RequestBuilder<'a> { - /// Add a single header to the Consumer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-OAUTH1/consumers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-OAUTH1/consumers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-OAUTH1/consumers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/get.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/get.rs deleted file mode 100644 index 2a61fda6d..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/get.rs +++ /dev/null @@ -1,181 +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 operation on /v3/OS-OAUTH1/consumers/{consumer_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// consumer_id parameter for /v3/OS-OAUTH1/consumers/{consumer_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<'a> RequestBuilder<'a> { - /// Add a single header to the Consumer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-OAUTH1/consumers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-OAUTH1/consumers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-OAUTH1/consumers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/head.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/head.rs deleted file mode 100644 index 4a6ccedf0..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/OS-OAUTH1/consumers -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Consumer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH1/consumers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH1/consumers".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH1/consumers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/list.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/list.rs deleted file mode 100644 index 136a93cc8..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/list.rs +++ /dev/null @@ -1,174 +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 operation on /v3/OS-OAUTH1/consumers -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Consumer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-OAUTH1/consumers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH1/consumers".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH1/consumers".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/set.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/set.rs deleted file mode 100644 index dfb76fd6e..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer/set.rs +++ /dev/null @@ -1,208 +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`. - -//! PATCH operation on /v3/OS-OAUTH1/consumers/{consumer_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// consumer_id parameter for /v3/OS-OAUTH1/consumers/{consumer_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Consumer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("OS-OAUTH1/consumers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-OAUTH1/consumers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/OS-OAUTH1/consumers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/create.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/create.rs deleted file mode 100644 index c8ec64e55..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/create.rs +++ /dev/null @@ -1,202 +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`. - -//! POST operation on /v3/OS-OAUTH1/request_token -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Request_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH1/request_token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH1/request_token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH1/request_token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/get.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/get.rs deleted file mode 100644 index 8d026334b..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/OS-OAUTH1/request_token -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Request_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-OAUTH1/request_token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH1/request_token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH1/request_token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/head.rs b/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/head.rs deleted file mode 100644 index 964c7072a..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth1/request_token/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/OS-OAUTH1/request_token -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Request_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH1/request_token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH1/request_token".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH1/request_token".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2/token/create.rs b/openstack_sdk/src/api/identity/v3/os_oauth2/token/create.rs deleted file mode 100644 index 935049ddb..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth2/token/create.rs +++ /dev/null @@ -1,204 +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 an OAuth2.0 Access Token. -//! -//! POST /v3/OS-OAUTH2/token -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH2/token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH2/token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-OAUTH2/token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2/token/delete.rs b/openstack_sdk/src/api/identity/v3/os_oauth2/token/delete.rs deleted file mode 100644 index 5d5fa377a..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth2/token/delete.rs +++ /dev/null @@ -1,174 +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`. - -//! The method is not allowed. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-OAUTH2/token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path("/OS-OAUTH2/token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path("/OS-OAUTH2/token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2/token/get.rs b/openstack_sdk/src/api/identity/v3/os_oauth2/token/get.rs deleted file mode 100644 index cf02c3a69..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth2/token/get.rs +++ /dev/null @@ -1,174 +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`. - -//! The method is not allowed. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-OAUTH2/token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH2/token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-OAUTH2/token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2/token/head.rs b/openstack_sdk/src/api/identity/v3/os_oauth2/token/head.rs deleted file mode 100644 index 7830a15a0..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth2/token/head.rs +++ /dev/null @@ -1,169 +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`. - -//! The method is not allowed. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH2/token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH2/token".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-OAUTH2/token".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2/token/set.rs b/openstack_sdk/src/api/identity/v3/os_oauth2/token/set.rs deleted file mode 100644 index 646fe827e..000000000 --- a/openstack_sdk/src/api/identity/v3/os_oauth2/token/set.rs +++ /dev/null @@ -1,202 +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`. - -//! The method is not allowed. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-OAUTH2/token".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path("/OS-OAUTH2/token".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path("/OS-OAUTH2/token".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_revoke/event/get.rs b/openstack_sdk/src/api/identity/v3/os_revoke/event/get.rs deleted file mode 100644 index d629785dc..000000000 --- a/openstack_sdk/src/api/identity/v3/os_revoke/event/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/OS-REVOKE/events -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Event. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-REVOKE/events".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-REVOKE/events".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-REVOKE/events".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_revoke/event/head.rs b/openstack_sdk/src/api/identity/v3/os_revoke/event/head.rs deleted file mode 100644 index 23f3328a1..000000000 --- a/openstack_sdk/src/api/identity/v3/os_revoke/event/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/OS-REVOKE/events -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Event. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-REVOKE/events".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-REVOKE/events".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-REVOKE/events".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_simple_cert/ca/get.rs b/openstack_sdk/src/api/identity/v3/os_simple_cert/ca/get.rs deleted file mode 100644 index 2c1acb2b3..000000000 --- a/openstack_sdk/src/api/identity/v3/os_simple_cert/ca/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/OS-SIMPLE-CERT/ca -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Ca. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-SIMPLE-CERT/ca".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-SIMPLE-CERT/ca".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-SIMPLE-CERT/ca".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_simple_cert/ca/head.rs b/openstack_sdk/src/api/identity/v3/os_simple_cert/ca/head.rs deleted file mode 100644 index f4e093f76..000000000 --- a/openstack_sdk/src/api/identity/v3/os_simple_cert/ca/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/OS-SIMPLE-CERT/ca -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Ca. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-SIMPLE-CERT/ca".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-SIMPLE-CERT/ca".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-SIMPLE-CERT/ca".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_simple_cert/certificate/get.rs b/openstack_sdk/src/api/identity/v3/os_simple_cert/certificate/get.rs deleted file mode 100644 index 3a15f8ae3..000000000 --- a/openstack_sdk/src/api/identity/v3/os_simple_cert/certificate/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/OS-SIMPLE-CERT/certificates -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Certificate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-SIMPLE-CERT/certificates".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-SIMPLE-CERT/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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-SIMPLE-CERT/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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_simple_cert/certificate/head.rs b/openstack_sdk/src/api/identity/v3/os_simple_cert/certificate/head.rs deleted file mode 100644 index fdc333a7f..000000000 --- a/openstack_sdk/src/api/identity/v3/os_simple_cert/certificate/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/OS-SIMPLE-CERT/certificates -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Certificate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-SIMPLE-CERT/certificates".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-SIMPLE-CERT/certificates".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-SIMPLE-CERT/certificates".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/create.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/create.rs deleted file mode 100644 index 1d2b93af0..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/create.rs +++ /dev/null @@ -1,359 +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`. - -//! Create a new trust. -//! -//! The User creating the trust must be the trustor. -//! -//! POST /v3/OS-TRUST/trusts -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Roles<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The resource name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Trust<'a> { - /// If set to true then a trust between a trustor and any third-party user - /// may be issued by the trustee just like a regular trust. If set to - /// false, stops further redelegation. False by default. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allow_redelegation: Option>, - - /// Specifies the expiration time of the trust. A trust may be revoked - /// ahead of expiration. If the value represents a time in the past, the - /// trust is deactivated. In the redelegation case it must not exceed the - /// value of the corresponding expires_at field of the redelegated trust or - /// it may be omitted, then the expires_at value is copied from the - /// redelegated trust. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expires_at: Option>>, - - /// If set to true, then the user attribute of tokens generated based on - /// the trust will represent that of the trustor rather than the trustee, - /// thus allowing the trustee to impersonate the trustor. If impersonation - /// if set to false, then the token's user attribute will represent that of - /// the trustee. - #[serde()] - #[builder(setter(into))] - pub(crate) impersonation: bool, - - /// Identifies the project upon which the trustor is delegating - /// authorization. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>>, - - /// Returned with redelegated trust provides information about the - /// predecessor in the trust chain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redelegated_trust_id: Option>>, - - /// Specifies the maximum remaining depth of the redelegated trust chain. - /// Each subsequent trust has this field decremented by 1 automatically. - /// The initial trustor issuing new trust that can be redelegated, must set - /// allow_redelegation to true and may set redelegation_count to an integer - /// value less than or equal to max_redelegation_count configuration - /// parameter in order to limit the possible length of derived trust - /// chains. The trust issued by the trustor using a project-scoped token - /// (not redelegating), in which allow_redelegation is set to true (the new - /// trust is redelegatable), will be populated with the value specified in - /// the max_redelegation_count configuration parameter if - /// redelegation_count is not set or set to null. If allow_redelegation is - /// set to false then redelegation_count will be set to 0 in the trust. If - /// the trust is being issued by the trustee of a redelegatable - /// trust-scoped token (redelegation case) then redelegation_count should - /// not be set, as it will automatically be set to the value in the - /// redelegatable trust-scoped token decremented by 1. Note, if the - /// resulting value is 0, this means that the new trust will not be - /// redelegatable, regardless of the value of allow_redelegation. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redelegation_count: Option>, - - /// Specifies how many times the trust can be used to obtain a token. This - /// value is decreased each time a token is issued through the trust. Once - /// it reaches 0, no further tokens will be issued through the trust. The - /// default value is null, meaning there is no limit on the number of - /// tokens issued through the trust. If redelegation is enabled it must not - /// be set. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remaining_uses: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) roles: Option>>, - - /// Represents the user who is capable of consuming the trust. - #[serde()] - #[builder(setter(into))] - pub(crate) trustee_user_id: Cow<'a, str>, - - /// Represents the user who created the trust, and who's authorization is - /// being delegated. - #[serde()] - #[builder(setter(into))] - pub(crate) trustor_user_id: Cow<'a, str>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> TrustBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) trust: Trust<'a>, - - #[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 Trust. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-TRUST/trusts".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("trust", serde_json::to_value(&self.trust)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("trust".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .trust( - TrustBuilder::default() - .impersonation(false) - .trustee_user_id("foo") - .trustor_user_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .trust( - TrustBuilder::default() - .impersonation(false) - .trustee_user_id("foo") - .trustor_user_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "trust" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-TRUST/trusts".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "trust": {} })); - }); - - let endpoint = Request::builder() - .trust( - TrustBuilder::default() - .impersonation(false) - .trustee_user_id("foo") - .trustor_user_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/OS-TRUST/trusts".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "trust": {} })); - }); - - let endpoint = Request::builder() - .trust( - TrustBuilder::default() - .impersonation(false) - .trustee_user_id("foo") - .trustor_user_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/delete.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/delete.rs deleted file mode 100644 index 77bfa392a..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/delete.rs +++ /dev/null @@ -1,183 +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`. - -//! Delete trust. -//! -//! DELETE /v3/OS-TRUST/trusts/{trust_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_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<'a> RequestBuilder<'a> { - /// Add a single header to the Trust. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-TRUST/trusts/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-TRUST/trusts/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/OS-TRUST/trusts/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/get.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/get.rs deleted file mode 100644 index fd271de6e..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/get.rs +++ /dev/null @@ -1,186 +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 trust. -//! -//! GET /v3/OS-TRUST/trusts/{trust_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_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<'a> RequestBuilder<'a> { - /// Add a single header to the Trust. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("OS-TRUST/trusts/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("trust".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "trust" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-TRUST/trusts/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "trust": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/OS-TRUST/trusts/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "trust": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/head.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/head.rs deleted file mode 100644 index 97c169917..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/head.rs +++ /dev/null @@ -1,186 +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`. - -//! Dispatch for LIST trusts. -//! -//! GET /v3/OS-TRUST/trusts -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Represents the user who is capable of consuming the trust. - #[builder(default, setter(into))] - trustee_user_id: Option>, - - /// Represents the user who created the trust, and who's authorization is - /// being delegated. - #[builder(default, setter(into))] - trustor_user_id: 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> { - /// Add a single header to the Trust. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "OS-TRUST/trusts".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("trustee_user_id", self.trustee_user_id.as_ref()); - params.push_opt("trustor_user_id", self.trustor_user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-TRUST/trusts".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/OS-TRUST/trusts".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/list.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/list.rs deleted file mode 100644 index 30cb43643..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/list.rs +++ /dev/null @@ -1,194 +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`. - -//! Dispatch for LIST trusts. -//! -//! GET /v3/OS-TRUST/trusts -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Represents the user who is capable of consuming the trust. - #[builder(default, setter(into))] - trustee_user_id: Option>, - - /// Represents the user who created the trust, and who's authorization is - /// being delegated. - #[builder(default, setter(into))] - trustor_user_id: 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> { - /// Add a single header to the Trust. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "OS-TRUST/trusts".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("trustee_user_id", self.trustee_user_id.as_ref()); - params.push_opt("trustor_user_id", self.trustor_user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("trusts".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "trusts" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-TRUST/trusts".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "trusts": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/OS-TRUST/trusts".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "trusts": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/role/get.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/role/get.rs deleted file mode 100644 index c84d7f1ce..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/role/get.rs +++ /dev/null @@ -1,204 +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 a role that has been assigned to a trust. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - trust_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-TRUST/trusts/{trust_id}/roles/{id}", - id = self.id.as_ref(), - trust_id = self.trust_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-TRUST/trusts/{trust_id}/roles/{id}", - id = "id", - trust_id = "trust_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .trust_id("trust_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-TRUST/trusts/{trust_id}/roles/{id}", - id = "id", - trust_id = "trust_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") - .trust_id("trust_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/role/head.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/role/head.rs deleted file mode 100644 index 8657568c4..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/role/head.rs +++ /dev/null @@ -1,199 +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 a role that has been assigned to a trust. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - trust_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "OS-TRUST/trusts/{trust_id}/roles/{id}", - id = self.id.as_ref(), - trust_id = self.trust_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/OS-TRUST/trusts/{trust_id}/roles/{id}", - id = "id", - trust_id = "trust_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .trust_id("trust_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/OS-TRUST/trusts/{trust_id}/roles/{id}", - id = "id", - trust_id = "trust_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .trust_id("trust_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/role/list.rs b/openstack_sdk/src/api/identity/v3/os_trust/trust/role/list.rs deleted file mode 100644 index ef41808c9..000000000 --- a/openstack_sdk/src/api/identity/v3/os_trust/trust/role/list.rs +++ /dev/null @@ -1,191 +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 operation on /v3/OS-TRUST/trusts/{trust_id}/roles -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - trust_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "OS-TRUST/trusts/{trust_id}/roles", - trust_id = self.trust_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/OS-TRUST/trusts/{trust_id}/roles", - trust_id = "trust_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().trust_id("trust_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/OS-TRUST/trusts/{trust_id}/roles", - trust_id = "trust_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() - .trust_id("trust_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/create.rs b/openstack_sdk/src/api/identity/v3/policy/create.rs deleted file mode 100644 index bbe406723..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/create.rs +++ /dev/null @@ -1,205 +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`. - -//! Creates a policy. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/policies` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/policies".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/policies".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/delete.rs b/openstack_sdk/src/api/identity/v3/policy/delete.rs deleted file mode 100644 index 190c51de4..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes a policy. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/policy` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// policy_id parameter for /v3/policies/{policy_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<'a> RequestBuilder<'a> { - /// Add a single header to the Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/policies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/policies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/get.rs b/openstack_sdk/src/api/identity/v3/policy/get.rs deleted file mode 100644 index 0cc30ac4a..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Shows details for a policy. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/policy` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// policy_id parameter for /v3/policies/{policy_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<'a> RequestBuilder<'a> { - /// Add a single header to the Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/policies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/policies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/head.rs b/openstack_sdk/src/api/identity/v3/policy/head.rs deleted file mode 100644 index 8eeb8133a..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/policies -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/policies".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/policies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/list.rs b/openstack_sdk/src/api/identity/v3/policy/list.rs deleted file mode 100644 index f7c171716..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/list.rs +++ /dev/null @@ -1,177 +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`. - -//! Lists policies. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/policies` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/policies".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/policies".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/delete.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/delete.rs deleted file mode 100644 index 21aa158f8..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! DELETE operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - policy_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/get.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/get.rs deleted file mode 100644 index 7013b7384..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/get.rs +++ /dev/null @@ -1,205 +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 operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - policy_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/head.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/head.rs deleted file mode 100644 index 4e709ca5d..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/head.rs +++ /dev/null @@ -1,200 +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`. - -//! HEAD operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - policy_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/list.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/list.rs deleted file mode 100644 index 826a163a1..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/list.rs +++ /dev/null @@ -1,191 +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 operation on /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - policy_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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints", - policy_id = "policy_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() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/set.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/set.rs deleted file mode 100644 index 70fea349b..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint/set.rs +++ /dev/null @@ -1,232 +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`. - -//! PUT operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// endpoint_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Endpoint. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/delete.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/delete.rs deleted file mode 100644 index df02f0958..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! DELETE operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - policy_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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_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() - .policy_id("policy_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/get.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/get.rs deleted file mode 100644 index bac8dd413..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/get.rs +++ /dev/null @@ -1,205 +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 operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - policy_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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_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() - .policy_id("policy_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/head.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/head.rs deleted file mode 100644 index 1dec64adf..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/head.rs +++ /dev/null @@ -1,200 +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`. - -//! HEAD operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - policy_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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_id", - id = "id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/delete.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/delete.rs deleted file mode 100644 index 2b5458aa4..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/delete.rs +++ /dev/null @@ -1,218 +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`. - -//! DELETE operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// region_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - service_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 Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - service_id = self.service_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_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() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/get.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/get.rs deleted file mode 100644 index a80f098c7..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/get.rs +++ /dev/null @@ -1,218 +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 operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// region_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - service_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 Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - service_id = self.service_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_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() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/head.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/head.rs deleted file mode 100644 index 2c8a694d8..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/head.rs +++ /dev/null @@ -1,213 +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`. - -//! HEAD operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// region_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - service_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 Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - service_id = self.service_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/set.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/set.rs deleted file mode 100644 index 88dcbe2d6..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region/set.rs +++ /dev/null @@ -1,245 +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`. - -//! PUT operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// region_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} - /// API - #[builder(default, setter(into))] - service_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - service_id = self.service_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", - policy_id = "policy_id", - id = "id", - service_id = "service_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() - .policy_id("policy_id") - .id("id") - .service_id("service_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/set.rs b/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/set.rs deleted file mode 100644 index 7884d13c0..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/set.rs +++ /dev/null @@ -1,232 +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`. - -//! PUT operation on -//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = self.policy_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", - policy_id = "policy_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() - .policy_id("policy_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/policy/set.rs b/openstack_sdk/src/api/identity/v3/policy/set.rs deleted file mode 100644 index 34b18e5d7..000000000 --- a/openstack_sdk/src/api/identity/v3/policy/set.rs +++ /dev/null @@ -1,211 +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`. - -//! Updates a policy. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/policy` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// policy_id parameter for /v3/policies/{policy_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PATCH - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/policies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/policies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/create.rs b/openstack_sdk/src/api/identity/v3/project/create.rs deleted file mode 100644 index 31c9cc3c0..000000000 --- a/openstack_sdk/src/api/identity/v3/project/create.rs +++ /dev/null @@ -1,293 +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`. - -//! Creates a project, where the project may act as a domain. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The resource options for the project. Available resource options are -/// `immutable`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) immutable: Option, -} - -/// A `project` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Project<'a> { - /// The description of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the domain for the project. - /// - /// For projects acting as a domain, the `domain_id` must not be specified, - /// it will be generated by the Identity service implementation. - /// - /// For regular projects (i.e. those not acing as a domain), if `domain_id` - /// is not specified, but `parent_id` is specified, then the domain ID of - /// the parent will be used. If neither `domain_id` or `parent_id` is - /// specified, the Identity service implementation will default to the - /// domain to which the client’s token is scoped. If both `domain_id` and - /// `parent_id` are specified, and they do not indicate the same domain, an - /// `Bad Request (400)` will be returned. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>>, - - /// If set to `true`, project is enabled. If set to `false`, project is - /// disabled. The default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// If set to `true`, project is enabled. If set to `false`, project is - /// disabled. The default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_domain: Option, - - /// The name of the project, which must be unique within the owning domain. - /// A project can have the same name as its domain. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The resource options for the project. Available resource options are - /// `immutable`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option, - - /// The ID of the parent of the project. - /// - /// If specified on project creation, this places the project within a - /// hierarchy and implicitly defines the owning domain, which will be the - /// same domain as the parent specified. If `parent_id` is not specified - /// and `is_domain` is `false`, then the project will use its owning domain - /// as its parent. If `is_domain` is `true` (i.e. the project is acting as - /// a domain), then `parent_id` must not specified (or if it is, it must be - /// `null`) since domains have no parents. - /// - /// `parent_id` is immutable, and can’t be updated after the project is - /// created - hence a project cannot be moved within the hierarchy. - /// - /// **New in version 3.4** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) parent_id: Option>>, - - /// A list of simple strings assigned to a project. Tags can be used to - /// classify projects into groups. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `project` object - #[builder(setter(into))] - pub(crate) project: Project<'a>, - - #[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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "projects".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("project", serde_json::to_value(&self.project)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("project".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .project(ProjectBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .project(ProjectBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "project" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/projects".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "project": {} })); - }); - - let endpoint = Request::builder() - .project(ProjectBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/projects".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "project": {} })); - }); - - let endpoint = Request::builder() - .project(ProjectBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/delete.rs b/openstack_sdk/src/api/identity/v3/project/delete.rs deleted file mode 100644 index a40d49ea4..000000000 --- a/openstack_sdk/src/api/identity/v3/project/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("projects/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/projects/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/projects/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/find.rs b/openstack_sdk/src/api/identity/v3/project/find.rs deleted file mode 100644 index 92a399573..000000000 --- a/openstack_sdk/src/api/identity/v3/project/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::identity::v3::project::{get as Get, list as List}; - -/// Find for project 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/get.rs b/openstack_sdk/src/api/identity/v3/project/get.rs deleted file mode 100644 index 69806507d..000000000 --- a/openstack_sdk/src/api/identity/v3/project/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("projects/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("project".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "project" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/projects/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "project": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/projects/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "project": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/group/role/delete.rs b/openstack_sdk/src/api/identity/v3/project/group/role/delete.rs deleted file mode 100644 index 79e180d58..000000000 --- a/openstack_sdk/src/api/identity/v3/project/group/role/delete.rs +++ /dev/null @@ -1,217 +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`. - -//! Unassigns a role from a group on a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - project_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = "group_id", - project_id = "project_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = "group_id", - project_id = "project_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() - .group_id("group_id") - .project_id("project_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/group/role/get.rs b/openstack_sdk/src/api/identity/v3/project/group/role/get.rs deleted file mode 100644 index cab899eb7..000000000 --- a/openstack_sdk/src/api/identity/v3/project/group/role/get.rs +++ /dev/null @@ -1,216 +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`. - -//! Check grant for project, group, role. -//! -//! GET/HEAD /v3/projects/{project_id/groups/{group_id}/roles/{role_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - project_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = "group_id", - project_id = "project_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = "group_id", - project_id = "project_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() - .group_id("group_id") - .project_id("project_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/group/role/head.rs b/openstack_sdk/src/api/identity/v3/project/group/role/head.rs deleted file mode 100644 index 40debb5ac..000000000 --- a/openstack_sdk/src/api/identity/v3/project/group/role/head.rs +++ /dev/null @@ -1,201 +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`. - -//! List grants for group on project. -//! -//! GET/HEAD /v3/projects/{project_id}/groups/{group_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - project_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "projects/{project_id}/groups/{group_id}/roles", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/projects/{project_id}/groups/{group_id}/roles", - group_id = "group_id", - project_id = "project_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/projects/{project_id}/groups/{group_id}/roles", - group_id = "group_id", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/group/role/list.rs b/openstack_sdk/src/api/identity/v3/project/group/role/list.rs deleted file mode 100644 index 5da251e58..000000000 --- a/openstack_sdk/src/api/identity/v3/project/group/role/list.rs +++ /dev/null @@ -1,210 +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`. - -//! Lists role assignments for a group on a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - project_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/groups/{group_id}/roles", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("roles".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "roles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/projects/{project_id}/groups/{group_id}/roles", - group_id = "group_id", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/projects/{project_id}/groups/{group_id}/roles", - group_id = "group_id", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/group/role/set.rs b/openstack_sdk/src/api/identity/v3/project/group/role/set.rs deleted file mode 100644 index 41c96833c..000000000 --- a/openstack_sdk/src/api/identity/v3/project/group/role/set.rs +++ /dev/null @@ -1,217 +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`. - -//! Assigns a role to a group on a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/groups/{group_id}/roles API - #[builder(default, setter(into))] - project_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = self.group_id.as_ref(), - project_id = self.project_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = "group_id", - project_id = "project_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .project_id("project_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/projects/{project_id}/groups/{group_id}/roles/{id}", - group_id = "group_id", - project_id = "project_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() - .group_id("group_id") - .project_id("project_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/head.rs b/openstack_sdk/src/api/identity/v3/project/head.rs deleted file mode 100644 index f4d6b2f35..000000000 --- a/openstack_sdk/src/api/identity/v3/project/head.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`. - -//! Get project. -//! -//! GET/HEAD /v3/projects/{project_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("projects/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/projects/{id}", id = "id",)); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().id("id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/projects/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/list.rs b/openstack_sdk/src/api/identity/v3/project/list.rs deleted file mode 100644 index 10ba4b7f0..000000000 --- a/openstack_sdk/src/api/identity/v3/project/list.rs +++ /dev/null @@ -1,233 +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`. - -//! Lists projects. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - #[builder(default)] - enabled: Option, - - #[builder(default)] - is_domain: Option, - - #[builder(default)] - limit: Option, - - /// ID of the last fetched entry - #[builder(default, setter(into))] - marker: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: Option>, - - #[builder(default, setter(into))] - not_tags: Option>, - - #[builder(default, setter(into))] - not_tags_any: Option>, - - #[builder(default, setter(into))] - parent_id: Option>, - - #[builder(default, setter(into))] - tags: Option>, - - #[builder(default, setter(into))] - tags_any: 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> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "projects".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("enabled", self.enabled); - params.push_opt("is_domain", self.is_domain); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("parent_id", self.parent_id.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("projects".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "projects" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/projects".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/projects".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/set.rs b/openstack_sdk/src/api/identity/v3/project/set.rs deleted file mode 100644 index e560a8a8a..000000000 --- a/openstack_sdk/src/api/identity/v3/project/set.rs +++ /dev/null @@ -1,259 +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`. - -//! Updates a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// The resource options for the project. Available resource options are -/// `immutable`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) immutable: Option, -} - -/// A `project` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Project<'a> { - /// The description of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// If set to `true`, project is enabled. If set to `false`, project is - /// disabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The name of the project, which must be unique within the owning domain. - /// A project can have the same name as its domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The resource options for the project. Available resource options are - /// `immutable`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option, - - /// A list of simple strings assigned to a project. Tags can be used to - /// classify projects into groups. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `project` object - #[builder(setter(into))] - pub(crate) project: Project<'a>, - - /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { - /// Add a single header to the Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("projects/{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("project", serde_json::to_value(&self.project)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("project".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .project(ProjectBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .project(ProjectBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "project" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/projects/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "project": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .project(ProjectBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/projects/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "project": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .project(ProjectBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/tag/delete.rs b/openstack_sdk/src/api/identity/v3/project/tag/delete.rs deleted file mode 100644 index 83afb10ff..000000000 --- a/openstack_sdk/src/api/identity/v3/project/tag/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! Remove a single tag from a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// value parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - value: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/tags/{value}", - project_id = self.project_id.as_ref(), - value = self.value.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/tag/delete_all.rs b/openstack_sdk/src/api/identity/v3/project/tag/delete_all.rs deleted file mode 100644 index 27ef5dab9..000000000 --- a/openstack_sdk/src/api/identity/v3/project/tag/delete_all.rs +++ /dev/null @@ -1,193 +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`. - -//! Remove all tags from a given project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - project_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/tags", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/projects/{project_id}/tags", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/projects/{project_id}/tags", - project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/tag/get.rs b/openstack_sdk/src/api/identity/v3/project/tag/get.rs deleted file mode 100644 index 0988287ca..000000000 --- a/openstack_sdk/src/api/identity/v3/project/tag/get.rs +++ /dev/null @@ -1,205 +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`. - -//! Checks if a project contains the specified tag. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// value parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - value: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/tags/{value}", - project_id = self.project_id.as_ref(), - value = self.value.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/tag/head.rs b/openstack_sdk/src/api/identity/v3/project/tag/head.rs deleted file mode 100644 index e61cc77b7..000000000 --- a/openstack_sdk/src/api/identity/v3/project/tag/head.rs +++ /dev/null @@ -1,199 +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 information for a single tag associated with a given project. -//! -//! GET /v3/projects/{project_id}/tags/{value} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// value parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - value: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "projects/{project_id}/tags/{value}", - project_id = self.project_id.as_ref(), - value = self.value.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/tag/list.rs b/openstack_sdk/src/api/identity/v3/project/tag/list.rs deleted file mode 100644 index 484c1a3b7..000000000 --- a/openstack_sdk/src/api/identity/v3/project/tag/list.rs +++ /dev/null @@ -1,196 +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`. - -//! Lists all tags within a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - project_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/tags", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("tags".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/projects/{project_id}/tags", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/projects/{project_id}/tags", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/tag/replace.rs b/openstack_sdk/src/api/identity/v3/project/tag/replace.rs deleted file mode 100644 index 582a40d96..000000000 --- a/openstack_sdk/src/api/identity/v3/project/tag/replace.rs +++ /dev/null @@ -1,223 +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`. - -//! Modifies the tags for a project. Any existing tags not specified will be -//! deleted. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A list of simple strings assigned to a project. - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// project_id parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - project_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "projects/{project_id}/tags", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("tags".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/projects/{project_id}/tags", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/projects/{project_id}/tags", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/tag/set.rs b/openstack_sdk/src/api/identity/v3/project/tag/set.rs deleted file mode 100644 index cbf04e5a5..000000000 --- a/openstack_sdk/src/api/identity/v3/project/tag/set.rs +++ /dev/null @@ -1,205 +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`. - -//! Creates the specified tag and adds it to the list of tags in the project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// value parameter for /v3/projects/{project_id}/tags/{value} API - #[builder(default, setter(into))] - value: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "projects/{project_id}/tags/{value}", - project_id = self.project_id.as_ref(), - value = self.value.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/projects/{project_id}/tags/{value}", - project_id = "project_id", - value = "value", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .value("value") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/user/role/delete.rs b/openstack_sdk/src/api/identity/v3/project/user/role/delete.rs deleted file mode 100644 index 6872e0a4d..000000000 --- a/openstack_sdk/src/api/identity/v3/project/user/role/delete.rs +++ /dev/null @@ -1,217 +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`. - -//! Unassigns a role from a user on a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/users/{user_id}/roles/{id}", - project_id = self.project_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/projects/{project_id}/users/{user_id}/roles/{id}", - project_id = "project_id", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/projects/{project_id}/users/{user_id}/roles/{id}", - project_id = "project_id", - id = "id", - user_id = "user_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() - .project_id("project_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/user/role/get.rs b/openstack_sdk/src/api/identity/v3/project/user/role/get.rs deleted file mode 100644 index 75e0ebd8e..000000000 --- a/openstack_sdk/src/api/identity/v3/project/user/role/get.rs +++ /dev/null @@ -1,216 +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`. - -//! Check grant for project, user, role. -//! -//! GET/HEAD /v3/projects/{project_id/users/{user_id}/roles/{role_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/users/{user_id}/roles/{id}", - project_id = self.project_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/projects/{project_id}/users/{user_id}/roles/{id}", - project_id = "project_id", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/projects/{project_id}/users/{user_id}/roles/{id}", - project_id = "project_id", - id = "id", - user_id = "user_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() - .project_id("project_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/user/role/head.rs b/openstack_sdk/src/api/identity/v3/project/user/role/head.rs deleted file mode 100644 index 1d7220e81..000000000 --- a/openstack_sdk/src/api/identity/v3/project/user/role/head.rs +++ /dev/null @@ -1,201 +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`. - -//! List grants for user on project. -//! -//! GET/HEAD /v3/projects/{project_id}/users/{user_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "projects/{project_id}/users/{user_id}/roles", - project_id = self.project_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/projects/{project_id}/users/{user_id}/roles", - project_id = "project_id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/projects/{project_id}/users/{user_id}/roles", - project_id = "project_id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/user/role/list.rs b/openstack_sdk/src/api/identity/v3/project/user/role/list.rs deleted file mode 100644 index 8b16c30f3..000000000 --- a/openstack_sdk/src/api/identity/v3/project/user/role/list.rs +++ /dev/null @@ -1,210 +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`. - -//! Lists role assignments for a user on a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "projects/{project_id}/users/{user_id}/roles", - project_id = self.project_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("roles".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "roles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/projects/{project_id}/users/{user_id}/roles", - project_id = "project_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/projects/{project_id}/users/{user_id}/roles", - project_id = "project_id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/project/user/role/set.rs b/openstack_sdk/src/api/identity/v3/project/user/role/set.rs deleted file mode 100644 index 83177b040..000000000 --- a/openstack_sdk/src/api/identity/v3/project/user/role/set.rs +++ /dev/null @@ -1,217 +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`. - -//! Assigns a role to a user on a project. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// project_id parameter for - /// /v3/projects/{project_id}/users/{user_id}/roles API - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "projects/{project_id}/users/{user_id}/roles/{id}", - project_id = self.project_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/projects/{project_id}/users/{user_id}/roles/{id}", - project_id = "project_id", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/projects/{project_id}/users/{user_id}/roles/{id}", - project_id = "project_id", - id = "id", - user_id = "user_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() - .project_id("project_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/region/create.rs b/openstack_sdk/src/api/identity/v3/region/create.rs deleted file mode 100644 index 8e75e5f36..000000000 --- a/openstack_sdk/src/api/identity/v3/region/create.rs +++ /dev/null @@ -1,256 +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`. - -//! Creates a region. -//! -//! When you create the region, you can optionally specify a region ID. If you -//! include characters in the region ID that are not allowed in a URI, you must -//! URL-encode the ID. If you omit an ID, the API assigns an ID to the region. -//! -//! The following errors might occur: -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/regions` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `region` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Region<'a> { - /// The region description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID for the region. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>>, - - /// To make this region a child of another region, set this parameter to - /// the ID of the parent region. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) parent_region_id: Option>>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> RegionBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `region` object - #[builder(setter(into))] - pub(crate) region: Region<'a>, - - #[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 Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "regions".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("region", serde_json::to_value(&self.region)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("region".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .region(RegionBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .region(RegionBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "region" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/regions".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "region": {} })); - }); - - let endpoint = Request::builder() - .region(RegionBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/regions".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "region": {} })); - }); - - let endpoint = Request::builder() - .region(RegionBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/region/delete.rs b/openstack_sdk/src/api/identity/v3/region/delete.rs deleted file mode 100644 index 373ad654b..000000000 --- a/openstack_sdk/src/api/identity/v3/region/delete.rs +++ /dev/null @@ -1,186 +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`. - -//! Deletes a region. -//! -//! The following error might occur: -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/region` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// region_id parameter for /v3/regions/{region_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<'a> RequestBuilder<'a> { - /// Add a single header to the Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("regions/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/regions/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/regions/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/region/get.rs b/openstack_sdk/src/api/identity/v3/region/get.rs deleted file mode 100644 index 7e828fd87..000000000 --- a/openstack_sdk/src/api/identity/v3/region/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a region, by ID. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/regions` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// region_id parameter for /v3/regions/{region_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<'a> RequestBuilder<'a> { - /// Add a single header to the Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("regions/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("region".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "region" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/regions/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "region": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/regions/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "region": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/region/head.rs b/openstack_sdk/src/api/identity/v3/region/head.rs deleted file mode 100644 index fdc35f889..000000000 --- a/openstack_sdk/src/api/identity/v3/region/head.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`. - -//! HEAD operation on /v3/regions -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the region. - #[builder(default, setter(into))] - parent_region_id: 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> { - /// Add a single header to the Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "regions".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("parent_region_id", self.parent_region_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/regions".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/regions".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/region/list.rs b/openstack_sdk/src/api/identity/v3/region/list.rs deleted file mode 100644 index 660b0d997..000000000 --- a/openstack_sdk/src/api/identity/v3/region/list.rs +++ /dev/null @@ -1,189 +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`. - -//! Lists regions. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/regions` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the region. - #[builder(default, setter(into))] - parent_region_id: 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> { - /// Add a single header to the Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "regions".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("parent_region_id", self.parent_region_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("regions".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "regions" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/regions".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "regions": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/regions".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "regions": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/region/set.rs b/openstack_sdk/src/api/identity/v3/region/set.rs deleted file mode 100644 index ce69666c2..000000000 --- a/openstack_sdk/src/api/identity/v3/region/set.rs +++ /dev/null @@ -1,261 +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`. - -//! Updates a region. -//! -//! You can update the description or parent region ID for a region. You cannot -//! update the region ID. -//! -//! The following error might occur: -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/region` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `region` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Region<'a> { - /// The region description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The region ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>>, - - /// To make this region a child of another region, set this parameter to - /// the ID of the parent region. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) parent_region_id: Option>>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> RegionBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `region` object - #[builder(setter(into))] - pub(crate) region: Region<'a>, - - /// region_id parameter for /v3/regions/{region_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<'a> RequestBuilder<'a> { - /// Add a single header to the Region. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("regions/{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("region", serde_json::to_value(&self.region)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("region".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .region(RegionBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .region(RegionBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "region" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/regions/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "region": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .region(RegionBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/regions/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "region": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .region(RegionBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/registered_limit/create.rs b/openstack_sdk/src/api/identity/v3/registered_limit/create.rs deleted file mode 100644 index 6713ac2f1..000000000 --- a/openstack_sdk/src/api/identity/v3/registered_limit/create.rs +++ /dev/null @@ -1,262 +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`. - -//! Creates registered limits. It supports to create more than one registered -//! limit in one request. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limits` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RegisteredLimits<'a> { - /// The default limit for the registered limit. - #[serde()] - #[builder(setter(into))] - pub(crate) default_limit: i32, - - /// The registered limit description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the region that contains the service endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region_id: Option>>, - - /// The resource name. - #[serde()] - #[builder(setter(into))] - pub(crate) resource_name: Cow<'a, str>, - - /// The UUID of the service to which the registered limit belongs. - #[serde()] - #[builder(setter(into))] - pub(crate) service_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A list of `registered_limits` objects - #[builder(setter(into))] - pub(crate) registered_limits: Vec>, - - #[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 Registered_Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "registered_limits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "registered_limits", - serde_json::to_value(&self.registered_limits)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("registered_limits".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .registered_limits(Vec::from([RegisteredLimitsBuilder::default() - .default_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .registered_limits(Vec::from([RegisteredLimitsBuilder::default() - .default_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "registered_limits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/registered_limits".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limits": {} })); - }); - - let endpoint = Request::builder() - .registered_limits(Vec::from([RegisteredLimitsBuilder::default() - .default_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/registered_limits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limits": {} })); - }); - - let endpoint = Request::builder() - .registered_limits(Vec::from([RegisteredLimitsBuilder::default() - .default_limit(123) - .resource_name("foo") - .service_id("foo") - .build() - .unwrap()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/registered_limit/delete.rs b/openstack_sdk/src/api/identity/v3/registered_limit/delete.rs deleted file mode 100644 index dd76d0c17..000000000 --- a/openstack_sdk/src/api/identity/v3/registered_limit/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a registered limit. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limit` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// registered_limit_id parameter for - /// /v3/registered_limits/{registered_limit_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<'a> RequestBuilder<'a> { - /// Add a single header to the Registered_Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("registered_limits/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/registered_limits/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/registered_limits/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/registered_limit/get.rs b/openstack_sdk/src/api/identity/v3/registered_limit/get.rs deleted file mode 100644 index 8f29e56b8..000000000 --- a/openstack_sdk/src/api/identity/v3/registered_limit/get.rs +++ /dev/null @@ -1,188 +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`. - -//! Shows details for a registered limit. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limit` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// registered_limit_id parameter for - /// /v3/registered_limits/{registered_limit_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<'a> RequestBuilder<'a> { - /// Add a single header to the Registered_Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("registered_limits/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("registered_limit".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "registered_limit" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/registered_limits/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limit": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/registered_limits/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limit": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/registered_limit/head.rs b/openstack_sdk/src/api/identity/v3/registered_limit/head.rs deleted file mode 100644 index 1b1eb8261..000000000 --- a/openstack_sdk/src/api/identity/v3/registered_limit/head.rs +++ /dev/null @@ -1,190 +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`. - -//! List registered limits. -//! -//! GET /v3/registered_limits -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the region. - #[builder(default, setter(into))] - region_id: Option>, - - /// The resource name. - #[builder(default, setter(into))] - resource_name: Option>, - - /// Filters the response by a service ID. - #[builder(default, setter(into))] - service_id: 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> { - /// Add a single header to the Registered_Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "registered_limits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("region_id", self.region_id.as_ref()); - params.push_opt("resource_name", self.resource_name.as_ref()); - params.push_opt("service_id", self.service_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/registered_limits".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/registered_limits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/registered_limit/list.rs b/openstack_sdk/src/api/identity/v3/registered_limit/list.rs deleted file mode 100644 index 3253f740e..000000000 --- a/openstack_sdk/src/api/identity/v3/registered_limit/list.rs +++ /dev/null @@ -1,199 +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`. - -//! Lists Registered Limits. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limits` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the region. - #[builder(default, setter(into))] - region_id: Option>, - - /// The resource name. - #[builder(default, setter(into))] - resource_name: Option>, - - /// Filters the response by a service ID. - #[builder(default, setter(into))] - service_id: 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> { - /// Add a single header to the Registered_Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "registered_limits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("region_id", self.region_id.as_ref()); - params.push_opt("resource_name", self.resource_name.as_ref()); - params.push_opt("service_id", self.service_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("registered_limits".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "registered_limits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/registered_limits".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limits": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/registered_limits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limits": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/registered_limit/set.rs b/openstack_sdk/src/api/identity/v3/registered_limit/set.rs deleted file mode 100644 index 03b993590..000000000 --- a/openstack_sdk/src/api/identity/v3/registered_limit/set.rs +++ /dev/null @@ -1,254 +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`. - -//! Updates the specified registered limit. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limit` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `registered_limit` objects -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RegisteredLimit<'a> { - /// The default limit for the registered limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_limit: Option, - - /// The registered limit description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the region that contains the service endpoint. Either - /// service_id, resource_name, or region_id must be different than existing - /// value otherwise it will raise 409. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) region_id: Option>>, - - /// The resource name. Either service_id, resource_name or region_id must - /// be different than existing value otherwise it will raise 409. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) resource_name: Option>, - - /// The UUID of the service to update to which the registered limit - /// belongs. Either service_id, resource_name, or region_id must be - /// different than existing value otherwise it will raise 409. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `registered_limit` objects - #[builder(setter(into))] - pub(crate) registered_limit: RegisteredLimit<'a>, - - /// registered_limit_id parameter for - /// /v3/registered_limits/{registered_limit_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<'a> RequestBuilder<'a> { - /// Add a single header to the Registered_Limit. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("registered_limits/{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( - "registered_limit", - serde_json::to_value(&self.registered_limit)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("registered_limit".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "registered_limit" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/registered_limits/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limit": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/registered_limits/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "registered_limit": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/create.rs b/openstack_sdk/src/api/identity/v3/role/create.rs deleted file mode 100644 index 439e8bca6..000000000 --- a/openstack_sdk/src/api/identity/v3/role/create.rs +++ /dev/null @@ -1,265 +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`. - -//! Creates a role. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/roles` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// The resource options for the role. Available resource options are -/// `immutable`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) immutable: Option, -} - -/// A `role` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Role<'a> { - /// Add description about the role. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the domain of the role. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>>, - - /// The role name. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The resource options for the role. Available resource options are - /// `immutable`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> RoleBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `role` object - #[builder(setter(into))] - pub(crate) role: Role<'a>, - - #[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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "roles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("role", serde_json::to_value(&self.role)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .role(RoleBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .role(RoleBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "role" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/roles".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role": {} })); - }); - - let endpoint = Request::builder() - .role(RoleBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/roles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role": {} })); - }); - - let endpoint = Request::builder() - .role(RoleBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/delete.rs b/openstack_sdk/src/api/identity/v3/role/delete.rs deleted file mode 100644 index 6c7e8efda..000000000 --- a/openstack_sdk/src/api/identity/v3/role/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes a role. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("roles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/roles/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/roles/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/find.rs b/openstack_sdk/src/api/identity/v3/role/find.rs deleted file mode 100644 index 6a6eebca4..000000000 --- a/openstack_sdk/src/api/identity/v3/role/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::identity::v3::role::{get as Get, list as List}; - -/// Find for role 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate role in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // role 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") - && let Some(name) = name_as_val.as_str() - && 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/identity/v3/role/get.rs b/openstack_sdk/src/api/identity/v3/role/get.rs deleted file mode 100644 index 028ef4277..000000000 --- a/openstack_sdk/src/api/identity/v3/role/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a role. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("roles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "role" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/roles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/roles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/head.rs b/openstack_sdk/src/api/identity/v3/role/head.rs deleted file mode 100644 index 33fabb867..000000000 --- a/openstack_sdk/src/api/identity/v3/role/head.rs +++ /dev/null @@ -1,185 +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`. - -//! List roles. -//! -//! GET/HEAD /v3/roles -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "roles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("name", self.name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/roles".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/roles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/imply/delete.rs b/openstack_sdk/src/api/identity/v3/role/imply/delete.rs deleted file mode 100644 index 78cb329a3..000000000 --- a/openstack_sdk/src/api/identity/v3/role/imply/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Deletes a role inference rule. -//! -//! Relationship: -//! `https://developer.openstack.org/api-ref/identity/v3/#delete-role-inference-rule` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// implied_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - implied_role_id: Cow<'a, str>, - - /// prior_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - prior_role_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 Imply. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = self.implied_role_id.as_ref(), - prior_role_id = self.prior_role_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_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() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/imply/get.rs b/openstack_sdk/src/api/identity/v3/role/imply/get.rs deleted file mode 100644 index e0f19fd8b..000000000 --- a/openstack_sdk/src/api/identity/v3/role/imply/get.rs +++ /dev/null @@ -1,210 +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`. - -//! Gets a role inference rule. -//! -//! Relationship: -//! `https://developer.openstack.org/api-ref/identity/v3/#get-role-inference-rule` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// implied_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - implied_role_id: Cow<'a, str>, - - /// prior_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - prior_role_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 Imply. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = self.implied_role_id.as_ref(), - prior_role_id = self.prior_role_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role_inference".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "role_inference" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inference": {} })); - }); - - let endpoint = Request::builder() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inference": {} })); - }); - - let endpoint = Request::builder() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/imply/head.rs b/openstack_sdk/src/api/identity/v3/role/imply/head.rs deleted file mode 100644 index 8a7493f33..000000000 --- a/openstack_sdk/src/api/identity/v3/role/imply/head.rs +++ /dev/null @@ -1,202 +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`. - -//! Checks a role role inference rule. -//! -//! Relationship: -//! `https://developer.openstack.org/api-ref/identity/v3/#confirm-role-inference-rule` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// implied_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - implied_role_id: Cow<'a, str>, - - /// prior_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - prior_role_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 Imply. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = self.implied_role_id.as_ref(), - prior_role_id = self.prior_role_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/imply/list.rs b/openstack_sdk/src/api/identity/v3/role/imply/list.rs deleted file mode 100644 index 0390e5af1..000000000 --- a/openstack_sdk/src/api/identity/v3/role/imply/list.rs +++ /dev/null @@ -1,200 +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`. - -//! Lists implied (inference) roles for a role. -//! -//! Relationship: -//! `https://developer.openstack.org/api-ref/identity/v3/#list-implied-roles-for-role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// prior_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - prior_role_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 Imply. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "roles/{prior_role_id}/implies", - prior_role_id = self.prior_role_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role_inference".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "role_inference" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/roles/{prior_role_id}/implies", - prior_role_id = "prior_role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inference": {} })); - }); - - let endpoint = Request::builder() - .prior_role_id("prior_role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/roles/{prior_role_id}/implies", - prior_role_id = "prior_role_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inference": {} })); - }); - - let endpoint = Request::builder() - .prior_role_id("prior_role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/imply/set.rs b/openstack_sdk/src/api/identity/v3/role/imply/set.rs deleted file mode 100644 index 5a4c2fa95..000000000 --- a/openstack_sdk/src/api/identity/v3/role/imply/set.rs +++ /dev/null @@ -1,210 +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`. - -//! Creates a role inference rule. -//! -//! Relationship: -//! `https://developer.openstack.org/api-ref/identity/v3/#create-role-inference-rule` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// implied_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - implied_role_id: Cow<'a, str>, - - /// prior_role_id parameter for - /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API - #[builder(default, setter(into))] - prior_role_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 Imply. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = self.implied_role_id.as_ref(), - prior_role_id = self.prior_role_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role_inference".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "role_inference" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inference": {} })); - }); - - let endpoint = Request::builder() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/roles/{prior_role_id}/implies/{implied_role_id}", - implied_role_id = "implied_role_id", - prior_role_id = "prior_role_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inference": {} })); - }); - - let endpoint = Request::builder() - .implied_role_id("implied_role_id") - .prior_role_id("prior_role_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/list.rs b/openstack_sdk/src/api/identity/v3/role/list.rs deleted file mode 100644 index 002606e72..000000000 --- a/openstack_sdk/src/api/identity/v3/role/list.rs +++ /dev/null @@ -1,194 +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`. - -//! Lists roles. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/roles` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "roles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("name", self.name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("roles".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "roles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/roles".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/roles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role/set.rs b/openstack_sdk/src/api/identity/v3/role/set.rs deleted file mode 100644 index d10f38d4b..000000000 --- a/openstack_sdk/src/api/identity/v3/role/set.rs +++ /dev/null @@ -1,271 +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`. - -//! Updates a role. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// The resource options for the role. Available resource options are -/// `immutable`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) immutable: Option, -} - -/// A `role` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Role<'a> { - /// The new role description. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>>, - - /// The new role name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The resource options for the role. Available resource options are - /// `immutable`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> RoleBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `role` object - #[builder(setter(into))] - pub(crate) role: Role<'a>, - - /// role_id parameter for /v3/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("roles/{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("role", serde_json::to_value(&self.role)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .role(RoleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .role(RoleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "role" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/roles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .role(RoleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/roles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .role(RoleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role_assignment/head.rs b/openstack_sdk/src/api/identity/v3/role_assignment/head.rs deleted file mode 100644 index d0e1904d2..000000000 --- a/openstack_sdk/src/api/identity/v3/role_assignment/head.rs +++ /dev/null @@ -1,221 +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`. - -//! List all role assignments. -//! -//! GET/HEAD /v3/role_assignments -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - effective: Option>, - - #[builder(default, setter(into))] - group_id: Option>, - - #[builder(default, setter(into))] - include_names: Option>, - - #[builder(default, setter(into))] - include_subtree: Option>, - - #[builder(default, setter(into))] - role_id: Option>, - - /// The ID of the domain. - #[builder(default, setter(into))] - scope_domain_id: Option>, - - #[builder(default, setter(into))] - scope_os_inherit_inherited_to: Option>, - - /// The ID of the project. - #[builder(default, setter(into))] - scope_project_id: Option>, - - #[builder(default, setter(into))] - scope_system: Option>, - - /// The ID of the user. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Role_Assignment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "role_assignments".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("effective", self.effective.as_ref()); - params.push_opt("group.id", self.group_id.as_ref()); - params.push_opt("include_names", self.include_names.as_ref()); - params.push_opt("include_subtree", self.include_subtree.as_ref()); - params.push_opt("role.id", self.role_id.as_ref()); - params.push_opt( - "scope.OS-INHERIT:inherited_to", - self.scope_os_inherit_inherited_to.as_ref(), - ); - params.push_opt("scope.domain.id", self.scope_domain_id.as_ref()); - params.push_opt("scope.project.id", self.scope_project_id.as_ref()); - params.push_opt("scope.system", self.scope_system.as_ref()); - params.push_opt("user.id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/role_assignments".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/role_assignments".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role_assignment/list.rs b/openstack_sdk/src/api/identity/v3/role_assignment/list.rs deleted file mode 100644 index 51d925454..000000000 --- a/openstack_sdk/src/api/identity/v3/role_assignment/list.rs +++ /dev/null @@ -1,297 +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 a list of role assignments. -//! -//! If no query parameters are specified, then this API will return a list of -//! all role assignments. -//! -//! Since this list is likely to be very long, this API would typically always -//! be used with one of more of the filter queries. Some typical examples are: -//! -//! `GET /v3/role_assignments?user.id={user_id}` would list all role -//! assignments involving the specified user. -//! -//! `GET /v3/role_assignments?scope.project.id={project_id}` would list all -//! role assignments involving the specified project. -//! -//! It is also possible to list all role assignments within a tree of projects: -//! `GET /v3/role_assignments?scope.project.id={project_id}&include_subtree=true` -//! would list all role assignments involving the specified project and all -//! sub-projects. `include_subtree=true` can only be specified in conjunction -//! with `scope.project.id`, specifying it without this will result in an HTTP -//! 400 Bad Request being returned. -//! -//! Each role assignment entity in the collection contains a link to the -//! assignment that gave rise to this entity. -//! -//! The scope section in the list response is extended to allow the -//! representation of role assignments that are inherited to projects. -//! -//! The query filter `scope.OS-INHERIT:inherited_to` can be used to filter -//! based on role assignments that are inherited. The only value of -//! `scope.OS-INHERIT:inherited_to` that is currently supported is `projects`, -//! indicating that this role is inherited to all projects of the owning domain -//! or parent project. -//! -//! If the query parameter `effective` is specified, rather than simply -//! returning a list of role assignments that have been made, the API returns a -//! list of effective assignments at the user, project and domain level, having -//! allowed for the effects of group membership, role inference rules as well -//! as inheritance from the parent domain or project. Since the effects of -//! group membership have already been allowed for, the group role assignment -//! entities themselves will not be returned in the collection. Likewise, since -//! the effects of inheritance have already been allowed for, the role -//! assignment entities themselves that specify the inheritance will also not -//! be returned in the collection. This represents the effective role -//! assignments that would be included in a scoped token. The same set of query -//! parameters can also be used in combination with the `effective` parameter. -//! -//! For example: -//! -//! `GET /v3/role_assignments?user.id={user_id}&effective` would, in other -//! words, answer the question “what can this user actually do?”. -//! -//! `GET /v3/role_assignments?user.id={user_id}&scope.project.id={project_id}&effective` -//! would return the equivalent set of role assignments that would be included -//! in the token response of a project scoped token. -//! -//! An example response for an API call with the query parameter `effective` -//! specified is given below: -//! -//! The entity `links` section of a response using the `effective` query -//! parameter also contains, for entities that are included by virtue of group -//! membership, a url that can be used to access the membership of the group. -//! -//! If the query parameter `include_names` is specified, rather than simply -//! returning the entity IDs in the role assignments, the collection will -//! additionally include the names of the entities. For example: -//! -//! `GET /v3/role_assignments?user.id={user_id}&effective&include_names=true` -//! would return: -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/role_assignments` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - effective: Option>, - - #[builder(default, setter(into))] - group_id: Option>, - - #[builder(default, setter(into))] - include_names: Option>, - - #[builder(default, setter(into))] - include_subtree: Option>, - - #[builder(default, setter(into))] - role_id: Option>, - - /// The ID of the domain. - #[builder(default, setter(into))] - scope_domain_id: Option>, - - #[builder(default, setter(into))] - scope_os_inherit_inherited_to: Option>, - - /// The ID of the project. - #[builder(default, setter(into))] - scope_project_id: Option>, - - #[builder(default, setter(into))] - scope_system: Option>, - - /// The ID of the user. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Role_Assignment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "role_assignments".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("effective", self.effective.as_ref()); - params.push_opt("group.id", self.group_id.as_ref()); - params.push_opt("include_names", self.include_names.as_ref()); - params.push_opt("include_subtree", self.include_subtree.as_ref()); - params.push_opt("role.id", self.role_id.as_ref()); - params.push_opt( - "scope.OS-INHERIT:inherited_to", - self.scope_os_inherit_inherited_to.as_ref(), - ); - params.push_opt("scope.domain.id", self.scope_domain_id.as_ref()); - params.push_opt("scope.project.id", self.scope_project_id.as_ref()); - params.push_opt("scope.system", self.scope_system.as_ref()); - params.push_opt("user.id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role_assignments".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "role_assignments" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/role_assignments".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_assignments": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/role_assignments".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_assignments": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role_inference/head.rs b/openstack_sdk/src/api/identity/v3/role_inference/head.rs deleted file mode 100644 index 9a014a091..000000000 --- a/openstack_sdk/src/api/identity/v3/role_inference/head.rs +++ /dev/null @@ -1,171 +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`. - -//! List role inference rules. -//! -//! GET/HEAD /v3/role_inferences -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Role_Inference. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "role_inferences".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/role_inferences".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/role_inferences".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/role_inference/list.rs b/openstack_sdk/src/api/identity/v3/role_inference/list.rs deleted file mode 100644 index 367e79aa9..000000000 --- a/openstack_sdk/src/api/identity/v3/role_inference/list.rs +++ /dev/null @@ -1,180 +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`. - -//! Lists all role inference rules. -//! -//! Relationship: -//! `https://developer.openstack.org/api-ref/identity/v3/#list-all-role-inference-rules` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Role_Inference. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "role_inferences".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("role_inferences".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "role_inferences" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/role_inferences".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inferences": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/role_inferences".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "role_inferences": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/s3token/create.rs b/openstack_sdk/src/api/identity/v3/s3token/create.rs deleted file mode 100644 index bae597b85..000000000 --- a/openstack_sdk/src/api/identity/v3/s3token/create.rs +++ /dev/null @@ -1,204 +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`. - -//! Authenticate s3token. -//! -//! POST /v3/s3tokens -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 S3Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "s3tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/s3tokens".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/s3tokens".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/s3token/get.rs b/openstack_sdk/src/api/identity/v3/s3token/get.rs deleted file mode 100644 index 394c991a1..000000000 --- a/openstack_sdk/src/api/identity/v3/s3token/get.rs +++ /dev/null @@ -1,174 +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 operation on /v3/s3tokens -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 S3Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "s3tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/s3tokens".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/s3tokens".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/s3token/head.rs b/openstack_sdk/src/api/identity/v3/s3token/head.rs deleted file mode 100644 index ab8d521c0..000000000 --- a/openstack_sdk/src/api/identity/v3/s3token/head.rs +++ /dev/null @@ -1,169 +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`. - -//! HEAD operation on /v3/s3tokens -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 S3Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "s3tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/s3tokens".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/s3tokens".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/service/create.rs b/openstack_sdk/src/api/identity/v3/service/create.rs deleted file mode 100644 index 51eca5d46..000000000 --- a/openstack_sdk/src/api/identity/v3/service/create.rs +++ /dev/null @@ -1,253 +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`. - -//! Creates a service. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/services` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `service` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Service<'a> { - /// Defines whether the service and its endpoints appear in the service - /// catalog: - `false`. The service and its endpoints do not appear in the - /// service catalog. - `true`. The service and its endpoints appear in the - /// service catalog. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The service name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The service type, which describes the API implemented by the service. - /// Value is `compute`, `ec2`, `identity`, `image`, `network`, or `volume`. - #[serde(rename = "type")] - #[builder(setter(into))] - pub(crate) _type: Cow<'a, str>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> ServiceBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `service` object. - #[builder(setter(into))] - pub(crate) service: Service<'a>, - - #[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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "services".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("service", serde_json::to_value(&self.service)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("service".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service(ServiceBuilder::default()._type("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service(ServiceBuilder::default()._type("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/services".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - let endpoint = Request::builder() - .service(ServiceBuilder::default()._type("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/services".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - let endpoint = Request::builder() - .service(ServiceBuilder::default()._type("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/service/delete.rs b/openstack_sdk/src/api/identity/v3/service/delete.rs deleted file mode 100644 index 5c61f3e92..000000000 --- a/openstack_sdk/src/api/identity/v3/service/delete.rs +++ /dev/null @@ -1,188 +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`. - -//! Deletes a service. -//! -//! If you try to delete a service that still has associated endpoints, this -//! call either deletes all associated endpoints or fails until all endpoints -//! are deleted. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/service` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_id parameter for /v3/services/{service_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<'a> RequestBuilder<'a> { - /// Add a single header to the Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("services/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/services/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/services/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/service/find.rs b/openstack_sdk/src/api/identity/v3/service/find.rs deleted file mode 100644 index 89b7153ba..000000000 --- a/openstack_sdk/src/api/identity/v3/service/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::identity::v3::service::{get as Get, list as List}; - -/// Find for service 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate service in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // service 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") - && let Some(name) = name_as_val.as_str() - && 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/identity/v3/service/get.rs b/openstack_sdk/src/api/identity/v3/service/get.rs deleted file mode 100644 index c41bafa81..000000000 --- a/openstack_sdk/src/api/identity/v3/service/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a service. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/service` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// service_id parameter for /v3/services/{service_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<'a> RequestBuilder<'a> { - /// Add a single header to the Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("services/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("service".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/services/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/services/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/service/head.rs b/openstack_sdk/src/api/identity/v3/service/head.rs deleted file mode 100644 index f3cc0d164..000000000 --- a/openstack_sdk/src/api/identity/v3/service/head.rs +++ /dev/null @@ -1,171 +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`. - -//! List all services. -//! -//! GET /v3/services -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "services".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/services".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/services".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/service/list.rs b/openstack_sdk/src/api/identity/v3/service/list.rs deleted file mode 100644 index 2d6cec7d4..000000000 --- a/openstack_sdk/src/api/identity/v3/service/list.rs +++ /dev/null @@ -1,189 +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`. - -//! Lists all services. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/services` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filters the response by a domain ID. - #[builder(default, setter(into))] - service: 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> { - /// Add a single header to the Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "services".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("service", self.service.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("services".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "services" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/services".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "services": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/services".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "services": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/service/set.rs b/openstack_sdk/src/api/identity/v3/service/set.rs deleted file mode 100644 index 3ba77765f..000000000 --- a/openstack_sdk/src/api/identity/v3/service/set.rs +++ /dev/null @@ -1,262 +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`. - -//! Updates a service. -//! -//! The request body is the same as the create service request body, except -//! that you include only those attributes that you want to update. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/services` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// A `service` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Service<'a> { - /// Defines whether the service and its endpoints appear in the service - /// catalog: - `false`. The service and its endpoints do not appear in the - /// service catalog. - `true`. The service and its endpoints appear in the - /// service catalog. Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// The service name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The service type, which describes the API implemented by the service. - /// Value is `compute`, `ec2`, `identity`, `image`, `network`, or `volume`. - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _type: Option>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> ServiceBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `service` object. - #[builder(setter(into))] - pub(crate) service: Service<'a>, - - /// service_id parameter for /v3/services/{service_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<'a> RequestBuilder<'a> { - /// Add a single header to the Service. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("services/{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("service", serde_json::to_value(&self.service)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("service".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service(ServiceBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service(ServiceBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/services/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service(ServiceBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/services/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service(ServiceBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/group/role/delete.rs b/openstack_sdk/src/api/identity/v3/system/group/role/delete.rs deleted file mode 100644 index 8724bac4b..000000000 --- a/openstack_sdk/src/api/identity/v3/system/group/role/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! Remove a system role assignment from a group. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "system/groups/{group_id}/roles/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_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() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/group/role/get.rs b/openstack_sdk/src/api/identity/v3/system/group/role/get.rs deleted file mode 100644 index 7aa5564dd..000000000 --- a/openstack_sdk/src/api/identity/v3/system/group/role/get.rs +++ /dev/null @@ -1,206 +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 a specific system role assignment for a group. This is the same API as -//! `HEAD /v3/system/groups/{group_id}/roles/{role_id}`. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "system/groups/{group_id}/roles/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_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() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/group/role/head.rs b/openstack_sdk/src/api/identity/v3/system/group/role/head.rs deleted file mode 100644 index 68b7cfc8b..000000000 --- a/openstack_sdk/src/api/identity/v3/system/group/role/head.rs +++ /dev/null @@ -1,200 +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`. - -//! Check if a specific group has a role assignment on the system. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "system/groups/{group_id}/roles/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/group/role/list.rs b/openstack_sdk/src/api/identity/v3/system/group/role/list.rs deleted file mode 100644 index a86911503..000000000 --- a/openstack_sdk/src/api/identity/v3/system/group/role/list.rs +++ /dev/null @@ -1,196 +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`. - -//! Lists all system role assignment a group has. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_roles` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "system/groups/{group_id}/roles", - group_id = self.group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("roles".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "roles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/system/groups/{group_id}/roles", - group_id = "group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder().group_id("group_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/system/groups/{group_id}/roles", - group_id = "group_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/group/role/set.rs b/openstack_sdk/src/api/identity/v3/system/group/role/set.rs deleted file mode 100644 index 66298e8f1..000000000 --- a/openstack_sdk/src/api/identity/v3/system/group/role/set.rs +++ /dev/null @@ -1,205 +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`. - -//! Grant a group a role on the system. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API - #[builder(default, setter(into))] - group_id: Cow<'a, str>, - - /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { - /// Add a single header to the Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "system/groups/{group_id}/roles/{id}", - group_id = self.group_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .group_id("group_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/system/groups/{group_id}/roles/{id}", - group_id = "group_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() - .group_id("group_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/user/role/delete.rs b/openstack_sdk/src/api/identity/v3/system/user/role/delete.rs deleted file mode 100644 index c74919fd8..000000000 --- a/openstack_sdk/src/api/identity/v3/system/user/role/delete.rs +++ /dev/null @@ -1,205 +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`. - -//! Remove a system role assignment from a user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "system/users/{user_id}/roles/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_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") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/user/role/get.rs b/openstack_sdk/src/api/identity/v3/system/user/role/get.rs deleted file mode 100644 index aeb3be7b5..000000000 --- a/openstack_sdk/src/api/identity/v3/system/user/role/get.rs +++ /dev/null @@ -1,206 +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 a specific system role assignment for a user. This is the same API as -//! `HEAD /v3/system/users/{user_id}/roles/{role_id}`. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "system/users/{user_id}/roles/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_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") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/user/role/head.rs b/openstack_sdk/src/api/identity/v3/system/user/role/head.rs deleted file mode 100644 index f984fd089..000000000 --- a/openstack_sdk/src/api/identity/v3/system/user/role/head.rs +++ /dev/null @@ -1,200 +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`. - -//! Check if a specific user has a role assignment on the system. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "system/users/{user_id}/roles/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/user/role/list.rs b/openstack_sdk/src/api/identity/v3/system/user/role/list.rs deleted file mode 100644 index 14b24c14e..000000000 --- a/openstack_sdk/src/api/identity/v3/system/user/role/list.rs +++ /dev/null @@ -1,196 +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`. - -//! Lists all system role assignment a user has. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_roles` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "system/users/{user_id}/roles", - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("roles".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "roles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/system/users/{user_id}/roles", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/system/users/{user_id}/roles", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "roles": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/system/user/role/set.rs b/openstack_sdk/src/api/identity/v3/system/user/role/set.rs deleted file mode 100644 index 8138c961f..000000000 --- a/openstack_sdk/src/api/identity/v3/system/user/role/set.rs +++ /dev/null @@ -1,205 +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`. - -//! Grant a user a role on the system. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "system/users/{user_id}/roles/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/system/users/{user_id}/roles/{id}", - id = "id", - user_id = "user_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") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/access_rule/delete.rs b/openstack_sdk/src/api/identity/v3/user/access_rule/delete.rs deleted file mode 100644 index 1ee131d65..000000000 --- a/openstack_sdk/src/api/identity/v3/user/access_rule/delete.rs +++ /dev/null @@ -1,208 +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`. - -//! Delete an access rule. An access rule that is still in use by an -//! application credential cannot be deleted. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/access_rules` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_rule_id parameter for - /// /v3/users/{user_id}/access_rules/{access_rule_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} - /// API - #[builder(default, setter(into))] - user_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 Access_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/access_rules/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/users/{user_id}/access_rules/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/users/{user_id}/access_rules/{id}", - id = "id", - user_id = "user_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") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/access_rule/find.rs b/openstack_sdk/src/api/identity/v3/user/access_rule/find.rs deleted file mode 100644 index 6a1938ed6..000000000 --- a/openstack_sdk/src/api/identity/v3/user/access_rule/find.rs +++ /dev/null @@ -1,120 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; -use serde::de::DeserializeOwned; -use tracing::trace; - -use crate::api::common::CommaSeparatedList; -use crate::api::find::Findable; -use crate::api::rest_endpoint_prelude::*; -use crate::api::ParamValue; - -use crate::api::{ApiError, Client, Pageable, Query, RestClient}; - -use crate::api::identity::v3::user::access_rule::{get as Get, list as List}; - -/// Find for user/access_rule by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[builder(default, setter(into))] - user_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 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<'a>; - fn get_ep(&self) -> Result, crate::api::ApiError> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.user_id(self.user_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().map_err(|err| ApiError::endpoint_builder(err)) - } - fn list_ep(&self) -> Result, crate::api::ApiError> { - let mut ep = List::Request::builder(); - ep.user_id(self.user_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().map_err(|err| ApiError::endpoint_builder(err)) - } - /// Locate user/access_rule in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // user/access_rule 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/identity/v3/user/access_rule/get.rs b/openstack_sdk/src/api/identity/v3/user/access_rule/get.rs deleted file mode 100644 index 5bc614216..000000000 --- a/openstack_sdk/src/api/identity/v3/user/access_rule/get.rs +++ /dev/null @@ -1,210 +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 details of an access rule. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/access_rules` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_rule_id parameter for - /// /v3/users/{user_id}/access_rules/{access_rule_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} - /// API - #[builder(default, setter(into))] - user_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 Access_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/access_rules/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("access_rule".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "access_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/access_rules/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "access_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/access_rules/{id}", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "access_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/access_rule/head.rs b/openstack_sdk/src/api/identity/v3/user/access_rule/head.rs deleted file mode 100644 index ea6774e92..000000000 --- a/openstack_sdk/src/api/identity/v3/user/access_rule/head.rs +++ /dev/null @@ -1,201 +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 access rule resource. -//! -//! GET/HEAD /v3/users/{user_id}/access_rules/{access_rule_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_rule_id parameter for - /// /v3/users/{user_id}/access_rules/{access_rule_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} - /// API - #[builder(default, setter(into))] - user_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 Access_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "users/{user_id}/access_rules/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/users/{user_id}/access_rules/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/users/{user_id}/access_rules/{id}", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/access_rule/list.rs b/openstack_sdk/src/api/identity/v3/user/access_rule/list.rs deleted file mode 100644 index dda24c0a2..000000000 --- a/openstack_sdk/src/api/identity/v3/user/access_rule/list.rs +++ /dev/null @@ -1,216 +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`. - -//! List all access rules for a user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/access_rules` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The request method that the application credential is permitted to use - /// for a given API endpoint. - #[builder(default, setter(into))] - method: Option>, - - /// The API path that the application credential is permitted to access. - #[builder(default, setter(into))] - path: Option>, - - /// The service type identifier for the service that the application is - /// permitted to access. - #[builder(default, setter(into))] - service: Option>, - - /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} - /// API - #[builder(default, setter(into))] - user_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 Access_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/access_rules", - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("method", self.method.as_ref()); - params.push_opt("path", self.path.as_ref()); - params.push_opt("service", self.service.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("access_rules".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "access_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/access_rules", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "access_rules": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/access_rules", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "access_rules": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/application_credential/create.rs b/openstack_sdk/src/api/identity/v3/user/application_credential/create.rs deleted file mode 100644 index b8bf665b4..000000000 --- a/openstack_sdk/src/api/identity/v3/user/application_credential/create.rs +++ /dev/null @@ -1,368 +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`. - -//! Creates an application credential for a user on the project to which the -//! current token is scoped. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Method { - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "PATCH")] - Patch, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AccessRules<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The request method that the application credential is permitted to use - /// for a given API endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) method: Option, - - /// The API path that the application credential is permitted to access. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) path: Option>, - - /// The service type identifier for the service that the application - /// credential is permitted to access. Must be a service type that is - /// listed in the service catalog and not a code name for a service. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Roles<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The resource name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// An application credential object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ApplicationCredential<'a> { - /// A list of `access_rules` objects - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) access_rules: Option>>, - - /// A description of the application credential’s purpose. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// An optional expiry time for the application credential. If unset, the - /// application credential does not expire. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expires_at: Option>>, - - /// The UUID for the credential. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The name of the application credential. Must be unique to a user. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The ID of the project the application credential was created for and - /// that authentication requests using this application credential will be - /// scoped to. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// An optional list of role objects, identified by ID or name. The list - /// may only contain roles that the user has assigned on the project. If - /// not provided, the roles assigned to the application credential will be - /// the same as the roles in the current token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) roles: Option>>, - - /// The secret that the application credential will be created with. If not - /// provided, one will be generated. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) secret: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) system: Option>>, - - /// An optional flag to restrict whether the application credential may be - /// used for the creation or destruction of other application credentials - /// or trusts. Defaults to false. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) unrestricted: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An application credential object. - #[builder(setter(into))] - pub(crate) application_credential: ApplicationCredential<'a>, - - /// user_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - user_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 Application_Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "users/{user_id}/application_credentials", - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "application_credential", - serde_json::to_value(&self.application_credential)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("application_credential".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .application_credential( - ApplicationCredentialBuilder::default() - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .application_credential( - ApplicationCredentialBuilder::default() - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "application_credential" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/users/{user_id}/application_credentials", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "application_credential": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .application_credential( - ApplicationCredentialBuilder::default() - .name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/users/{user_id}/application_credentials", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "application_credential": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .application_credential( - ApplicationCredentialBuilder::default() - .name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/application_credential/delete.rs b/openstack_sdk/src/api/identity/v3/user/application_credential/delete.rs deleted file mode 100644 index d5116eb75..000000000 --- a/openstack_sdk/src/api/identity/v3/user/application_credential/delete.rs +++ /dev/null @@ -1,209 +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`. - -//! Delete an application credential. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// application_credential_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - user_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 Application_Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/application_credentials/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/users/{user_id}/application_credentials/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/users/{user_id}/application_credentials/{id}", - id = "id", - user_id = "user_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") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/application_credential/find.rs b/openstack_sdk/src/api/identity/v3/user/application_credential/find.rs deleted file mode 100644 index 61778b9a1..000000000 --- a/openstack_sdk/src/api/identity/v3/user/application_credential/find.rs +++ /dev/null @@ -1,96 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::identity::v3::user::application_credential::{get as Get, list as List}; - -/// Find for user/application_credential by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[builder(default, setter(into))] - user_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 Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.user_id(self.user_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - let mut ep = List::Request::builder(); - ep.user_id(self.user_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/application_credential/get.rs b/openstack_sdk/src/api/identity/v3/user/application_credential/get.rs deleted file mode 100644 index 4d32fa7d6..000000000 --- a/openstack_sdk/src/api/identity/v3/user/application_credential/get.rs +++ /dev/null @@ -1,212 +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 details of an application credential. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// application_credential_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - user_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 Application_Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/application_credentials/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("application_credential".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "application_credential" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/application_credentials/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "application_credential": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/application_credentials/{id}", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "application_credential": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/application_credential/head.rs b/openstack_sdk/src/api/identity/v3/user/application_credential/head.rs deleted file mode 100644 index 38418f467..000000000 --- a/openstack_sdk/src/api/identity/v3/user/application_credential/head.rs +++ /dev/null @@ -1,204 +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 application credential resource. -//! -//! GET/HEAD /v3/users/{user_id}/application_credentials/ -//! {application_credential_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// application_credential_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - user_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 Application_Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "users/{user_id}/application_credentials/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/users/{user_id}/application_credentials/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/users/{user_id}/application_credentials/{id}", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/application_credential/list.rs b/openstack_sdk/src/api/identity/v3/user/application_credential/list.rs deleted file mode 100644 index 11063e4d4..000000000 --- a/openstack_sdk/src/api/identity/v3/user/application_credential/list.rs +++ /dev/null @@ -1,205 +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`. - -//! List all application credentials for a user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The name of the application credential. Must be unique to a user. - #[builder(default, setter(into))] - name: Option>, - - /// user_id parameter for - /// /v3/users/{user_id}/application_credentials/{application_credential_id} - /// API - #[builder(default, setter(into))] - user_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 Application_Credential. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/application_credentials", - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("name", self.name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("application_credentials".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "application_credentials" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/application_credentials", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "application_credentials": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/application_credentials", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "application_credentials": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/create.rs b/openstack_sdk/src/api/identity/v3/user/create.rs deleted file mode 100644 index d73341407..000000000 --- a/openstack_sdk/src/api/identity/v3/user/create.rs +++ /dev/null @@ -1,379 +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`. - -//! Creates a user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/users` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Protocols<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_id: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) unique_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Federated<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) idp_id: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) protocols: Vec>, -} - -/// The resource options for the user. Available resource options are -/// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, -/// `ignore_lockout_failure_attempts`, `lock_password`, -/// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` -/// `ignore_user_inactivity`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_change_password_upon_first_use: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_lockout_failure_attempts: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_password_expiry: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_user_inactivity: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) lock_password: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) multi_factor_auth_enabled: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_multi_factor_auth_rules"))] - pub(crate) multi_factor_auth_rules: Option>>>, -} - -impl<'a> OptionsBuilder<'a> { - pub fn multi_factor_auth_rules(&mut self, iter: I1) -> &mut Self - where - I1: Iterator, - I2: IntoIterator, - V: Into>, - { - self.multi_factor_auth_rules - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(|x| Vec::from_iter(x.into_iter().map(Into::into)))); - self - } -} - -/// A `user` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User<'a> { - /// The ID of the default project for the user. A user’s default project - /// must not be a domain. Setting this attribute does not grant any actual - /// authorization on the project, and is merely provided for convenience. - /// Therefore, the referenced project does not need to exist within the - /// user domain. (Since v3.1) If the user does not have authorization to - /// their default project, the default project is ignored at token - /// creation. (Since v3.1) Additionally, if your default project is not - /// valid, a token is issued without an explicit scope of authorization. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_project_id: Option>>, - - /// The description of the user resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the domain of the user. If the domain ID is not provided in - /// the request, the Identity service will attempt to pull the domain ID - /// from the token used in the request. Note that this requires the use of - /// a domain-scoped token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>, - - /// If the user is enabled, this value is `true`. If the user is disabled, - /// this value is `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// List of federated objects associated with a user. Each object in the - /// list contains the `idp_id` and `protocols`. `protocols` is a list of - /// objects, each of which contains `protocol_id` and `unique_id` of the - /// protocol and user respectively. For example: - /// - /// ```text - /// "federated": [ - /// { - /// "idp_id": "efbab5a6acad4d108fec6c63d9609d83", - /// "protocols": [ - /// {"protocol_id": mapped, "unique_id": "test@example.com"} - /// ] - /// } - /// ] - /// ``` - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) federated: Option>>, - - /// The user name. Must be unique within the owning domain. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The resource options for the user. Available resource options are - /// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, - /// `ignore_lockout_failure_attempts`, `lock_password`, - /// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` - /// `ignore_user_inactivity`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option>, - - /// The password for the user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) password: Option>>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> UserBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `user` object - #[builder(setter(into))] - pub(crate) user: User<'a>, - - #[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 User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "users".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("user", serde_json::to_value(&self.user)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("user".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .user(UserBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .user(UserBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "user" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/users".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "user": {} })); - }); - - let endpoint = Request::builder() - .user(UserBuilder::default().name("foo").build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/users".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "user": {} })); - }); - - let endpoint = Request::builder() - .user(UserBuilder::default().name("foo").build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/create.rs b/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/create.rs deleted file mode 100644 index 22bafc709..000000000 --- a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/create.rs +++ /dev/null @@ -1,220 +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`. - -//! Create EC2 Credential for user. -//! -//! POST /v3/users/{user_id}/credentials/OS-EC2 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - user_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Os_Ec2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "users/{user_id}/credentials/OS-EC2", - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/users/{user_id}/credentials/OS-EC2", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/users/{user_id}/credentials/OS-EC2", - user_id = "user_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() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/delete.rs b/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/delete.rs deleted file mode 100644 index 826538d99..000000000 --- a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/delete.rs +++ /dev/null @@ -1,206 +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`. - -//! Delete a specific EC2 credential. -//! -//! DELETE /users/{user_id}/credentials/OS-EC2/{credential_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// credential_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - credential_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - user_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 Os_Ec2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = self.credential_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = "credential_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .credential_id("credential_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = "credential_id", - user_id = "user_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() - .credential_id("credential_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/get.rs b/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/get.rs deleted file mode 100644 index 0dc06fde5..000000000 --- a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/get.rs +++ /dev/null @@ -1,206 +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 a specific EC2 credential. -//! -//! GET/HEAD /users/{user_id}/credentials/OS-EC2/{credential_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// credential_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - credential_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - user_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 Os_Ec2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = self.credential_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = "credential_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .credential_id("credential_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = "credential_id", - user_id = "user_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() - .credential_id("credential_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/head.rs b/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/head.rs deleted file mode 100644 index 0ff06cde3..000000000 --- a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/head.rs +++ /dev/null @@ -1,201 +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 a specific EC2 credential. -//! -//! GET/HEAD /users/{user_id}/credentials/OS-EC2/{credential_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// credential_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - credential_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - user_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 Os_Ec2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = self.credential_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = "credential_id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .credential_id("credential_id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/users/{user_id}/credentials/OS-EC2/{credential_id}", - credential_id = "credential_id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .credential_id("credential_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/list.rs b/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/list.rs deleted file mode 100644 index 1f9610de3..000000000 --- a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2/list.rs +++ /dev/null @@ -1,193 +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`. - -//! List EC2 Credentials for user. -//! -//! GET/HEAD /v3/users/{user_id}/credentials/OS-EC2 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for - /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API - #[builder(default, setter(into))] - user_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 Os_Ec2. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/credentials/OS-EC2", - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/credentials/OS-EC2", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/credentials/OS-EC2", - user_id = "user_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() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/delete.rs b/openstack_sdk/src/api/identity/v3/user/delete.rs deleted file mode 100644 index 57d608c56..000000000 --- a/openstack_sdk/src/api/identity/v3/user/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Deletes a user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/user` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for /v3/users/{user_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("users/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/users/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/users/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/find.rs b/openstack_sdk/src/api/identity/v3/user/find.rs deleted file mode 100644 index 0c6338a23..000000000 --- a/openstack_sdk/src/api/identity/v3/user/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::identity::v3::user::{get as Get, list as List}; - -/// Find for user 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/get.rs b/openstack_sdk/src/api/identity/v3/user/get.rs deleted file mode 100644 index 4b5dea9c6..000000000 --- a/openstack_sdk/src/api/identity/v3/user/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Shows details for a user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/user` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for /v3/users/{user_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("users/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("user".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "user" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/users/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "user": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/users/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "user": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/group/head.rs b/openstack_sdk/src/api/identity/v3/user/group/head.rs deleted file mode 100644 index d0bdc32eb..000000000 --- a/openstack_sdk/src/api/identity/v3/user/group/head.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`. - -//! Get groups for a user. -//! -//! GET/HEAD /v3/users/{user_id}/groups -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for /v3/users/{user_id}/groups API - #[builder(default, setter(into))] - user_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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("users/{user_id}/groups", user_id = self.user_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/users/{user_id}/groups", user_id = "user_id",)); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/users/{user_id}/groups", user_id = "user_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/group/list.rs b/openstack_sdk/src/api/identity/v3/user/group/list.rs deleted file mode 100644 index 7ba62a80b..000000000 --- a/openstack_sdk/src/api/identity/v3/user/group/list.rs +++ /dev/null @@ -1,187 +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`. - -//! Lists groups to which a user belongs. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/user_groups` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for /v3/users/{user_id}/groups API - #[builder(default, setter(into))] - user_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 Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("users/{user_id}/groups", user_id = self.user_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("groups".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/users/{user_id}/groups", user_id = "user_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/users/{user_id}/groups", user_id = "user_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "groups": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/head.rs b/openstack_sdk/src/api/identity/v3/user/head.rs deleted file mode 100644 index 39307502c..000000000 --- a/openstack_sdk/src/api/identity/v3/user/head.rs +++ /dev/null @@ -1,246 +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`. - -//! List users. -//! -//! GET/HEAD /v3/users -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - /// Whether the identity provider is enabled or not - #[builder(default)] - enabled: Option, - - /// Filters the response by an identity provider ID. - #[builder(default, setter(into))] - idp_id: Option>, - - #[builder(default)] - limit: Option, - - /// ID of the last fetched entry - #[builder(default, setter(into))] - marker: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: Option>, - - /// Filter results based on which user passwords have expired. The query - /// should include an operator and a timestamp with a colon (:) separating - /// the two, for example: `password_expires_at={operator}:{timestamp}` - /// Valid operators are: lt, lte, gt, gte, eq, and neq - /// - /// - lt: expiration time lower than the timestamp - /// - lte: expiration time lower than or equal to the timestamp - /// - gt: expiration time higher than the timestamp - /// - gte: expiration time higher than or equal to the timestamp - /// - eq: expiration time equal to the timestamp - /// - neq: expiration time not equal to the timestamp - /// - /// Valid timestamps are of the form: `YYYY-MM-DDTHH:mm:ssZ`.For - /// example:`/v3/users?password_expires_at=lt:2016-12-08T22:02:00Z` The - /// example would return a list of users whose password expired before the - /// timestamp `(2016-12-08T22:02:00Z).` - #[builder(default, setter(into))] - password_expires_at: Option>, - - /// Filters the response by a protocol ID. - #[builder(default, setter(into))] - protocol_id: Option>, - - /// Sort direction. A valid value is asc (ascending) or desc (descending). - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts resources by attribute. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filters the response by a unique ID. - #[builder(default, setter(into))] - unique_id: 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> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "users".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("enabled", self.enabled); - params.push_opt("idp_id", self.idp_id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("password_expires_at", self.password_expires_at.as_ref()); - params.push_opt("protocol_id", self.protocol_id.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("unique_id", self.unique_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/users".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/users".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/list.rs b/openstack_sdk/src/api/identity/v3/user/list.rs deleted file mode 100644 index 209657b3d..000000000 --- a/openstack_sdk/src/api/identity/v3/user/list.rs +++ /dev/null @@ -1,255 +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`. - -//! Lists users. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/users` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the domain. - #[builder(default, setter(into))] - domain_id: Option>, - - /// Whether the identity provider is enabled or not - #[builder(default)] - enabled: Option, - - /// Filters the response by an identity provider ID. - #[builder(default, setter(into))] - idp_id: Option>, - - #[builder(default)] - limit: Option, - - /// ID of the last fetched entry - #[builder(default, setter(into))] - marker: Option>, - - /// The resource name. - #[builder(default, setter(into))] - name: Option>, - - /// Filter results based on which user passwords have expired. The query - /// should include an operator and a timestamp with a colon (:) separating - /// the two, for example: `password_expires_at={operator}:{timestamp}` - /// Valid operators are: lt, lte, gt, gte, eq, and neq - /// - /// - lt: expiration time lower than the timestamp - /// - lte: expiration time lower than or equal to the timestamp - /// - gt: expiration time higher than the timestamp - /// - gte: expiration time higher than or equal to the timestamp - /// - eq: expiration time equal to the timestamp - /// - neq: expiration time not equal to the timestamp - /// - /// Valid timestamps are of the form: `YYYY-MM-DDTHH:mm:ssZ`.For - /// example:`/v3/users?password_expires_at=lt:2016-12-08T22:02:00Z` The - /// example would return a list of users whose password expired before the - /// timestamp `(2016-12-08T22:02:00Z).` - #[builder(default, setter(into))] - password_expires_at: Option>, - - /// Filters the response by a protocol ID. - #[builder(default, setter(into))] - protocol_id: Option>, - - /// Sort direction. A valid value is asc (ascending) or desc (descending). - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts resources by attribute. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filters the response by a unique ID. - #[builder(default, setter(into))] - unique_id: 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> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "users".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("enabled", self.enabled); - params.push_opt("idp_id", self.idp_id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("password_expires_at", self.password_expires_at.as_ref()); - params.push_opt("protocol_id", self.protocol_id.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("unique_id", self.unique_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("users".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(3, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "users" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/users".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "users": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/users".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "users": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/delete.rs b/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/delete.rs deleted file mode 100644 index f29780917..000000000 --- a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/delete.rs +++ /dev/null @@ -1,206 +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`. - -//! Delete specific access token. -//! -//! DELETE /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_token_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API - #[builder(default, setter(into))] - user_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 Access_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = "id", - user_id = "user_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") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/get.rs b/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/get.rs deleted file mode 100644 index d0be09a9b..000000000 --- a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/get.rs +++ /dev/null @@ -1,206 +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 specific access token. -//! -//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_token_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API - #[builder(default, setter(into))] - user_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 Access_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = "id", - user_id = "user_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") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/head.rs b/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/head.rs deleted file mode 100644 index 29e63f17f..000000000 --- a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/head.rs +++ /dev/null @@ -1,201 +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 specific access token. -//! -//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_token_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API - #[builder(default, setter(into))] - user_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 Access_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = "id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/list.rs b/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/list.rs deleted file mode 100644 index 27a7fe017..000000000 --- a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/list.rs +++ /dev/null @@ -1,193 +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`. - -//! List OAuth1 Access Tokens for user. -//! -//! GET /v3/users/{user_id}/OS-OAUTH1/access_tokens -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API - #[builder(default, setter(into))] - user_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 Access_Token. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/OS-OAUTH1/access_tokens", - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens", - user_id = "user_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() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/get.rs b/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/get.rs deleted file mode 100644 index cc6d7eb77..000000000 --- a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/get.rs +++ /dev/null @@ -1,220 +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 role for access token. -//! -//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/ -//! {access_token_id}/roles/{role_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_token_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - access_token_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", - access_token_id = self.access_token_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", - access_token_id = "access_token_id", - id = "id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .access_token_id("access_token_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", - access_token_id = "access_token_id", - id = "id", - user_id = "user_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() - .access_token_id("access_token_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/head.rs b/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/head.rs deleted file mode 100644 index bbcffcbe3..000000000 --- a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/head.rs +++ /dev/null @@ -1,215 +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 role for access token. -//! -//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/ -//! {access_token_id}/roles/{role_id} -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_token_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - access_token_id: Cow<'a, str>, - - /// role_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", - access_token_id = self.access_token_id.as_ref(), - id = self.id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", - access_token_id = "access_token_id", - id = "id", - user_id = "user_id", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .access_token_id("access_token_id") - .id("id") - .user_id("user_id") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", - access_token_id = "access_token_id", - id = "id", - user_id = "user_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .access_token_id("access_token_id") - .id("id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/list.rs b/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/list.rs deleted file mode 100644 index 62d7ba8f5..000000000 --- a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role/list.rs +++ /dev/null @@ -1,209 +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`. - -//! List roles for a user access token. -//! -//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/ -//! {access_token_id}/roles -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// access_token_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - access_token_id: Cow<'a, str>, - - /// user_id parameter for - /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} - /// API - #[builder(default, setter(into))] - user_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 Role. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles", - access_token_id = self.access_token_id.as_ref(), - user_id = self.user_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles", - access_token_id = "access_token_id", - user_id = "user_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .access_token_id("access_token_id") - .user_id("user_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles", - access_token_id = "access_token_id", - user_id = "user_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() - .access_token_id("access_token_id") - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/password/set.rs b/openstack_sdk/src/api/identity/v3/user/password/set.rs deleted file mode 100644 index 45684b5ea..000000000 --- a/openstack_sdk/src/api/identity/v3/user/password/set.rs +++ /dev/null @@ -1,255 +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`. - -//! Changes the password for a user. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/user_change_password` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::serialize_sensitive_string; -use secrecy::SecretString; -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `user` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User { - /// The original password for the user. - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) original_password: SecretString, - - /// The new password for the user. - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) password: SecretString, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `user` object - #[builder(setter(into))] - pub(crate) user: User, - - /// user_id parameter for /v3/users/{user_id}/password API - #[builder(default, setter(into))] - user_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 Password. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("users/{user_id}/password", user_id = self.user_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("user", serde_json::to_value(&self.user)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .user( - UserBuilder::default() - .original_password("foo") - .password("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .user( - UserBuilder::default() - .original_password("foo") - .password("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/users/{user_id}/password", user_id = "user_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .user( - UserBuilder::default() - .original_password("foo") - .password("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/users/{user_id}/password", user_id = "user_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() - .user_id("user_id") - .user( - UserBuilder::default() - .original_password("foo") - .password("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/project/head.rs b/openstack_sdk/src/api/identity/v3/user/project/head.rs deleted file mode 100644 index dba54a18c..000000000 --- a/openstack_sdk/src/api/identity/v3/user/project/head.rs +++ /dev/null @@ -1,176 +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`. - -//! HEAD operation on /v3/users/{user_id}/projects -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for /v3/users/{user_id}/projects API - #[builder(default, setter(into))] - user_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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("users/{user_id}/projects", user_id = self.user_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/users/{user_id}/projects", user_id = "user_id",)); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/users/{user_id}/projects", user_id = "user_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/project/list.rs b/openstack_sdk/src/api/identity/v3/user/project/list.rs deleted file mode 100644 index 124e7a96e..000000000 --- a/openstack_sdk/src/api/identity/v3/user/project/list.rs +++ /dev/null @@ -1,187 +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`. - -//! List projects to which the user has authorization to access. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/user_projects` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// user_id parameter for /v3/users/{user_id}/projects API - #[builder(default, setter(into))] - user_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 Project. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("users/{user_id}/projects", user_id = self.user_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("projects".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "projects" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/users/{user_id}/projects", user_id = "user_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder().user_id("user_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/users/{user_id}/projects", user_id = "user_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "projects": {} })); - }); - - let endpoint = Request::builder() - .user_id("user_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/user/set.rs b/openstack_sdk/src/api/identity/v3/user/set.rs deleted file mode 100644 index 8f74daaf1..000000000 --- a/openstack_sdk/src/api/identity/v3/user/set.rs +++ /dev/null @@ -1,385 +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`. - -//! Updates a user. -//! -//! If the back-end driver does not support this functionality, this call might -//! return the HTTP `Not Implemented (501)` response code. -//! -//! Relationship: -//! `https://docs.openstack.org/api/openstack-identity/3/rel/user` -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Protocols<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_id: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) unique_id: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Federated<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) idp_id: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) protocols: Vec>, -} - -/// The resource options for the user. Available resource options are -/// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, -/// `ignore_lockout_failure_attempts`, `lock_password`, -/// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` -/// `ignore_user_inactivity`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Options<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_change_password_upon_first_use: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_lockout_failure_attempts: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_password_expiry: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ignore_user_inactivity: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) lock_password: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) multi_factor_auth_enabled: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_multi_factor_auth_rules"))] - pub(crate) multi_factor_auth_rules: Option>>>, -} - -impl<'a> OptionsBuilder<'a> { - pub fn multi_factor_auth_rules(&mut self, iter: I1) -> &mut Self - where - I1: Iterator, - I2: IntoIterator, - V: Into>, - { - self.multi_factor_auth_rules - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(|x| Vec::from_iter(x.into_iter().map(Into::into)))); - self - } -} - -/// A `user` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct User<'a> { - /// The new ID of the default project for the user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_project_id: Option>>, - - /// The description of the user resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// The ID of the new domain for the user. The ability to change the domain - /// of a user is now deprecated, and will be removed in subsequent release. - /// It is already disabled by default in most Identity service - /// implementations. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>, - - /// Enables or disables the user. An enabled user can authenticate and - /// receive authorization. A disabled user cannot authenticate or receive - /// authorization. Additionally, all tokens that the user holds become no - /// longer valid. If you reenable this user, pre-existing tokens do not - /// become valid. To enable the user, set to `true`. To disable the user, - /// set to `false`. Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// List of federated objects associated with a user. Each object in the - /// list contains the `idp_id` and `protocols`. `protocols` is a list of - /// objects, each of which contains `protocol_id` and `unique_id` of the - /// protocol and user respectively. For example: - /// - /// ```text - /// "federated": [ - /// { - /// "idp_id": "efbab5a6acad4d108fec6c63d9609d83", - /// "protocols": [ - /// {"protocol_id": mapped, "unique_id": "test@example.com"} - /// ] - /// } - /// ] - /// ``` - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) federated: Option>>, - - /// The new name for the user. Must be unique within the owning domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The resource options for the user. Available resource options are - /// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, - /// `ignore_lockout_failure_attempts`, `lock_password`, - /// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` - /// `ignore_user_inactivity`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) options: Option>, - - /// The new password for the user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) password: Option>>, - - #[builder(setter(name = "_properties"), default, private)] - #[serde(flatten)] - _properties: BTreeMap, Value>, -} - -impl<'a> UserBuilder<'a> { - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `user` object - #[builder(setter(into))] - pub(crate) user: User<'a>, - - /// user_id parameter for /v3/users/{user_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<'a> RequestBuilder<'a> { - /// Add a single header to the User. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("users/{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("user", serde_json::to_value(&self.user)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("user".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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .user(UserBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .user(UserBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "user" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/users/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "user": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user(UserBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PATCH) - .path(format!("/users/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "user": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .user(UserBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/version/get.rs b/openstack_sdk/src/api/identity/v3/version/get.rs deleted file mode 100644 index 34ca69272..000000000 --- a/openstack_sdk/src/api/identity/v3/version/get.rs +++ /dev/null @@ -1,173 +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 operation on /v3 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v3/version/head.rs b/openstack_sdk/src/api/identity/v3/version/head.rs deleted file mode 100644 index d40456fc3..000000000 --- a/openstack_sdk/src/api/identity/v3/version/head.rs +++ /dev/null @@ -1,168 +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`. - -//! HEAD operation on /v3 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - "".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(3, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path("/".to_string()); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path("/".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/identity_provider/create.rs b/openstack_sdk/src/api/identity/v4/federation/identity_provider/create.rs deleted file mode 100644 index f101d30e3..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/identity_provider/create.rs +++ /dev/null @@ -1,328 +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`. - -//! Create the identity provider with the specified properties. -//! -//! It is expected that only admin user is able to create global identity -//! providers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// Identity provider data. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct IdentityProvider<'a> { - /// The bound issuer that is verified when using the identity provider. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bound_issuer: Option>, - - /// Default attribute mapping name which is automatically used when no - /// mapping is explicitly requested. The referred attribute mapping must - /// exist. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_mapping_name: Option>, - - /// The ID of the domain this identity provider belongs to. Empty value - /// identifies that the identity provider can be used by other domains as - /// well. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>, - - /// Identity provider `enabled` property. Inactive Identity Providers can - /// not be used for login. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// Optional URL to fetch JsonWebKeySet. Must be specified for JWT - /// authentication when discovery for the provider is not available or not - /// standard compliant. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) jwks_url: Option>, - - /// List of the jwt validation public keys. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) jwt_validation_pubkeys: Option>>, - - /// Identity provider name. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// The oidc `client_id` to use for the private client. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_client_id: Option>, - - /// The oidc `client_secret` to use for the private client. It is never - /// returned back. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_client_secret: Option>, - - /// OIDC discovery endpoint for the identity provider. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_discovery_url: Option>, - - /// The oidc response mode. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_response_mode: Option>, - - /// List of supported response types. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_response_types: Option>>, - - /// Additional special provider specific configuration. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_provider_config"))] - pub(crate) provider_config: Option, Value>>, -} - -impl<'a> IdentityProviderBuilder<'a> { - /// Additional special provider specific configuration. - pub fn provider_config(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.provider_config - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Identity provider data. - #[builder(setter(into))] - pub(crate) identity_provider: IdentityProvider<'a>, - - #[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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "federation/identity_providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "identity_provider", - serde_json::to_value(&self.identity_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_provider".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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .identity_provider( - IdentityProviderBuilder::default() - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .identity_provider( - IdentityProviderBuilder::default() - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "identity_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/federation/identity_providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .identity_provider( - IdentityProviderBuilder::default() - .name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/federation/identity_providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .identity_provider( - IdentityProviderBuilder::default() - .name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/identity_provider/delete.rs b/openstack_sdk/src/api/identity/v4/federation/identity_provider/delete.rs deleted file mode 100644 index d8d5033a8..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/identity_provider/delete.rs +++ /dev/null @@ -1,193 +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`. - -//! Deletes the existing identity provider. -//! -//! It is expected that only admin user is allowed to delete the global -//! identity provider -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the identity provider - #[builder(default, setter(into))] - idp_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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "federation/identity_providers/{idp_id}", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/federation/identity_providers/{idp_id}", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/federation/identity_providers/{idp_id}", - idp_id = "idp_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() - .idp_id("idp_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/identity_provider/get.rs b/openstack_sdk/src/api/identity/v4/federation/identity_provider/get.rs deleted file mode 100644 index 59fbfa2b3..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/identity_provider/get.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows details of the existing identity provider. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the identity provider - #[builder(default, setter(into))] - idp_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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "federation/identity_providers/{idp_id}", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_provider".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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "identity_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/federation/identity_providers/{idp_id}", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/federation/identity_providers/{idp_id}", - idp_id = "idp_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/identity_provider/list.rs b/openstack_sdk/src/api/identity/v4/federation/identity_provider/list.rs deleted file mode 100644 index 7393a9ea6..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/identity_provider/list.rs +++ /dev/null @@ -1,208 +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`. - -//! List identity providers. Without any filters only global identity providers -//! are returned. With the `domain_id` identity providers owned by the -//! specified identity provider are returned. -//! -//! It is expected that only global or owned identity providers can be -//! returned, while an admin user is able to list all providers. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filters the response by a domain ID. - #[builder(default, setter(into))] - domain_id: Option>, - - /// Limit number of entries on the single response page. - #[builder(default)] - limit: Option, - - /// Page marker (id of the last entry on the previous page. - #[builder(default, setter(into))] - marker: Option>, - - /// Filters the response by IDP name. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "federation/identity_providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("name", self.name.as_ref()); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_providers".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(4, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "identity_providers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/federation/identity_providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_providers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/federation/identity_providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_providers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/identity_provider/set.rs b/openstack_sdk/src/api/identity/v4/federation/identity_provider/set.rs deleted file mode 100644 index ee91ef7e6..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/identity_provider/set.rs +++ /dev/null @@ -1,331 +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`. - -//! Updates the existing identity provider. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// New identity provider data. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct IdentityProvider<'a> { - /// The new bound issuer that is verified when using the identity provider. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bound_issuer: Option>>, - - /// New default attribute mapping name which is automatically used when no - /// mapping is explicitly requested. The referred attribute mapping must - /// exist. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_mapping_name: Option>>, - - /// Identity provider `enabled` property. Inactive Identity Providers can - /// not be used for login. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option>, - - /// New URL to fetch JsonWebKeySet. This must be set for "jwt" mapping when - /// the provider does not provide discovery endpoint or when it is not - /// standard compliant. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) jwks_url: Option>>, - - /// The list of the jwt validation public keys. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) jwt_validation_pubkeys: Option>>, - - /// The new name of the federated identity provider. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The new oidc `client_id` to use for the private client. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_client_id: Option>>, - - /// The new oidc `client_secret` to use for the private client. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_client_secret: Option>>, - - /// The new OIDC discovery endpoint for the identity provider. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_discovery_url: Option>>, - - /// The new oidc response mode. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_response_mode: Option>>, - - /// The new oidc response mode. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_response_types: Option>>, - - /// New additional provider configuration. - #[serde()] - #[builder(private, setter(into, name = "_provider_config"))] - pub(crate) provider_config: BTreeMap, Value>, -} - -impl<'a> IdentityProviderBuilder<'a> { - /// New additional provider configuration. - pub fn provider_config(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.provider_config - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// New identity provider data. - #[builder(setter(into))] - pub(crate) identity_provider: IdentityProvider<'a>, - - /// The ID of the identity provider - #[builder(default, setter(into))] - idp_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 Identity_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "federation/identity_providers/{idp_id}", - idp_id = self.idp_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "identity_provider", - serde_json::to_value(&self.identity_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("identity_provider".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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .identity_provider( - IdentityProviderBuilder::default() - .provider_config(BTreeMap::::new().into_iter()) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .identity_provider( - IdentityProviderBuilder::default() - .provider_config(BTreeMap::::new().into_iter()) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "identity_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/federation/identity_providers/{idp_id}", - idp_id = "idp_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .identity_provider( - IdentityProviderBuilder::default() - .provider_config(BTreeMap::::new().into_iter()) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/federation/identity_providers/{idp_id}", - idp_id = "idp_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "identity_provider": {} })); - }); - - let endpoint = Request::builder() - .idp_id("idp_id") - .identity_provider( - IdentityProviderBuilder::default() - .provider_config(BTreeMap::::new().into_iter()) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/mapping/create.rs b/openstack_sdk/src/api/identity/v4/federation/mapping/create.rs deleted file mode 100644 index fd98366cd..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/mapping/create.rs +++ /dev/null @@ -1,358 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "jwt")] - Jwt, - #[serde(rename = "oidc")] - Oidc, -} - -/// OIDC/JWT attribute mapping create data. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Mapping<'a> { - /// List of allowed redirect urls (only for `oidc` type). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allowed_redirect_uris: Option>>, - - /// List of audiences that must be present in the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bound_audiences: Option>>, - - /// Additional claims that must be present in the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_bound_claims"))] - pub(crate) bound_claims: Option, Value>>, - - /// Token subject value that must be set in the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bound_subject: Option>, - - /// `domain_id` owning the attribute mapping. - /// - /// Unset `domain_id` means the attribute mapping is shared and can be used - /// by different domains. This requires `domain_id_claim` to be present. - /// Attribute mapping can be only shared when the referred identity - /// provider is also shared (does not set the `domain_id` attribute). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>, - - /// `domain_id` claim name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id_claim: Option>, - - /// Mapping enabled property. Inactive mappings can not be used for login. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// `groups` claim name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) groups_claim: Option>, - - /// Attribute mapping ID for federated logins. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>>, - - /// ID of the federated identity provider for which this attribute mapping - /// can be used. - #[serde()] - #[builder(setter(into))] - pub(crate) idp_id: Cow<'a, str>, - - /// Attribute mapping name for federated logins. - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// List of OIDC scopes. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_scopes: Option>>, - - /// Fixed project_id for the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token_project_id: Option>, - - /// Token restrictions to be applied to the granted token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token_restriction_id: Option>>, - - /// Attribute mapping type. - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, - - /// `user_id` claim name. - #[serde()] - #[builder(setter(into))] - pub(crate) user_id_claim: Cow<'a, str>, - - /// `user_name` claim name. - #[serde()] - #[builder(setter(into))] - pub(crate) user_name_claim: Cow<'a, str>, -} - -impl<'a> MappingBuilder<'a> { - /// Additional claims that must be present in the token. - pub fn bound_claims(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.bound_claims - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// OIDC/JWT attribute mapping create data. - #[builder(setter(into))] - pub(crate) mapping: Mapping<'a>, - - #[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 Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "federation/mappings".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("mapping", serde_json::to_value(&self.mapping)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mapping".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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .mapping( - MappingBuilder::default() - .idp_id("foo") - .name("foo") - .user_id_claim("foo") - .user_name_claim("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .mapping( - MappingBuilder::default() - .idp_id("foo") - .name("foo") - .user_id_claim("foo") - .user_name_claim("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "mapping" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/federation/mappings".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .mapping( - MappingBuilder::default() - .idp_id("foo") - .name("foo") - .user_id_claim("foo") - .user_name_claim("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/federation/mappings".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .mapping( - MappingBuilder::default() - .idp_id("foo") - .name("foo") - .user_id_claim("foo") - .user_name_claim("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/mapping/delete.rs b/openstack_sdk/src/api/identity/v4/federation/mapping/delete.rs deleted file mode 100644 index f7d310332..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/mapping/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the attribute mapping - #[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<'a> RequestBuilder<'a> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("federation/mappings/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - 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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/federation/mappings/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/federation/mappings/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/mapping/get.rs b/openstack_sdk/src/api/identity/v4/federation/mapping/get.rs deleted file mode 100644 index 18051f75b..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/mapping/get.rs +++ /dev/null @@ -1,184 +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 attribute mapping attribute by the ID. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the attribute mapping. - #[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<'a> RequestBuilder<'a> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("federation/mappings/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mapping".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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "mapping" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/federation/mappings/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/federation/mappings/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/mapping/list.rs b/openstack_sdk/src/api/identity/v4/federation/mapping/list.rs deleted file mode 100644 index 0fb1ac04c..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/mapping/list.rs +++ /dev/null @@ -1,218 +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`. - -//! List available federation mappings. -//! -//! Without `domain_id` specified global mappings are returned. -//! -//! It is expected that listing mappings belonging to the other domain is only -//! allowed to the admin user. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Filters the response by a mapping type. - #[builder(default, setter(into))] - _type: Option>, - - /// Filters the response by a domain ID. - #[builder(default, setter(into))] - domain_id: Option>, - - /// Filters the response by a idp ID. - #[builder(default, setter(into))] - idp_id: Option>, - - /// Limit number of entries on the single response page (Maximal 100). - #[builder(default)] - limit: Option, - - /// Page marker (id of the last entry on the previous page. - #[builder(default, setter(into))] - marker: Option>, - - /// Filters the response by IDP name. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "federation/mappings".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("domain_id", self.domain_id.as_ref()); - params.push_opt("idp_id", self.idp_id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("type", self._type.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mappings".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(4, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "mappings" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/federation/mappings".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mappings": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/federation/mappings".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mappings": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/identity/v4/federation/mapping/set.rs b/openstack_sdk/src/api/identity/v4/federation/mapping/set.rs deleted file mode 100644 index d196646a0..000000000 --- a/openstack_sdk/src/api/identity/v4/federation/mapping/set.rs +++ /dev/null @@ -1,328 +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`. - -//! TODO: describe domain_id update rules -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "jwt")] - Jwt, - #[serde(rename = "oidc")] - Oidc, -} - -/// OIDC/JWT attribute mapping update data. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Mapping<'a> { - /// List of allowed redirect urls (only for `oidc` type). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allowed_redirect_uris: Option>>, - - /// List of audiences that must be present in the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bound_audiences: Option>>, - - /// Additional claims that must be present in the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_bound_claims"))] - pub(crate) bound_claims: Option, Value>>, - - /// Token subject value that must be set in the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) bound_subject: Option>>, - - /// `domain_id` owning the attribute mapping. - /// - /// Unset `domain_id` means the attribute mapping is shared and can be used - /// by different domains. This requires `domain_id_claim` to be present. - /// Attribute mapping can be only shared when the referred identity - /// provider is also shared (does not set the `domain_id` attribute). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_id_claim: Option>>, - - /// Mapping enabled property. Inactive mappings can not be used for login. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// `groups` claim name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) groups_claim: Option>>, - - /// ID of the federated identity provider for which this attribute mapping - /// can be used. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) idp_id: Option>>, - - /// Attribute mapping name for federated logins. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// List of OIDC scopes. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) oidc_scopes: Option>>, - - /// Fixed project_id for the token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token_project_id: Option>>, - - /// Token restrictions to be applied to the granted token. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token_restriction_id: Option>>, - - /// Attribute mapping type. - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, - - /// `user_id` claim name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user_id_claim: Option>>, - - /// `user_name` claim name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user_name_claim: Option>>, -} - -impl<'a> MappingBuilder<'a> { - /// Additional claims that must be present in the token. - pub fn bound_claims(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.bound_claims - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// OIDC/JWT attribute mapping update data. - #[builder(setter(into))] - pub(crate) mapping: Mapping<'a>, - - /// The ID of the attribute mapping. - #[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<'a> RequestBuilder<'a> { - /// Add a single header to the Mapping. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("federation/mappings/{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("mapping", serde_json::to_value(&self.mapping)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("mapping".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(4, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .mapping(MappingBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .mapping(MappingBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "mapping" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/federation/mappings/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .mapping(MappingBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/federation/mappings/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "mapping": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .mapping(MappingBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image.rs b/openstack_sdk/src/api/image.rs index 504099738..74e72d0e9 100644 --- a/openstack_sdk/src/api/image.rs +++ b/openstack_sdk/src/api/image.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Image API (Glance) bindings -pub mod v2; +//! # Image API (Glance) bindings +pub use openstack_sdk_image::*; diff --git a/openstack_sdk/src/api/image/v2/cache/delete.rs b/openstack_sdk/src/api/image/v2/cache/delete.rs deleted file mode 100644 index ede562104..000000000 --- a/openstack_sdk/src/api/image/v2/cache/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a image from cache. *(Since Image API v2.14)* -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/cache/{image_id} API - #[builder(default, setter(into))] - image_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 Cache. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("cache/{image_id}", image_id = self.image_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/cache/{image_id}", image_id = "image_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().image_id("image_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/cache/{image_id}", image_id = "image_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() - .image_id("image_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/cache/delete_all.rs b/openstack_sdk/src/api/image/v2/cache/delete_all.rs deleted file mode 100644 index 6092a6af7..000000000 --- a/openstack_sdk/src/api/image/v2/cache/delete_all.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`. - -//! Clears the cache and its queue. *(Since Image API v2.14)* -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Cache. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "cache".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path("/cache".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path("/cache".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/cache/list.rs b/openstack_sdk/src/api/image/v2/cache/list.rs deleted file mode 100644 index d925cf0b8..000000000 --- a/openstack_sdk/src/api/image/v2/cache/list.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`. - -//! Lists all images in cache or queue. *(Since Image API v2.14)* -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Cache. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "cache".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/cache".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/cache".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/cache/set.rs b/openstack_sdk/src/api/image/v2/cache/set.rs deleted file mode 100644 index 36662f0e9..000000000 --- a/openstack_sdk/src/api/image/v2/cache/set.rs +++ /dev/null @@ -1,212 +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`. - -//! Queues image for caching. *(Since Image API v2.14)* -//! -//! Normal response codes: 202 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/cache/{image_id} API - #[builder(default, setter(into))] - image_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Cache. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("cache/{image_id}", image_id = self.image_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/cache/{image_id}", image_id = "image_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().image_id("image_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/cache/{image_id}", image_id = "image_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() - .image_id("image_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/create.rs b/openstack_sdk/src/api/image/v2/image/create.rs deleted file mode 100644 index 665358389..000000000 --- a/openstack_sdk/src/api/image/v2/image/create.rs +++ /dev/null @@ -1,467 +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`. - -//! Creates a catalog record for an operating system disk image. *(Since Image -//! API v2.0)* -//! -//! The `Location` response header contains the URI for the image. -//! -//! A multiple store backend support is introduced in the Rocky release as a -//! part of the EXPERIMENTAL Image API v2.8. Since Image API v2.8 a new header -//! `OpenStack-image-store-ids` which contains the list of available stores -//! will be included in response. This header is only included if multiple -//! backend stores are supported. -//! -//! The response body contains the new image entity. -//! -//! Synchronous Postconditions -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 409, 413, 415 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum ContainerFormat { - #[serde(rename = "aki")] - Aki, - #[serde(rename = "ami")] - Ami, - #[serde(rename = "ari")] - Ari, - #[serde(rename = "bare")] - Bare, - #[serde(rename = "compressed")] - Compressed, - #[serde(rename = "docker")] - Docker, - #[serde(rename = "ova")] - Ova, - #[serde(rename = "ovf")] - Ovf, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum DiskFormat { - #[serde(rename = "aki")] - Aki, - #[serde(rename = "ami")] - Ami, - #[serde(rename = "ari")] - Ari, - #[serde(rename = "iso")] - Iso, - #[serde(rename = "ploop")] - Ploop, - #[serde(rename = "qcow2")] - Qcow2, - #[serde(rename = "raw")] - Raw, - #[serde(rename = "vdi")] - Vdi, - #[serde(rename = "vhd")] - Vhd, - #[serde(rename = "vhdx")] - Vhdx, - #[serde(rename = "vmdk")] - Vmdk, -} - -/// Values to be used to populate the corresponding image properties. If the -/// image status is not 'queued', values must exactly match those already -/// contained in the image properties. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ValidationData<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) checksum: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) os_hash_algo: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) os_hash_value: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Locations<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Value>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) url: Cow<'a, str>, - - /// Values to be used to populate the corresponding image properties. If - /// the image status is not 'queued', values must exactly match those - /// already contained in the image properties. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) validation_data: Option>, -} - -impl<'a> LocationsBuilder<'a> { - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.metadata - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Visibility { - #[serde(rename = "community")] - Community, - #[serde(rename = "private")] - Private, - #[serde(rename = "public")] - Public, - #[serde(rename = "shared")] - Shared, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Format of the image container. - /// - /// Values may vary based on the configuration available in a particular - /// OpenStack cloud. See the [Image Schema](#image-schema) response from - /// the cloud itself for the valid values available. See - /// [Container Format](https://docs.openstack.org/glance/latest/user/formats.html#container-format) - /// in the Glance documentation for more information. - /// - /// Example formats are: `ami`, `ari`, `aki`, `bare`, `ovf`, `ova`, - /// `docker`, or `compressed`. - /// - /// The value might be `null` (JSON null data type). - /// - /// **Train changes**: The `compressed` container format is a supported - /// value. - #[builder(default)] - pub(crate) container_format: Option, - - /// The format of the disk. - /// - /// Values may vary based on the configuration available in a particular - /// OpenStack cloud. See the [Image Schema](#image-schema) response from - /// the cloud itself for the valid values available. See - /// [Disk Format](https://docs.openstack.org/glance/latest/user/formats.html#disk-format) - /// in the Glance documentation for more information. - /// - /// Example formats are: `ami`, `ari`, `aki`, `vhd`, `vhdx`, `vmdk`, `raw`, - /// `qcow2`, `vdi`, `ploop` or `iso`. - /// - /// The value might be `null` (JSON null data type). - /// - /// **Newton changes**: The `vhdx` disk format is a supported value.\ - /// **Ocata changes**: The `ploop` disk format is a supported value. - #[builder(default)] - pub(crate) disk_format: Option, - - /// A unique, user-defined image UUID, in the format: - /// - /// ```text - /// nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn - /// ``` - /// - /// Where **n** is a hexadecimal digit from 0 to f, or F. - /// - /// For example: - /// - /// ```text - /// b2173dd3-7ad6-4362-baa6-a68bce3565cb - /// ``` - /// - /// If you omit this value, the API generates a UUID for the image. If you - /// specify a value that has already been assigned, the request fails with - /// a `409` response code. - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// A set of URLs to access the image file kept in external store - #[builder(default, setter(into))] - pub(crate) locations: Option>>, - - /// Amount of disk space in GB that is required to boot the image. - #[builder(default, setter(into))] - pub(crate) min_disk: Option, - - /// Amount of RAM in MB that is required to boot the image. - #[builder(default, setter(into))] - pub(crate) min_ram: Option, - - /// The name of the image. - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// If true, image will not appear in default image list response. - #[builder(default, setter(into))] - pub(crate) os_hidden: Option, - - /// Owner of the image - #[builder(default, setter(into))] - pub(crate) owner: Option>>, - - /// Image protection for deletion. Valid value is `true` or `false`. - /// Default is `false`. - #[builder(default, setter(into))] - pub(crate) protected: Option, - - /// List of tags for this image. Each tag is a string of at most 255 chars. - /// The maximum number of tags allowed on an image is set by the operator. - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// Visibility for this image. Valid value is one of: `public`, `private`, - /// `shared`, or `community`. At most sites, only an administrator can make - /// an image `public`. Some sites may restrict what users can make an image - /// `community`. Some sites may restrict what users can perform member - /// operations on a `shared` image. *Since the Image API v2.5, the default - /// value is `shared`.* - #[builder(default)] - pub(crate) visibility: Option, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Cow<'a, str>>, -} -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 Image. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "images".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.container_format { - params.push("container_format", serde_json::to_value(val)?); - } - if let Some(val) = &self.disk_format { - params.push("disk_format", serde_json::to_value(val)?); - } - if let Some(val) = &self.id { - params.push("id", serde_json::to_value(val)?); - } - if let Some(val) = &self.locations { - params.push("locations", serde_json::to_value(val)?); - } - if let Some(val) = &self.min_disk { - params.push("min_disk", serde_json::to_value(val)?); - } - if let Some(val) = &self.min_ram { - params.push("min_ram", serde_json::to_value(val)?); - } - if let Some(val) = &self.name { - params.push("name", serde_json::to_value(val)?); - } - if let Some(val) = &self.os_hidden { - params.push("os_hidden", serde_json::to_value(val)?); - } - if let Some(val) = &self.owner { - params.push("owner", serde_json::to_value(val)?); - } - if let Some(val) = &self.protected { - params.push("protected", serde_json::to_value(val)?); - } - if let Some(val) = &self.tags { - params.push("tags", serde_json::to_value(val)?); - } - if let Some(val) = &self.visibility { - params.push("visibility", serde_json::to_value(val)?); - } - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/images".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/images".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/delete.rs b/openstack_sdk/src/api/image/v2/image/delete.rs deleted file mode 100644 index 90ab77ae4..000000000 --- a/openstack_sdk/src/api/image/v2/image/delete.rs +++ /dev/null @@ -1,192 +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`. - -//! (Since Image API v2.0) Deletes an image. -//! -//! You cannot delete images with the `protected` attribute set to `true` -//! (boolean). -//! -//! Preconditions -//! -//! Synchronous Postconditions -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_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<'a> RequestBuilder<'a> { - /// Add a single header to the Image. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("images/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/images/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/images/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/find.rs b/openstack_sdk/src/api/image/v2/image/find.rs deleted file mode 100644 index ad5fbc907..000000000 --- a/openstack_sdk/src/api/image/v2/image/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::image::v2::image::{get as Get, list as List}; - -/// Find for image 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/image/v2/image/get.rs b/openstack_sdk/src/api/image/v2/image/get.rs deleted file mode 100644 index 1dbc0a20f..000000000 --- a/openstack_sdk/src/api/image/v2/image/get.rs +++ /dev/null @@ -1,189 +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`. - -//! Shows details for an image. *(Since Image API v2.0)* -//! -//! The response body contains a single image entity. -//! -//! Preconditions -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_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<'a> RequestBuilder<'a> { - /// Add a single header to the Image. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("images/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/images/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/images/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/import/create.rs b/openstack_sdk/src/api/image/v2/image/import/create.rs deleted file mode 100644 index b60fce180..000000000 --- a/openstack_sdk/src/api/image/v2/image/import/create.rs +++ /dev/null @@ -1,322 +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`. - -//! Signals the Image Service to complete the image import workflow by -//! processing data that has been made available to the OpenStack image -//! service. *(Since Image API v2.6)* -//! -//! In the `glance-direct` workflow, the data has been made available to the -//! Image service via the [Stage binary image data](#image-stage-call) API -//! call. -//! -//! In the `web-download` workflow, the data is made available to the Image -//! service by being posted to an accessible location with a URL that you know. -//! -//! In the `copy-image` workflow, the data is made available to the Image -//! service by copying existing image data to the staging area. -//! -//! In the `glance-download` workflow, the data is made available to the Image -//! service by fetching an image accessible from another glance service -//! specified by a region name and an image id that you know. -//! -//! Beginning with API version 2.8, an optional `stores` parameter may be added -//! to the body request. When present, it contains the list of backing store -//! identifiers to import the image binary data to. If at least one store -//! identifier specified is not recognized, a 409 (Conflict) response is -//! returned. When the parameter is not present, the image data is placed into -//! the default backing store. -//! -//! For backwards compatibility, if the `stores` parameter is not specified, -//! the header ‘X-Image-Meta-Store’ is evaluated. -//! -//! To import the data into the entire set of stores you may consume from this -//! particular deployment of Glance without specifying each one of them, you -//! can use the optional boolean body parameter `all_stores`. Note that this -//! can’t be used simultaneously with the `stores` parameter. -//! -//! To set the behavior of the import workflow in case of error, you can use -//! the optional boolean body parameter `all_stores_must_succeed`. When set to -//! True (default), if an error occurs during the upload in at least one store, -//! the workflow fails, the data is deleted from stores where copying is done -//! and the state of the image remains unchanged. When set to False, the -//! workflow will fail only if the upload fails on all stores specified. In -//! case of a partial success, the locations added to the image will be the -//! stores where the data has been correctly uploaded. -//! -//! The JSON request body specifies what import method you wish to use for this -//! image request. -//! -//! **Preconditions** -//! -//! Before you can complete the interoperable image import workflow, you must -//! meet the following preconditions: -//! -//! **Additional Preconditions** -//! -//! If you are using the `glance-direct` import method: -//! -//! If you are using the `web-download` import method: -//! -//! If you are using the `copy-image` import method: -//! -//! If you are using the `glance-download` import method: -//! -//! **Synchronous Postconditions** -//! -//! Normal response codes: 202 -//! -//! Error response codes: 400, 401, 403, 404, 405, 409, 410, 413, 415, 503 -//! -//! If the image import process is not enabled in your cloud, this request will -//! result in a 404 response code with an appropriate message. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A JSON object indicating what import method you wish to use to import your -/// image. The content of this JSON object is another JSON object with a `name` -/// field whose value is the identifier for the import method. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Method<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) glance_image_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) glance_region: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) glance_service_interface: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) uri: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// When set to True the data will be imported to the set of stores you may - /// consume from this particular deployment of Glance (ie: the same set of - /// stores returned to a call to /v2/info/stores on the glance-api the - /// request hits). This can’t be used simultaneously with the `stores` - /// parameter. - #[builder(default, setter(into))] - pub(crate) all_stores: Option, - - #[builder(default, setter(into))] - pub(crate) all_stores_must_success: Option, - - /// A JSON object indicating what import method you wish to use to import - /// your image. The content of this JSON object is another JSON object with - /// a `name` field whose value is the identifier for the import method. - #[builder(default, setter(into))] - pub(crate) method: Option>, - - /// If present contains the list of store id to import the image binary - /// data to. - #[builder(default, setter(into))] - pub(crate) stores: Option>>, - - /// image_id parameter for /v2/images/{image_id}/import API - #[builder(default, setter(into))] - image_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 Import. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "images/{image_id}/import", - image_id = self.image_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.all_stores { - params.push("all_stores", serde_json::to_value(val)?); - } - if let Some(val) = &self.all_stores_must_success { - params.push("all_stores_must_success", serde_json::to_value(val)?); - } - if let Some(val) = &self.method { - params.push("method", serde_json::to_value(val)?); - } - if let Some(val) = &self.stores { - params.push("stores", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/images/{image_id}/import", image_id = "image_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().image_id("image_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/images/{image_id}/import", image_id = "image_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() - .image_id("image_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/list.rs b/openstack_sdk/src/api/image/v2/image/list.rs deleted file mode 100644 index 6d6ccaf5a..000000000 --- a/openstack_sdk/src/api/image/v2/image/list.rs +++ /dev/null @@ -1,415 +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`. - -//! Lists public virtual machine (VM) images. *(Since Image API v2.0)* -//! -//! **Pagination** -//! -//! Returns a subset of the larger collection of images and a link that you can -//! use to get the next set of images. You should always check for the presence -//! of a `next` link and use it as the URI in a subsequent HTTP GET request. -//! You should follow this pattern until a `next` link is no longer provided. -//! -//! The `next` link preserves any query parameters that you send in your -//! initial request. You can use the `first` link to jump back to the first -//! page of the collection. If you prefer to paginate through images manually, -//! use the `limit` and `marker` parameters. -//! -//! **Query Filters** -//! -//! The list operation accepts query parameters to filter the response. -//! -//! A client can provide direct comparison filters by using most image -//! attributes, such as `name=Ubuntu`, `visibility=public`, and so on. -//! -//! To filter using image tags, use the filter `tag` (note the singular). To -//! filter on multiple tags, include each tag separately in the query. For -//! example, to find images with the tag **ready**, include `tag=ready` in your -//! query string. To find images tagged with **ready** and **approved**, -//! include `tag=ready&tag=approved` in your query string. (Note that only -//! images containing *both* tags will be included in the response.) -//! -//! A client cannot use any `link` in the json-schema, such as self, file, or -//! schema, to filter the response. -//! -//! You can list VM images that have a status of `active`, `queued`, or -//! `saving`. -//! -//! **The** `in` **Operator** -//! -//! As a convenience, you may specify several values for any of the following -//! fields by using the `in` operator: -//! -//! For most of these, usage is straight forward. For example, to list images -//! in queued or saving status, use: -//! -//! `GET /v2/images?status=in:saving,queued` -//! -//! To find images in a particular list of image IDs, use: -//! -//! `GET /v2/images?id=in:3afb79c1-131a-4c38-a87c-bc4b801d14e6,2e011209-660f-44b5-baf2-2eb4babae53d` -//! -//! Using the `in` operator with the `name` property of images can be a bit -//! trickier, depending upon how creatively you have named your images. The -//! general rule is that if an image name contains a comma (`,`), you must -//! enclose the entire name in quotation marks (`"`). As usual, you must URL -//! encode any characters that require it. -//! -//! For example, to find images named `glass, darkly` or `share me`, you would -//! use the following filter specification: -//! -//! `GET v2/images?name=in:"glass,%20darkly",share%20me` -//! -//! As with regular filtering by name, you must specify the complete name you -//! are looking for. Thus, for example, the query string `name=in:glass,share` -//! will only match images with the exact name `glass` or the exact name -//! `share`. It will not find an image named `glass, darkly` or an image named -//! `share me`. -//! -//! **Size Comparison Filters** -//! -//! You can use the `size_min` and `size_max` query parameters to filter images -//! that are greater than or less than the image size. The size, in bytes, is -//! the size of an image on disk. -//! -//! For example, to filter the container to include only images that are from 1 -//! to 4 MB, set the `size_min` query parameter to `1048576` and the `size_max` -//! query parameter to `4194304`. -//! -//! **Time Comparison Filters** -//! -//! You can use a *comparison operator* along with the `created_at` or -//! `updated_at` fields to filter your results. Specify the operator first, a -//! colon (`:`) as a separator, and then the time in -//! [ISO 8601 Format](https://en.wikipedia.org/wiki/ISO_8601). Available -//! comparison operators are: -//! -//! For example: -//! -//! **Sorting** -//! -//! You can use query parameters to sort the results of this operation. -//! -//! To sort the response, use the `sort_key` and `sort_dir` query parameters: -//! -//! Alternatively, specify the `sort` query parameter: -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Specify a comparison filter based on the date and time when the - /// resource was created. - #[builder(default, setter(into))] - created_at: Option>, - - /// id filter parameter - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Filters the response by a member status. A valid value is accepted, - /// pending, rejected, or all. Default is accepted. - #[builder(default, setter(into))] - member_status: Option>, - - /// Filters the response by a name, as a string. A valid value is the name - /// of an image. - #[builder(default, setter(into))] - name: Option>, - - /// When true, filters the response to display only "hidden" images. By - /// default, "hidden" images are not included in the image-list response. - /// (Since Image API v2.7) - #[builder(default)] - os_hidden: Option, - - /// Filters the response by a project (also called a “tenant”) ID. Shows - /// only images that are shared with you by the specified owner. - #[builder(default, setter(into))] - owner: Option>, - - /// Filters the response by the ‘protected’ image property. A valid value - /// is one of ‘true’, ‘false’ (must be all lowercase). Any other value will - /// result in a 400 response. - #[builder(default)] - protected: Option, - - /// Filters the response by a maximum image size, in bytes. - #[builder(default, setter(into))] - size_max: Option>, - - /// Filters the response by a minimum image size, in bytes. - #[builder(default, setter(into))] - size_min: Option>, - - /// Sorts the response by one or more attribute and sort direction - /// combinations. You can also set multiple sort keys and directions. - /// Default direction is desc. Use the comma (,) character to separate - /// multiple values. For example: `sort=name:asc,status:desc` - #[builder(default, setter(into))] - sort: Option>, - - /// Sorts the response by a set of one or more sort direction and attribute - /// (sort_key) combinations. A valid value for the sort direction is asc - /// (ascending) or desc (descending). If you omit the sort direction in a - /// set, the default is desc. - #[builder(default, setter(into))] - sort_dir: Option>, - - /// Sorts the response by an attribute, such as name, id, or updated_at. - /// Default is created_at. The API uses the natural sorting direction of - /// the sort_key image attribute. - #[builder(default, setter(into))] - sort_key: Option>, - - /// Filters the response by an image status. - #[builder(default, setter(into))] - status: Option>, - - /// Filters the response by the specified tag value. May be repeated, but - /// keep in mind that you're making a conjunctive query, so only images - /// containing all the tags specified will appear in the response. - #[builder(default, private, setter(name = "_tag"))] - tag: Option>>, - - /// Specify a comparison filter based on the date and time when the - /// resource was most recently modified. - #[builder(default, setter(into))] - updated_at: Option>, - - /// Filters the response by an image visibility value. A valid value is - /// public, private, community, shared, or all. (Note that if you filter on - /// shared, the images included in the response will only be those where - /// your member status is accepted unless you explicitly include a - /// member_status filter in the request.) If you omit this parameter, the - /// response shows public, private, and those shared images with a member - /// status of accepted. - #[builder(default, setter(into))] - visibility: 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> { - /// Filters the response by the specified tag value. May be repeated, but - /// keep in mind that you're making a conjunctive query, so only images - /// containing all the tags specified will appear in the response. - pub fn tag(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tag - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Image. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "images".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("member_status", self.member_status.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("os_hidden", self.os_hidden); - params.push_opt("owner", self.owner.as_ref()); - params.push_opt("protected", self.protected); - params.push_opt("size_max", self.size_max.as_ref()); - params.push_opt("size_min", self.size_min.as_ref()); - params.push_opt("sort", self.sort.as_ref()); - params.push_opt("sort_dir", self.sort_dir.as_ref()); - params.push_opt("sort_key", self.sort_key.as_ref()); - params.push_opt("status", self.status.as_ref()); - if let Some(val) = &self.tag { - params.extend(val.iter().map(|value| ("tag", value))); - } - params.push_opt("updated_at", self.updated_at.as_ref()); - params.push_opt("visibility", self.visibility.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("images".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "images" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/images".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "images": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/images".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "images": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/location/create.rs b/openstack_sdk/src/api/image/v2/image/location/create.rs deleted file mode 100644 index 148f8b34e..000000000 --- a/openstack_sdk/src/api/image/v2/image/location/create.rs +++ /dev/null @@ -1,288 +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`. - -//! Add location to an image which is in `queued` state. Accepts location url, -//! validation_data in JSON body. -//! -//! Adding a location to an image is only allowed for the owner or a user with -//! the service role. If these conditions are not met, a 403 (Forbidden) will -//! be returned. -//! -//! Attempting to add a location path to an image that is not in `queued` state -//! will result in a 409 (Conflict) response code -//! -//! Attempting to provide incorrect hash value in validation data(in the case -//! of http store) to the image will result in a 400 (Bad Request) response -//! code. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// An image metadata in key:value pairs containing values of `os_hash_value` -/// and `os_hash_algo` to be added to the image. If `do_secure_hash` is not -/// passed then it is the responsibility of the consumer of location add API to -/// provide the correct values in `validation_data`’ -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ValidationData<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) checksum: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) os_hash_algo: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) os_hash_value: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, private, setter(into, name = "_metadata"))] - pub(crate) metadata: Option, Value>>, - - /// The URL of the new location to be added in the image. - #[builder(setter(into))] - pub(crate) url: Cow<'a, str>, - - /// An image metadata in key:value pairs containing values of - /// `os_hash_value` and `os_hash_algo` to be added to the image. If - /// `do_secure_hash` is not passed then it is the responsibility of the - /// consumer of location add API to provide the correct values in - /// `validation_data`’ - #[builder(default, setter(into))] - pub(crate) validation_data: Option>, - - /// image_id parameter for /v2/images/{image_id}/locations API - #[builder(default, setter(into))] - image_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> { - pub fn metadata(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.metadata - .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 Location. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "images/{image_id}/locations", - image_id = self.image_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.metadata { - params.push("metadata", serde_json::to_value(val)?); - } - params.push("url", serde_json::to_value(&self.url)?); - if let Some(val) = &self.validation_data { - params.push("validation_data", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .url("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .url("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/images/{image_id}/locations", - image_id = "image_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .url("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/images/{image_id}/locations", - image_id = "image_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() - .image_id("image_id") - .url("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/location/list.rs b/openstack_sdk/src/api/image/v2/image/location/list.rs deleted file mode 100644 index ea3707caa..000000000 --- a/openstack_sdk/src/api/image/v2/image/location/list.rs +++ /dev/null @@ -1,196 +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`. - -//! Lists all locations associated to an image with location url and store-id, -//! accessible to only service user, for non service users API will return -//! forbidden. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_id}/locations API - #[builder(default, setter(into))] - image_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 Location. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "images/{image_id}/locations", - image_id = self.image_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/images/{image_id}/locations", - image_id = "image_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().image_id("image_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/images/{image_id}/locations", - image_id = "image_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() - .image_id("image_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/member/create.rs b/openstack_sdk/src/api/image/v2/image/member/create.rs deleted file mode 100644 index 3990b3411..000000000 --- a/openstack_sdk/src/api/image/v2/image/member/create.rs +++ /dev/null @@ -1,222 +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`. - -//! Adds a tenant ID as an image member. *(Since Image API v2.1)* -//! -//! Preconditions -//! -//! Synchronous Postconditions -//! -//! Troubleshooting -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 409, 413 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - image_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "images/{image_id}/members", - image_id = self.image_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/images/{image_id}/members", image_id = "image_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().image_id("image_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/images/{image_id}/members", image_id = "image_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() - .image_id("image_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/member/delete.rs b/openstack_sdk/src/api/image/v2/image/member/delete.rs deleted file mode 100644 index 0b726095d..000000000 --- a/openstack_sdk/src/api/image/v2/image/member/delete.rs +++ /dev/null @@ -1,213 +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`. - -//! Deletes a tenant ID from the member list of an image. *(Since Image API -//! v2.1)* -//! -//! Preconditions -//! -//! Synchronous Postconditions -//! -//! Troubleshooting -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// member_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// image_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - image_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "images/{image_id}/members/{id}", - image_id = self.image_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/images/{image_id}/members/{id}", - image_id = "image_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/images/{image_id}/members/{id}", - image_id = "image_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() - .image_id("image_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/member/get.rs b/openstack_sdk/src/api/image/v2/image/member/get.rs deleted file mode 100644 index 856b57df6..000000000 --- a/openstack_sdk/src/api/image/v2/image/member/get.rs +++ /dev/null @@ -1,210 +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`. - -//! Shows image member details. *(Since Image API v2.1)* -//! -//! Response body is a single image member entity. -//! -//! Preconditions -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// member_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// image_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - image_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "images/{image_id}/members/{id}", - image_id = self.image_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/images/{image_id}/members/{id}", - image_id = "image_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/images/{image_id}/members/{id}", - image_id = "image_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() - .image_id("image_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/member/list.rs b/openstack_sdk/src/api/image/v2/image/member/list.rs deleted file mode 100644 index d4a7ad3eb..000000000 --- a/openstack_sdk/src/api/image/v2/image/member/list.rs +++ /dev/null @@ -1,202 +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`. - -//! Lists the tenants that share this image. *(Since Image API v2.1)* -//! -//! If the image owner makes this call, the complete member list is returned. -//! -//! If a user who is an image member makes this call, the member list contains -//! only information for that user. -//! -//! If a user who is not an image member makes this call, the call returns the -//! HTTP `404` response code. -//! -//! Preconditions -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - image_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "images/{image_id}/members", - image_id = self.image_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("members".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "members" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/images/{image_id}/members", image_id = "image_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "members": {} })); - }); - - let endpoint = Request::builder().image_id("image_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/images/{image_id}/members", image_id = "image_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "members": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/member/set.rs b/openstack_sdk/src/api/image/v2/image/member/set.rs deleted file mode 100644 index 946190544..000000000 --- a/openstack_sdk/src/api/image/v2/image/member/set.rs +++ /dev/null @@ -1,246 +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`. - -//! Sets the status for an image member. *(Since Image API v2.1)* -//! -//! This call allows an image member to change his or her *member status*. -//! -//! When an image is shared with you, you have immediate access to the image. -//! What updating your member status on the image does for you is that it -//! affects whether the image will appear in your image list response. -//! -//! For a more detailed discussion of image sharing, please consult -//! [Image API v2 Sharing](http://specs.openstack.org/openstack/glance-specs/specs/api/v2/sharing-image-api-v2.html). -//! -//! Preconditions -//! -//! Synchronous Postconditions -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// member_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// image_id parameter for /v2/images/{image_id}/members/{member_id} API - #[builder(default, setter(into))] - image_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "images/{image_id}/members/{id}", - image_id = self.image_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/images/{image_id}/members/{id}", - image_id = "image_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/images/{image_id}/members/{id}", - image_id = "image_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() - .image_id("image_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/tag/delete.rs b/openstack_sdk/src/api/image/v2/image/tag/delete.rs deleted file mode 100644 index 7c9a0c131..000000000 --- a/openstack_sdk/src/api/image/v2/image/tag/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_id}/tags/{tag_value} API - #[builder(default, setter(into))] - image_id: Cow<'a, str>, - - /// tag_value parameter for /v2/images/{image_id}/tags/{tag_value} API - #[builder(default, setter(into))] - tag_value: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "images/{image_id}/tags/{tag_value}", - image_id = self.image_id.as_ref(), - tag_value = self.tag_value.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/images/{image_id}/tags/{tag_value}", - image_id = "image_id", - tag_value = "tag_value", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .tag_value("tag_value") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/images/{image_id}/tags/{tag_value}", - image_id = "image_id", - tag_value = "tag_value", - )) - .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("image_id") - .tag_value("tag_value") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/tag/set.rs b/openstack_sdk/src/api/image/v2/image/tag/set.rs deleted file mode 100644 index ca133b2c3..000000000 --- a/openstack_sdk/src/api/image/v2/image/tag/set.rs +++ /dev/null @@ -1,227 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_id}/tags/{tag_value} API - #[builder(default, setter(into))] - image_id: Cow<'a, str>, - - /// tag_value parameter for /v2/images/{image_id}/tags/{tag_value} API - #[builder(default, setter(into))] - tag_value: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "images/{image_id}/tags/{tag_value}", - image_id = self.image_id.as_ref(), - tag_value = self.tag_value.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/images/{image_id}/tags/{tag_value}", - image_id = "image_id", - tag_value = "tag_value", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .tag_value("tag_value") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/images/{image_id}/tags/{tag_value}", - image_id = "image_id", - tag_value = "tag_value", - )) - .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("image_id") - .tag_value("tag_value") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/image/task/list.rs b/openstack_sdk/src/api/image/v2/image/task/list.rs deleted file mode 100644 index d7e875974..000000000 --- a/openstack_sdk/src/api/image/v2/image/task/list.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows tasks associated with an image. *(Since Image API v2.12)* -//! -//! The response body contains list of tasks, possibly empty, associated with -//! the specified image. -//! -//! Preconditions -//! -//! Normal response codes: 200 -//! -//! Error response codes: 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// image_id parameter for /v2/images/{image_id}/tasks API - #[builder(default, setter(into))] - image_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 Task. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("images/{image_id}/tasks", image_id = self.image_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("tasks".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tasks" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/images/{image_id}/tasks", image_id = "image_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tasks": {} })); - }); - - let endpoint = Request::builder().image_id("image_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/images/{image_id}/tasks", image_id = "image_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tasks": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/info/import/get.rs b/openstack_sdk/src/api/image/v2/info/import/get.rs deleted file mode 100644 index 844efd634..000000000 --- a/openstack_sdk/src/api/image/v2/info/import/get.rs +++ /dev/null @@ -1,186 +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`. - -//! Returns information concerning the constraints around image import in the -//! cloud in which the call is made, for example, supported container formats, -//! supported disk formats, maximum image size, etc. This call contains a -//! `import-methods` field consisting of an array of string identifiers -//! indicating what import methods are supported in the cloud in which the call -//! is made. *(Since Image API v2.6)* -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Import. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "info/import".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("import-methods".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "import-methods" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/import".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "import-methods": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/import".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "import-methods": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/info/store/list.rs b/openstack_sdk/src/api/image/v2/info/store/list.rs deleted file mode 100644 index 66920d028..000000000 --- a/openstack_sdk/src/api/image/v2/info/store/list.rs +++ /dev/null @@ -1,186 +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`. - -//! A multiple store backend support is introduced in the Rocky release as a -//! part of the EXPERIMENTAL Image API v2.8. -//! -//! In version 2.7 of the API, this call will return a 404 (Not Found). Use the -//! [API versions call](../versions/index.html#versions-call) to determine what -//! API versions are available in your cloud. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Store. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "info/stores".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("stores".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "stores" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/stores".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stores": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/stores".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stores": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/info/store/list_detailed.rs b/openstack_sdk/src/api/image/v2/info/store/list_detailed.rs deleted file mode 100644 index 16e9fea8b..000000000 --- a/openstack_sdk/src/api/image/v2/info/store/list_detailed.rs +++ /dev/null @@ -1,182 +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`. - -//! Lists all the backend stores, with detail, accessible to admins, for -//! non-admin user API will return bad request. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Store. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "info/stores/detail".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("stores".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "stores" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/stores/detail".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stores": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/stores/detail".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stores": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/info/usage/list.rs b/openstack_sdk/src/api/image/v2/info/usage/list.rs deleted file mode 100644 index 9200465f0..000000000 --- a/openstack_sdk/src/api/image/v2/info/usage/list.rs +++ /dev/null @@ -1,180 +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`. - -//! The user’s quota and current usage are displayed, if enabled by server-side -//! configuration. -//! -//! Normal response codes: 200 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Usage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "info/usage".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("usage".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "usage" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/usage".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "usage": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/info/usage".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "usage": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/create.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/create.rs deleted file mode 100644 index 22096bf86..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/create.rs +++ /dev/null @@ -1,450 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "array")] - Array, - #[serde(rename = "boolean")] - Boolean, - #[serde(rename = "integer")] - Integer, - #[serde(rename = "number")] - Number, - #[serde(rename = "object")] - Object, - #[serde(rename = "string")] - String, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Items<'a> { - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Properties<'a> { - #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) additional_items: Option, - - /// OpenAPI specifies the field as '{}'. - #[serde(rename = "default", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _default: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) items: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_items: Option, - - #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_items: Option, - - #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) operators: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) pattern: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) readonly: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) title: Cow<'a, str>, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, - - #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) unique_items: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Objects<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_properties"))] - pub(crate) properties: Option, Properties<'a>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) required: Option>>, -} - -impl<'a> ObjectsBuilder<'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 - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ResourceTypeAssociations<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) properties_target: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Tags<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Visibility { - #[serde(rename = "private")] - Private, - #[serde(rename = "public")] - Public, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Provides a user friendly description of the namespace. - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The user friendly name for the namespace. Used by UI if available. - #[builder(default, setter(into))] - pub(crate) display_name: Option>, - - /// The unique namespace text. - #[builder(setter(into))] - pub(crate) namespace: Cow<'a, str>, - - #[builder(default, setter(into))] - pub(crate) objects: Option>>, - - /// Owner of the namespace. - #[builder(default, setter(into))] - pub(crate) owner: Option>, - - #[builder(default, private, setter(into, name = "_properties"))] - pub(crate) properties: Option, Properties<'a>>>, - - /// If true, namespace will not be deletable. - #[builder(default, setter(into))] - pub(crate) protected: Option, - - #[builder(default, setter(into))] - pub(crate) resource_type_associations: Option>>, - - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// Scope of namespace accessibility. - #[builder(default)] - pub(crate) visibility: 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 Namespace. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "metadefs/namespaces".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self.display_name { - params.push("display_name", serde_json::to_value(val)?); - } - params.push("namespace", serde_json::to_value(&self.namespace)?); - if let Some(val) = &self.objects { - params.push("objects", serde_json::to_value(val)?); - } - if let Some(val) = &self.owner { - params.push("owner", serde_json::to_value(val)?); - } - if let Some(val) = &self.properties { - params.push("properties", serde_json::to_value(val)?); - } - if let Some(val) = &self.protected { - params.push("protected", serde_json::to_value(val)?); - } - if let Some(val) = &self.resource_type_associations { - params.push("resource_type_associations", serde_json::to_value(val)?); - } - if let Some(val) = &self.tags { - params.push("tags", serde_json::to_value(val)?); - } - if let Some(val) = &self.visibility { - params.push("visibility", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .namespace("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .namespace("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/metadefs/namespaces".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().namespace("foo").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/metadefs/namespaces".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() - .namespace("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/delete.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/delete.rs deleted file mode 100644 index 129de80fa..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/delete.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for /v2/metadefs/namespaces/{namespace_name} - /// API - #[builder(default, setter(into))] - namespace_name: 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 Namespace. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/get.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/get.rs deleted file mode 100644 index f5dbd2beb..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/get.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for /v2/metadefs/namespaces/{namespace_name} - /// API - #[builder(default, setter(into))] - namespace_name: 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 Namespace. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/list.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/list.rs deleted file mode 100644 index a3368eacf..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/list.rs +++ /dev/null @@ -1,175 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Namespace. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "metadefs/namespaces".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("namespaces".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "namespaces" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metadefs/namespaces".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "namespaces": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metadefs/namespaces".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "namespaces": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/object/create.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/object/create.rs deleted file mode 100644 index 27dcc72ac..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/object/create.rs +++ /dev/null @@ -1,360 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "array")] - Array, - #[serde(rename = "boolean")] - Boolean, - #[serde(rename = "integer")] - Integer, - #[serde(rename = "number")] - Number, - #[serde(rename = "object")] - Object, - #[serde(rename = "string")] - String, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Items<'a> { - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Properties<'a> { - #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) additional_items: Option, - - /// OpenAPI specifies the field as '{}'. - #[serde(rename = "default", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _default: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) items: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_items: Option, - - #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_items: Option, - - #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) operators: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) pattern: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) readonly: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) title: Cow<'a, str>, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, - - #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) unique_items: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[builder(default, private, setter(into, name = "_properties"))] - pub(crate) properties: Option, Properties<'a>>>, - - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - namespace_name: 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> { - 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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "metadefs/namespaces/{namespace_name}/objects", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - params.push("name", serde_json::to_value(&self.name)?); - if let Some(val) = &self.properties { - params.push("properties", serde_json::to_value(val)?); - } - if let Some(val) = &self.required { - params.push("required", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/metadefs/namespaces/{namespace_name}/objects", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .name("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/metadefs/namespaces/{namespace_name}/objects", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/object/delete.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/object/delete.rs deleted file mode 100644 index 4f4b93a30..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/object/delete.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// object_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - object_name: 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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = self.namespace_name.as_ref(), - object_name = self.object_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = "namespace_name", - object_name = "object_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .object_name("object_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = "namespace_name", - object_name = "object_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .object_name("object_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/object/delete_all.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/object/delete_all.rs deleted file mode 100644 index 98f17a4d9..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/object/delete_all.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - namespace_name: 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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/objects", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}/objects", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}/objects", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/object/get.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/object/get.rs deleted file mode 100644 index 4537e306f..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/object/get.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// object_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - object_name: 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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = self.namespace_name.as_ref(), - object_name = self.object_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = "namespace_name", - object_name = "object_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .object_name("object_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = "namespace_name", - object_name = "object_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .object_name("object_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/object/list.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/object/list.rs deleted file mode 100644 index 2adb6ec9a..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/object/list.rs +++ /dev/null @@ -1,195 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - namespace_name: 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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/objects", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("objects".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "objects" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}/objects", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "objects": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}/objects", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "objects": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/object/set.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/object/set.rs deleted file mode 100644 index 07875a284..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/object/set.rs +++ /dev/null @@ -1,370 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "array")] - Array, - #[serde(rename = "boolean")] - Boolean, - #[serde(rename = "integer")] - Integer, - #[serde(rename = "number")] - Number, - #[serde(rename = "object")] - Object, - #[serde(rename = "string")] - String, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Items<'a> { - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Properties<'a> { - #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) additional_items: Option, - - /// OpenAPI specifies the field as '{}'. - #[serde(rename = "default", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _default: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) items: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_items: Option, - - #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_items: Option, - - #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) operators: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) pattern: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) readonly: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) title: Cow<'a, str>, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, - - #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) unique_items: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[builder(default, private, setter(into, name = "_properties"))] - pub(crate) properties: Option, Properties<'a>>>, - - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// object_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API - #[builder(default, setter(into))] - object_name: 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> { - 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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = self.namespace_name.as_ref(), - object_name = self.object_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - params.push("name", serde_json::to_value(&self.name)?); - if let Some(val) = &self.properties { - params.push("properties", serde_json::to_value(val)?); - } - if let Some(val) = &self.required { - params.push("required", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = "namespace_name", - object_name = "object_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .object_name("object_name") - .name("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/metadefs/namespaces/{namespace_name}/objects/{object_name}", - namespace_name = "namespace_name", - object_name = "object_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .object_name("object_name") - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/property/create.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/property/create.rs deleted file mode 100644 index f6ec72f65..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/property/create.rs +++ /dev/null @@ -1,360 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "array")] - Array, - #[serde(rename = "boolean")] - Boolean, - #[serde(rename = "integer")] - Integer, - #[serde(rename = "number")] - Number, - #[serde(rename = "object")] - Object, - #[serde(rename = "string")] - String, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Items<'a> { - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - pub(crate) additional_items: Option, - - /// OpenAPI specifies the field as '{}'. - #[builder(default, setter(into))] - pub(crate) _default: Option, - - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[builder(default, setter(into))] - pub(crate) items: Option>, - - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[builder(default, setter(into))] - pub(crate) max_items: Option, - - #[builder(default, setter(into))] - pub(crate) max_length: Option, - - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[builder(default, setter(into))] - pub(crate) min_items: Option, - - #[builder(default, setter(into))] - pub(crate) min_length: Option, - - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[builder(default, setter(into))] - pub(crate) operators: Option>>, - - #[builder(default, setter(into))] - pub(crate) pattern: Option>, - - #[builder(default, setter(into))] - pub(crate) readonly: Option, - - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - #[builder(setter(into))] - pub(crate) title: Cow<'a, str>, - - #[builder()] - pub(crate) _type: Type, - - #[builder(default, setter(into))] - pub(crate) unique_items: Option, - - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - namespace_name: 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 Property. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "metadefs/namespaces/{namespace_name}/properties", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.additional_items { - params.push("additionalItems", serde_json::to_value(val)?); - } - if let Some(val) = &self._default { - params.push("default", serde_json::to_value(val)?); - } - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self._enum { - params.push("enum", serde_json::to_value(val)?); - } - if let Some(val) = &self.items { - params.push("items", serde_json::to_value(val)?); - } - if let Some(val) = &self.max_items { - params.push("maxItems", serde_json::to_value(val)?); - } - if let Some(val) = &self.max_length { - params.push("maxLength", serde_json::to_value(val)?); - } - if let Some(val) = &self.maximum { - params.push("maximum", serde_json::to_value(val)?); - } - if let Some(val) = &self.min_items { - params.push("minItems", serde_json::to_value(val)?); - } - if let Some(val) = &self.min_length { - params.push("minLength", serde_json::to_value(val)?); - } - if let Some(val) = &self.minimum { - params.push("minimum", serde_json::to_value(val)?); - } - params.push("name", serde_json::to_value(&self.name)?); - if let Some(val) = &self.operators { - params.push("operators", serde_json::to_value(val)?); - } - if let Some(val) = &self.pattern { - params.push("pattern", serde_json::to_value(val)?); - } - if let Some(val) = &self.readonly { - params.push("readonly", serde_json::to_value(val)?); - } - if let Some(val) = &self.required { - params.push("required", serde_json::to_value(val)?); - } - params.push("title", serde_json::to_value(&self.title)?); - params.push("type", serde_json::to_value(&self._type)?); - if let Some(val) = &self.unique_items { - params.push("uniqueItems", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .title("foo") - ._type(Type::Array) - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .title("foo") - ._type(Type::Array) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/metadefs/namespaces/{namespace_name}/properties", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .name("foo") - .title("foo") - ._type(Type::Array) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/metadefs/namespaces/{namespace_name}/properties", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .name("foo") - .title("foo") - ._type(Type::Array) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/property/delete.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/property/delete.rs deleted file mode 100644 index f2a87fddb..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/property/delete.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// property_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - property_name: 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 Property. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = self.namespace_name.as_ref(), - property_name = self.property_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = "namespace_name", - property_name = "property_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .property_name("property_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = "namespace_name", - property_name = "property_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .property_name("property_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/property/delete_all.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/property/delete_all.rs deleted file mode 100644 index e5b4a18d8..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/property/delete_all.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - namespace_name: 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 Property. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/properties", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}/properties", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}/properties", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/property/get.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/property/get.rs deleted file mode 100644 index d18e9f6e4..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/property/get.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// property_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - property_name: 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 Property. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = self.namespace_name.as_ref(), - property_name = self.property_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = "namespace_name", - property_name = "property_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .property_name("property_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = "namespace_name", - property_name = "property_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .property_name("property_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/property/list.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/property/list.rs deleted file mode 100644 index 1199aee1b..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/property/list.rs +++ /dev/null @@ -1,195 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - namespace_name: 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 Property. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/properties", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("properties".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "properties" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}/properties", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "properties": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}/properties", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "properties": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/property/set.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/property/set.rs deleted file mode 100644 index 642612610..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/property/set.rs +++ /dev/null @@ -1,370 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "array")] - Array, - #[serde(rename = "boolean")] - Boolean, - #[serde(rename = "integer")] - Integer, - #[serde(rename = "number")] - Number, - #[serde(rename = "object")] - Object, - #[serde(rename = "string")] - String, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Items<'a> { - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - pub(crate) additional_items: Option, - - /// OpenAPI specifies the field as '{}'. - #[builder(default, setter(into))] - pub(crate) _default: Option, - - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[builder(default, setter(into))] - pub(crate) items: Option>, - - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[builder(default, setter(into))] - pub(crate) max_items: Option, - - #[builder(default, setter(into))] - pub(crate) max_length: Option, - - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[builder(default, setter(into))] - pub(crate) min_items: Option, - - #[builder(default, setter(into))] - pub(crate) min_length: Option, - - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[builder(default, setter(into))] - pub(crate) operators: Option>>, - - #[builder(default, setter(into))] - pub(crate) pattern: Option>, - - #[builder(default, setter(into))] - pub(crate) readonly: Option, - - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - #[builder(setter(into))] - pub(crate) title: Cow<'a, str>, - - #[builder()] - pub(crate) _type: Type, - - #[builder(default, setter(into))] - pub(crate) unique_items: Option, - - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// property_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API - #[builder(default, setter(into))] - property_name: 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 Property. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = self.namespace_name.as_ref(), - property_name = self.property_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.additional_items { - params.push("additionalItems", serde_json::to_value(val)?); - } - if let Some(val) = &self._default { - params.push("default", serde_json::to_value(val)?); - } - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self._enum { - params.push("enum", serde_json::to_value(val)?); - } - if let Some(val) = &self.items { - params.push("items", serde_json::to_value(val)?); - } - if let Some(val) = &self.max_items { - params.push("maxItems", serde_json::to_value(val)?); - } - if let Some(val) = &self.max_length { - params.push("maxLength", serde_json::to_value(val)?); - } - if let Some(val) = &self.maximum { - params.push("maximum", serde_json::to_value(val)?); - } - if let Some(val) = &self.min_items { - params.push("minItems", serde_json::to_value(val)?); - } - if let Some(val) = &self.min_length { - params.push("minLength", serde_json::to_value(val)?); - } - if let Some(val) = &self.minimum { - params.push("minimum", serde_json::to_value(val)?); - } - params.push("name", serde_json::to_value(&self.name)?); - if let Some(val) = &self.operators { - params.push("operators", serde_json::to_value(val)?); - } - if let Some(val) = &self.pattern { - params.push("pattern", serde_json::to_value(val)?); - } - if let Some(val) = &self.readonly { - params.push("readonly", serde_json::to_value(val)?); - } - if let Some(val) = &self.required { - params.push("required", serde_json::to_value(val)?); - } - params.push("title", serde_json::to_value(&self.title)?); - params.push("type", serde_json::to_value(&self._type)?); - if let Some(val) = &self.unique_items { - params.push("uniqueItems", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .title("foo") - ._type(Type::Array) - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .title("foo") - ._type(Type::Array) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = "namespace_name", - property_name = "property_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .property_name("property_name") - .name("foo") - .title("foo") - ._type(Type::Array) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/metadefs/namespaces/{namespace_name}/properties/{property_name}", - namespace_name = "namespace_name", - property_name = "property_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .property_name("property_name") - .name("foo") - .title("foo") - ._type(Type::Array) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/create.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/create.rs deleted file mode 100644 index 608d1bd44..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/create.rs +++ /dev/null @@ -1,241 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Resource type names should be aligned with Heat resource types whenever - /// possible: - /// https://docs.openstack.org/heat/latest/template_guide/openstack.html - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// Specifies the prefix to use for the given resource type. Any properties - /// in the namespace should be prefixed with this prefix when being applied - /// to the specified resource type. Must include prefix separator (e.g. a - /// colon :). - #[builder(default, setter(into))] - pub(crate) prefix: Option>, - - /// Some resource types allow more than one key / value pair per instance. - /// For example, Cinder allows user and image metadata on volumes. Only the - /// image properties metadata is evaluated by Nova (scheduling or drivers). - /// This property allows a namespace target to remove the ambiguity. - #[builder(default, setter(into))] - pub(crate) properties_target: Option>, - - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} - /// API - #[builder(default, setter(into))] - namespace_name: 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 Resource_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "metadefs/namespaces/{namespace_name}/resource_types", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("name", serde_json::to_value(&self.name)?); - if let Some(val) = &self.prefix { - params.push("prefix", serde_json::to_value(val)?); - } - if let Some(val) = &self.properties_target { - params.push("properties_target", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("resource_type_associations".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .unwrap(), - "resource_type_associations" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/metadefs/namespaces/{namespace_name}/resource_types", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_type_associations": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .name("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/metadefs/namespaces/{namespace_name}/resource_types", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_type_associations": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/delete.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/delete.rs deleted file mode 100644 index 723f41646..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/delete.rs +++ /dev/null @@ -1,207 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} - /// API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// resource_type parameter for - /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} - /// API - #[builder(default, setter(into))] - resource_type: 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 Resource_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/resource_types/{resource_type}", - namespace_name = self.namespace_name.as_ref(), - resource_type = self.resource_type.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("resource_type_associations".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "resource_type_associations" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}/resource_types/{resource_type}", - namespace_name = "namespace_name", - resource_type = "resource_type", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_type_associations": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .resource_type("resource_type") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}/resource_types/{resource_type}", - namespace_name = "namespace_name", - resource_type = "resource_type", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_type_associations": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .resource_type("resource_type") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/list.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/list.rs deleted file mode 100644 index 9c5710e6e..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type/list.rs +++ /dev/null @@ -1,196 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} - /// API - #[builder(default, setter(into))] - namespace_name: 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 Resource_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/resource_types", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("resource_type_associations".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "resource_type_associations" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}/resource_types", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_type_associations": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}/resource_types", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_type_associations": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/set.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/set.rs deleted file mode 100644 index 9e9de4f61..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/set.rs +++ /dev/null @@ -1,469 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "array")] - Array, - #[serde(rename = "boolean")] - Boolean, - #[serde(rename = "integer")] - Integer, - #[serde(rename = "number")] - Number, - #[serde(rename = "object")] - Object, - #[serde(rename = "string")] - String, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Items<'a> { - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Properties<'a> { - #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) additional_items: Option, - - /// OpenAPI specifies the field as '{}'. - #[serde(rename = "default", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _default: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) _enum: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) items: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_items: Option, - - #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_items: Option, - - #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_length: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) operators: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) pattern: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) readonly: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) required: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) title: Cow<'a, str>, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, - - #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) unique_items: Option, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Objects<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_properties"))] - pub(crate) properties: Option, Properties<'a>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) required: Option>>, -} - -impl<'a> ObjectsBuilder<'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 - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ResourceTypeAssociations<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) properties_target: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Tags<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Visibility { - #[serde(rename = "private")] - Private, - #[serde(rename = "public")] - Public, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Provides a user friendly description of the namespace. - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The user friendly name for the namespace. Used by UI if available. - #[builder(default, setter(into))] - pub(crate) display_name: Option>, - - /// The unique namespace text. - #[builder(setter(into))] - pub(crate) namespace: Cow<'a, str>, - - #[builder(default, setter(into))] - pub(crate) objects: Option>>, - - /// Owner of the namespace. - #[builder(default, setter(into))] - pub(crate) owner: Option>, - - #[builder(default, private, setter(into, name = "_properties"))] - pub(crate) properties: Option, Properties<'a>>>, - - /// If true, namespace will not be deletable. - #[builder(default, setter(into))] - pub(crate) protected: Option, - - #[builder(default, setter(into))] - pub(crate) resource_type_associations: Option>>, - - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// Scope of namespace accessibility. - #[builder(default)] - pub(crate) visibility: Option, - - /// namespace_name parameter for /v2/metadefs/namespaces/{namespace_name} - /// API - #[builder(default, setter(into))] - namespace_name: 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> { - 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 Namespace. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "metadefs/namespaces/{namespace_name}", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.description { - params.push("description", serde_json::to_value(val)?); - } - if let Some(val) = &self.display_name { - params.push("display_name", serde_json::to_value(val)?); - } - params.push("namespace", serde_json::to_value(&self.namespace)?); - if let Some(val) = &self.objects { - params.push("objects", serde_json::to_value(val)?); - } - if let Some(val) = &self.owner { - params.push("owner", serde_json::to_value(val)?); - } - if let Some(val) = &self.properties { - params.push("properties", serde_json::to_value(val)?); - } - if let Some(val) = &self.protected { - params.push("protected", serde_json::to_value(val)?); - } - if let Some(val) = &self.resource_type_associations { - params.push("resource_type_associations", serde_json::to_value(val)?); - } - if let Some(val) = &self.tags { - params.push("tags", serde_json::to_value(val)?); - } - if let Some(val) = &self.visibility { - params.push("visibility", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .namespace("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .namespace("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/metadefs/namespaces/{namespace_name}", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .namespace("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/metadefs/namespaces/{namespace_name}", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .namespace("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/create.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/tag/create.rs deleted file mode 100644 index 96b489500..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/create.rs +++ /dev/null @@ -1,226 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// tag_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - tag_name: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = self.namespace_name.as_ref(), - tag_name = self.tag_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("name", serde_json::to_value(&self.name)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .name("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/delete.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/tag/delete.rs deleted file mode 100644 index a73c74c45..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/delete.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// tag_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - tag_name: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = self.namespace_name.as_ref(), - tag_name = self.tag_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/delete_all.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/tag/delete_all.rs deleted file mode 100644 index 1524a8671..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/delete_all.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - namespace_name: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/tags", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/metadefs/namespaces/{namespace_name}/tags", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/metadefs/namespaces/{namespace_name}/tags", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/get.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/tag/get.rs deleted file mode 100644 index a73119432..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/get.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// tag_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - tag_name: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = self.namespace_name.as_ref(), - tag_name = self.tag_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/list.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/tag/list.rs deleted file mode 100644 index 0c034d3fb..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/list.rs +++ /dev/null @@ -1,195 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - namespace_name: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "metadefs/namespaces/{namespace_name}/tags", - namespace_name = self.namespace_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/metadefs/namespaces/{namespace_name}/tags", - namespace_name = "namespace_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/metadefs/namespaces/{namespace_name}/tags", - namespace_name = "namespace_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/set.rs b/openstack_sdk/src/api/image/v2/metadef/namespace/tag/set.rs deleted file mode 100644 index c202ddd6e..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/namespace/tag/set.rs +++ /dev/null @@ -1,226 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// namespace_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - namespace_name: Cow<'a, str>, - - /// tag_name parameter for - /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API - #[builder(default, setter(into))] - tag_name: 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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = self.namespace_name.as_ref(), - tag_name = self.tag_name.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("name", serde_json::to_value(&self.name)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .name("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", - namespace_name = "namespace_name", - tag_name = "tag_name", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .namespace_name("namespace_name") - .tag_name("tag_name") - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/metadef/resource_type/get.rs b/openstack_sdk/src/api/image/v2/metadef/resource_type/get.rs deleted file mode 100644 index a8aae8a01..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/resource_type/get.rs +++ /dev/null @@ -1,165 +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`. - -//! Lists all available resource types. -//! -//! Using the other API calls in this section, you can create and maintain -//! *resource type associations* between metadata definition namespaces and the -//! resource types that are returned by this call. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -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 Resource_Type. - 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> { - "v2/metadefs/resource_types".to_string().into() - } - - fn parameters(&self) -> QueryParams { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - #![allow(unused_imports)] - use super::*; - use crate::api::Query; - 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::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[test] - fn endpoint() { - let client = MockServerClient::new(); - let mock = client.server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/v2/metadefs/resource_types".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(); - } - - #[test] - fn endpoint_headers() { - let client = MockServerClient::new(); - let mock = client.server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/v2/metadefs/resource_types".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/image/v2/metadef/resource_type/list.rs b/openstack_sdk/src/api/image/v2/metadef/resource_type/list.rs deleted file mode 100644 index a13930ce7..000000000 --- a/openstack_sdk/src/api/image/v2/metadef/resource_type/list.rs +++ /dev/null @@ -1,175 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Resource_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "metadefs/resource_types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("resource_types".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "resource_types" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metadefs/resource_types".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_types": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metadefs/resource_types".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_types": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/image/get.rs b/openstack_sdk/src/api/image/v2/schema/image/get.rs deleted file mode 100644 index 7eee49d83..000000000 --- a/openstack_sdk/src/api/image/v2/schema/image/get.rs +++ /dev/null @@ -1,183 +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`. - -//! *(Since Images v2.0)* -//! -//! Shows a JSON schema document that represents an *image* entity. -//! -//! The following schema is solely an example. Consider only the response to -//! the API call as authoritative. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Image. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/image".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/image".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/image".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/images/get.rs b/openstack_sdk/src/api/image/v2/schema/images/get.rs deleted file mode 100644 index 099c5db6e..000000000 --- a/openstack_sdk/src/api/image/v2/schema/images/get.rs +++ /dev/null @@ -1,185 +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`. - -//! *(Since Images v2.0)* -//! -//! Shows a JSON schema document that represents an *images* entity. -//! -//! An images entity is a container of image entities. -//! -//! The following schema is solely an example. Consider only the response to -//! the API call as authoritative. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Images. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/images".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/images".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/images".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/member/get.rs b/openstack_sdk/src/api/image/v2/schema/member/get.rs deleted file mode 100644 index 19b577db6..000000000 --- a/openstack_sdk/src/api/image/v2/schema/member/get.rs +++ /dev/null @@ -1,183 +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`. - -//! *(Since Images v2.1)* -//! -//! Shows a JSON schema document that represents an *image member* entity. -//! -//! The following schema is solely an example. Consider only the response to -//! the API call as authoritative. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/member".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/member".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/member".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/members/get.rs b/openstack_sdk/src/api/image/v2/schema/members/get.rs deleted file mode 100644 index 0e31fca5d..000000000 --- a/openstack_sdk/src/api/image/v2/schema/members/get.rs +++ /dev/null @@ -1,185 +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`. - -//! *(Since Images v2.1)* -//! -//! Shows a JSON schema document that represents an *image members* entity. -//! -//! An image members entity is a container of image member entities. -//! -//! The following schema is solely an example. Consider only the response to -//! the API call as authoritative. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Members. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/members".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/members".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/members".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/namespace/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/namespace/get.rs deleted file mode 100644 index b14f79e69..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/namespace/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Namespace. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/namespace".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/namespace".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/namespace".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/namespaces/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/namespaces/get.rs deleted file mode 100644 index b816295db..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/namespaces/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Namespaces. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/namespaces".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/namespaces".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/namespaces".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/object/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/object/get.rs deleted file mode 100644 index 3f96e6559..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/object/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/object".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/object".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/object".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/objects/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/objects/get.rs deleted file mode 100644 index 80dae135c..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/objects/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Objects. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/objects".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/objects".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/objects".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/properties/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/properties/get.rs deleted file mode 100644 index bf9bacb29..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/properties/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Properties. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/properties".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/properties".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/properties".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/property/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/property/get.rs deleted file mode 100644 index 92f3c05b1..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/property/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Property. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/property".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/property".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/property".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/resource_type/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/resource_type/get.rs deleted file mode 100644 index ab4dbafce..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/resource_type/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Resource_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/resource_type".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/resource_type".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/resource_type".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/resource_types/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/resource_types/get.rs deleted file mode 100644 index 735c8f935..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/resource_types/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Resource_Types. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/resource_types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/resource_types".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/resource_types".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/tag/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/tag/get.rs deleted file mode 100644 index 55ac2c035..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/tag/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/tag".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/tag".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/tag".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/tags/get.rs b/openstack_sdk/src/api/image/v2/schema/metadef/tags/get.rs deleted file mode 100644 index a30646536..000000000 --- a/openstack_sdk/src/api/image/v2/schema/metadef/tags/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Tags. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/metadefs/tags".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/tags".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/metadefs/tags".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/task/get.rs b/openstack_sdk/src/api/image/v2/schema/task/get.rs deleted file mode 100644 index c822b6544..000000000 --- a/openstack_sdk/src/api/image/v2/schema/task/get.rs +++ /dev/null @@ -1,183 +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`. - -//! *(Since Images v2.2)* -//! -//! Shows a JSON schema document that represents an *task* entity. -//! -//! The following schema is solely an example. Consider only the response to -//! the API call as authoritative. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Task. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/task".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/task".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/task".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/schema/tasks/get.rs b/openstack_sdk/src/api/image/v2/schema/tasks/get.rs deleted file mode 100644 index bd514c00a..000000000 --- a/openstack_sdk/src/api/image/v2/schema/tasks/get.rs +++ /dev/null @@ -1,186 +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`. - -//! *(Since Images v2.2)* -//! -//! Shows a JSON schema document that represents a list of *tasks*. -//! -//! An tasks list entity is a container of entities containing abbreviated -//! information about individual tasks. -//! -//! The following schema is solely an example. Consider only the response to -//! the API call as authoritative. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Tasks. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "schemas/tasks".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/tasks".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/schemas/tasks".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/store/delete.rs b/openstack_sdk/src/api/image/v2/store/delete.rs deleted file mode 100644 index ae1ca0d2c..000000000 --- a/openstack_sdk/src/api/image/v2/store/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! This API allows you to delete a copy of the image from a specific store. -//! *(Since Image API v2.10)* -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// store_id parameter for /v2/stores/{store_id}/{image_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// image_id parameter for /v2/stores/{store_id}/{image_id} API - #[builder(default, setter(into))] - image_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 Store. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "stores/{id}/{image_id}", - image_id = self.image_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/stores/{id}/{image_id}", - image_id = "image_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .image_id("image_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/stores/{id}/{image_id}", - image_id = "image_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() - .image_id("image_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/task/create.rs b/openstack_sdk/src/api/image/v2/task/create.rs deleted file mode 100644 index b6e6a590c..000000000 --- a/openstack_sdk/src/api/image/v2/task/create.rs +++ /dev/null @@ -1,337 +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`. - -//! Creates a task. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 401, 413, 415 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Status { - #[serde(rename = "failure")] - Failure, - #[serde(rename = "pending")] - Pending, - #[serde(rename = "processing")] - Processing, - #[serde(rename = "success")] - Success, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "api_image_import")] - ApiImageImport, - #[serde(rename = "import")] - Import, - #[serde(rename = "location_import")] - LocationImport, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Datetime when this resource was created - #[builder(default, setter(into))] - pub(crate) created_at: Option>, - - /// Datetime when this resource would be subject to removal - #[builder(default, setter(into))] - pub(crate) expires_at: Option>>, - - /// An identifier for the task - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Image associated with the task - #[builder(default, setter(into))] - pub(crate) image_id: Option>, - - /// A JSON object specifying the input parameters to the task. Consult your - /// cloud provider’s documentation for details. - #[builder(default, private, setter(into, name = "_input"))] - pub(crate) input: Option, Value>>>, - - /// Human-readable informative message only included when appropriate - /// (usually on failure) - #[builder(default, setter(into))] - pub(crate) message: Option>, - - /// An identifier for the owner of this task - #[builder(default, setter(into))] - pub(crate) owner: Option>, - - /// Human-readable informative request-id - #[builder(default, setter(into))] - pub(crate) request_id: Option>, - - /// The result of current task, JSON blob - #[builder(default, private, setter(into, name = "_result"))] - pub(crate) result: Option, Value>>>, - - /// The current status of this task - #[builder(default)] - pub(crate) status: Option, - - /// The type of task represented by this content. - #[builder(default)] - pub(crate) _type: Option, - - /// Datetime when this resource was updated - #[builder(default, setter(into))] - pub(crate) updated_at: Option>, - - /// User associated with the task - #[builder(default, setter(into))] - pub(crate) user_id: 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> { - /// A JSON object specifying the input parameters to the task. Consult your - /// cloud provider’s documentation for details. - pub fn input(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.input - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// The result of current task, JSON blob - pub fn result(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.result - .get_or_insert(None) - .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 Task. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "tasks".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.created_at { - params.push("created_at", serde_json::to_value(val)?); - } - if let Some(val) = &self.expires_at { - params.push("expires_at", serde_json::to_value(val)?); - } - if let Some(val) = &self.id { - params.push("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.input { - params.push("input", serde_json::to_value(val)?); - } - if let Some(val) = &self.message { - params.push("message", serde_json::to_value(val)?); - } - if let Some(val) = &self.owner { - params.push("owner", serde_json::to_value(val)?); - } - if let Some(val) = &self.request_id { - params.push("request_id", serde_json::to_value(val)?); - } - if let Some(val) = &self.result { - params.push("result", serde_json::to_value(val)?); - } - if let Some(val) = &self.status { - params.push("status", serde_json::to_value(val)?); - } - if let Some(val) = &self._type { - params.push("type", serde_json::to_value(val)?); - } - if let Some(val) = &self.updated_at { - params.push("updated_at", serde_json::to_value(val)?); - } - if let Some(val) = &self.user_id { - params.push("user_id", serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/tasks".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/tasks".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/task/delete.rs b/openstack_sdk/src/api/image/v2/task/delete.rs deleted file mode 100644 index d0b73d6a1..000000000 --- a/openstack_sdk/src/api/image/v2/task/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// task_id parameter for /v2/tasks/{task_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<'a> RequestBuilder<'a> { - /// Add a single header to the Task. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("tasks/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/tasks/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/tasks/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/task/get.rs b/openstack_sdk/src/api/image/v2/task/get.rs deleted file mode 100644 index 32f09a53c..000000000 --- a/openstack_sdk/src/api/image/v2/task/get.rs +++ /dev/null @@ -1,185 +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`. - -//! Shows details for a task. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// task_id parameter for /v2/tasks/{task_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<'a> RequestBuilder<'a> { - /// Add a single header to the Task. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("tasks/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/tasks/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/tasks/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/image/v2/task/list.rs b/openstack_sdk/src/api/image/v2/task/list.rs deleted file mode 100644 index 2573c7d71..000000000 --- a/openstack_sdk/src/api/image/v2/task/list.rs +++ /dev/null @@ -1,181 +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`. - -//! Lists tasks. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 403, 404, 413 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Task. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "tasks".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Image - } - - fn response_key(&self) -> Option> { - Some("tasks".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Image - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tasks" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/tasks".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tasks": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/tasks".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tasks": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer.rs b/openstack_sdk/src/api/load_balancer.rs index a03696e6b..f0060e26c 100644 --- a/openstack_sdk/src/api/load_balancer.rs +++ b/openstack_sdk/src/api/load_balancer.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Load Balancing API (Octavia) bindings -pub mod v2; +//! # Load Balancing API (Octavia) bindings +pub use openstack_sdk_load_balancer::*; diff --git a/openstack_sdk/src/api/load_balancer/v2/amphorae/delete.rs b/openstack_sdk/src/api/load_balancer/v2/amphorae/delete.rs deleted file mode 100644 index ba96319dd..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/amphorae/delete.rs +++ /dev/null @@ -1,195 +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`. - -//! Removes an amphora and its associated configuration. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -//! **New in version 2.20** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id} API - #[builder(default, setter(into))] - amphora_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 Amphorae. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "octavia/amphorae/{amphora_id}", - amphora_id = self.amphora_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/octavia/amphorae/{amphora_id}", - amphora_id = "amphora_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/octavia/amphorae/{amphora_id}", - amphora_id = "amphora_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() - .amphora_id("amphora_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/amphorae/failover.rs b/openstack_sdk/src/api/load_balancer/v2/amphorae/failover.rs deleted file mode 100644 index 082d2822b..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/amphorae/failover.rs +++ /dev/null @@ -1,195 +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`. - -//! Force an amphora to failover. -//! -//! If you are not an administrative user, the service returns the HTTP -//! `Forbidden (403)` response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id}/failover API - #[builder(default, setter(into))] - amphora_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 Amphorae. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "octavia/amphorae/{amphora_id}/failover", - amphora_id = self.amphora_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/octavia/amphorae/{amphora_id}/failover", - amphora_id = "amphora_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/octavia/amphorae/{amphora_id}/failover", - amphora_id = "amphora_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() - .amphora_id("amphora_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/amphorae/get.rs b/openstack_sdk/src/api/load_balancer/v2/amphorae/get.rs deleted file mode 100644 index 2eefd18d1..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/amphorae/get.rs +++ /dev/null @@ -1,198 +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`. - -//! Shows the details of an amphora. -//! -//! If you are not an administrative user, the service returns the HTTP -//! `Forbidden (403)` response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id} API - #[builder(default, setter(into))] - amphora_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 Amphorae. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "octavia/amphorae/{amphora_id}", - amphora_id = self.amphora_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("amphora".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "amphora" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/octavia/amphorae/{amphora_id}", - amphora_id = "amphora_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "amphora": {} })); - }); - - let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/octavia/amphorae/{amphora_id}", - amphora_id = "amphora_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "amphora": {} })); - }); - - let endpoint = Request::builder() - .amphora_id("amphora_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/amphorae/list.rs b/openstack_sdk/src/api/load_balancer/v2/amphorae/list.rs deleted file mode 100644 index 5486569f8..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/amphorae/list.rs +++ /dev/null @@ -1,288 +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`. - -//! Lists all amphora for the project. -//! -//! If you are not an administrative user, the service returns the HTTP -//! `Forbidden (403)` response code. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - cached_zone: Option>, - - #[builder(default, setter(into))] - cert_busy: Option>, - - #[builder(default, setter(into))] - cert_expiration: Option>, - - #[builder(default, setter(into))] - compute_flavor: Option>, - - #[builder(default, setter(into))] - compute_id: Option>, - - #[builder(default, setter(into))] - created_at: Option>, - - #[builder(default, setter(into))] - ha_ip: Option>, - - #[builder(default, setter(into))] - ha_port_id: Option>, - - #[builder(default, setter(into))] - id: Option>, - - #[builder(default, setter(into))] - image_id: Option>, - - #[builder(default, setter(into))] - lb_network_ip: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - loadbalancer_id: Option>, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - #[builder(default, setter(into))] - role: Option>, - - #[builder(default, setter(into))] - status: Option>, - - #[builder(default, setter(into))] - updated_at: Option>, - - #[builder(default, setter(into))] - vrrp_id: Option>, - - #[builder(default, setter(into))] - vrrp_interface: Option>, - - #[builder(default, setter(into))] - vrrp_ip: Option>, - - #[builder(default, setter(into))] - vrrp_port_id: Option>, - - #[builder(default, setter(into))] - vrrp_priority: 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> { - /// Add a single header to the Amphorae. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "octavia/amphorae".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("cached_zone", self.cached_zone.as_ref()); - params.push_opt("cert_busy", self.cert_busy.as_ref()); - params.push_opt("cert_expiration", self.cert_expiration.as_ref()); - params.push_opt("compute_flavor", self.compute_flavor.as_ref()); - params.push_opt("compute_id", self.compute_id.as_ref()); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("ha_ip", self.ha_ip.as_ref()); - params.push_opt("ha_port_id", self.ha_port_id.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("image_id", self.image_id.as_ref()); - params.push_opt("lb_network_ip", self.lb_network_ip.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("loadbalancer_id", self.loadbalancer_id.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("role", self.role.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - params.push_opt("vrrp_id", self.vrrp_id.as_ref()); - params.push_opt("vrrp_interface", self.vrrp_interface.as_ref()); - params.push_opt("vrrp_ip", self.vrrp_ip.as_ref()); - params.push_opt("vrrp_port_id", self.vrrp_port_id.as_ref()); - params.push_opt("vrrp_priority", self.vrrp_priority.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("amphorae".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "amphorae" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/octavia/amphorae".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "amphorae": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/octavia/amphorae".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "amphorae": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/amphorae/stats.rs b/openstack_sdk/src/api/load_balancer/v2/amphorae/stats.rs deleted file mode 100644 index e1f927df8..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/amphorae/stats.rs +++ /dev/null @@ -1,198 +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 statistics for an amphora. -//! -//! If you are not an administrative user, the service returns the HTTP -//! `Forbidden (403)` response code. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. -//! -//! **New in version 2.3** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id}/stats API - #[builder(default, setter(into))] - amphora_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 Amphorae. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "octavia/amphorae/{amphora_id}/stats", - amphora_id = self.amphora_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/octavia/amphorae/{amphora_id}/stats", - amphora_id = "amphora_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/octavia/amphorae/{amphora_id}/stats", - amphora_id = "amphora_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() - .amphora_id("amphora_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone/create.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone/create.rs deleted file mode 100644 index 892e96aa3..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone/create.rs +++ /dev/null @@ -1,254 +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`. - -//! Creates an Availability Zone. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AvailabilityZone<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) availability_zone_profile_id: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) availability_zone: AvailabilityZone<'a>, - - #[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 Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/availabilityzones".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "availability_zone", - serde_json::to_value(&self.availability_zone)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .availability_zone( - AvailabilityZoneBuilder::default() - .availability_zone_profile_id("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .availability_zone( - AvailabilityZoneBuilder::default() - .availability_zone_profile_id("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "availability_zone" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/availabilityzones".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone": {} })); - }); - - let endpoint = Request::builder() - .availability_zone( - AvailabilityZoneBuilder::default() - .availability_zone_profile_id("foo") - .name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/availabilityzones".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone": {} })); - }); - - let endpoint = Request::builder() - .availability_zone( - AvailabilityZoneBuilder::default() - .availability_zone_profile_id("foo") - .name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone/delete.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone/delete.rs deleted file mode 100644 index 66e1fd622..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone/delete.rs +++ /dev/null @@ -1,182 +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`. - -//! Deletes an Availability Zone -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// availabilityzone_id parameter for - /// /v2/lbaas/availabilityzones/{availabilityzone_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<'a> RequestBuilder<'a> { - /// Add a single header to the Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/availabilityzones/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/availabilityzones/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/availabilityzones/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone/get.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone/get.rs deleted file mode 100644 index b5311c4f3..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone/get.rs +++ /dev/null @@ -1,185 +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`. - -//! Gets an Availability Zone's detail. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// availabilityzone_id parameter for - /// /v2/lbaas/availabilityzones/{availabilityzone_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<'a> RequestBuilder<'a> { - /// Add a single header to the Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/availabilityzones/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availability_zone" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/availabilityzones/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/availabilityzones/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone/list.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone/list.rs deleted file mode 100644 index b4e64a753..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone/list.rs +++ /dev/null @@ -1,217 +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`. - -//! Lists all Availability Zones. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - availability_zone_profile_id: Option>, - - #[builder(default, setter(into))] - description: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - name: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - #[builder(default, setter(into))] - status: 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> { - /// Add a single header to the Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/availabilityzones".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt( - "availability_zone_profile_id", - self.availability_zone_profile_id.as_ref(), - ); - params.push_opt("description", self.description.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("status", self.status.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zones".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availability_zones" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/availabilityzones".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zones": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/availabilityzones".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zones": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone/set.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone/set.rs deleted file mode 100644 index 2093105d8..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone/set.rs +++ /dev/null @@ -1,227 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines the attributes of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AvailabilityZone<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines the attributes of a PUT request. - #[builder(setter(into))] - pub(crate) availability_zone: AvailabilityZone<'a>, - - /// availabilityzone_id parameter for - /// /v2/lbaas/availabilityzones/{availabilityzone_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<'a> RequestBuilder<'a> { - /// Add a single header to the Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/availabilityzones/{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( - "availability_zone", - serde_json::to_value(&self.availability_zone)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "availability_zone" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/availabilityzones/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/availabilityzones/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/create.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/create.rs deleted file mode 100644 index 2142e06d4..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/create.rs +++ /dev/null @@ -1,254 +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`. - -//! Creates an Availability Zone Profile. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AvailabilityZoneProfile<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) availability_zone_data: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) provider_name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) availability_zone_profile: AvailabilityZoneProfile<'a>, - - #[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 Availability_Zone_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/availabilityzoneprofiles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "availability_zone_profile", - serde_json::to_value(&self.availability_zone_profile)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .availability_zone_profile( - AvailabilityZoneProfileBuilder::default() - .availability_zone_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .availability_zone_profile( - AvailabilityZoneProfileBuilder::default() - .availability_zone_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "availability_zone_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/availabilityzoneprofiles".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profile": {} })); - }); - - let endpoint = Request::builder() - .availability_zone_profile( - AvailabilityZoneProfileBuilder::default() - .availability_zone_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/availabilityzoneprofiles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profile": {} })); - }); - - let endpoint = Request::builder() - .availability_zone_profile( - AvailabilityZoneProfileBuilder::default() - .availability_zone_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/delete.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/delete.rs deleted file mode 100644 index b189723e0..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/delete.rs +++ /dev/null @@ -1,182 +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`. - -//! Deletes an Availability Zone Profile -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// availabilityzoneprofile_id parameter for - /// /v2/lbaas/availabilityzoneprofiles/{availabilityzoneprofile_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<'a> RequestBuilder<'a> { - /// Add a single header to the Availability_Zone_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/availabilityzoneprofiles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/availabilityzoneprofiles/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/availabilityzoneprofiles/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/find.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/find.rs deleted file mode 100644 index aeb02cc29..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::availability_zone_profile::{get as Get, list as List}; - -/// Find for availability_zone_profile 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/get.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/get.rs deleted file mode 100644 index 0383ace09..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/get.rs +++ /dev/null @@ -1,185 +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`. - -//! Gets an Availability Zone Profile's detail. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// availabilityzoneprofile_id parameter for - /// /v2/lbaas/availabilityzoneprofiles/{availabilityzoneprofile_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<'a> RequestBuilder<'a> { - /// Add a single header to the Availability_Zone_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/availabilityzoneprofiles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availability_zone_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profile": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/list.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/list.rs deleted file mode 100644 index 553a7c930..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/list.rs +++ /dev/null @@ -1,217 +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`. - -//! Lists all Availability Zone Profiles. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - availability_zone_data: Option>, - - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - name: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - #[builder(default, setter(into))] - provider_name: 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> { - /// Add a single header to the Availability_Zone_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/availabilityzoneprofiles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt( - "availability_zone_data", - self.availability_zone_data.as_ref(), - ); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("provider_name", self.provider_name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone_profiles".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availability_zone_profiles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/availabilityzoneprofiles".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profiles": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/availabilityzoneprofiles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profiles": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/set.rs b/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/set.rs deleted file mode 100644 index f49f76a8e..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile/set.rs +++ /dev/null @@ -1,237 +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`. - -//! Updates an Availability Zone Profile. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines the attributes of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AvailabilityZoneProfile<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone_data: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) provider_name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines the attributes of a PUT request. - #[builder(setter(into))] - pub(crate) availability_zone_profile: AvailabilityZoneProfile<'a>, - - /// availabilityzoneprofile_id parameter for - /// /v2/lbaas/availabilityzoneprofiles/{availabilityzoneprofile_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<'a> RequestBuilder<'a> { - /// Add a single header to the Availability_Zone_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/availabilityzoneprofiles/{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( - "availability_zone_profile", - serde_json::to_value(&self.availability_zone_profile)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .availability_zone_profile( - AvailabilityZoneProfileBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .availability_zone_profile( - AvailabilityZoneProfileBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "availability_zone_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .availability_zone_profile(AvailabilityZoneProfileBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_profile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .availability_zone_profile(AvailabilityZoneProfileBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor/create.rs b/openstack_sdk/src/api/load_balancer/v2/flavor/create.rs deleted file mode 100644 index 02f7ef079..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor/create.rs +++ /dev/null @@ -1,251 +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`. - -//! Creates a flavor. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) flavor_profile_id: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) flavor: Flavor<'a>, - - #[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 Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/flavors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("flavor", serde_json::to_value(&self.flavor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavor( - FlavorBuilder::default() - .flavor_profile_id("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavor( - FlavorBuilder::default() - .flavor_profile_id("foo") - .name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/flavors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor( - FlavorBuilder::default() - .flavor_profile_id("foo") - .name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/flavors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor( - FlavorBuilder::default() - .flavor_profile_id("foo") - .name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor/delete.rs b/openstack_sdk/src/api/load_balancer/v2/flavor/delete.rs deleted file mode 100644 index 69757bdc1..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Deletes a Flavor -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2/lbaas/flavors/{flavor_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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/flavors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/flavors/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/flavors/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor/find.rs b/openstack_sdk/src/api/load_balancer/v2/flavor/find.rs deleted file mode 100644 index 7257899b3..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::flavor::{get as Get, list as List}; - -/// Find for flavor 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor/get.rs b/openstack_sdk/src/api/load_balancer/v2/flavor/get.rs deleted file mode 100644 index b6221572b..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor/get.rs +++ /dev/null @@ -1,184 +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`. - -//! Gets a flavor's detail. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2/lbaas/flavors/{flavor_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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/flavors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/flavors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/flavors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor/list.rs b/openstack_sdk/src/api/load_balancer/v2/flavor/list.rs deleted file mode 100644 index 4d7a79965..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor/list.rs +++ /dev/null @@ -1,218 +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`. - -//! Lists all flavors. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - description: Option>, - - #[builder(default)] - enabled: Option, - - #[builder(default, setter(into))] - flavor_profile_id: Option>, - - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - name: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: 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> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/flavors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("description", self.description.as_ref()); - params.push_opt("enabled", self.enabled); - params.push_opt("flavor_profile_id", self.flavor_profile_id.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavors".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavors" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/flavors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/flavors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor/set.rs b/openstack_sdk/src/api/load_balancer/v2/flavor/set.rs deleted file mode 100644 index ce802c068..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor/set.rs +++ /dev/null @@ -1,227 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines the attributes of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines the attributes of a PUT request. - #[builder(setter(into))] - pub(crate) flavor: Flavor<'a>, - - /// flavor_id parameter for /v2/lbaas/flavors/{flavor_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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/flavors/{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("flavor", serde_json::to_value(&self.flavor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/flavors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/flavors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .flavor(FlavorBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/create.rs b/openstack_sdk/src/api/load_balancer/v2/flavor_profile/create.rs deleted file mode 100644 index c9c731dc2..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/create.rs +++ /dev/null @@ -1,251 +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`. - -//! Creates a flavor Profile. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavorprofile<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) flavor_data: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) provider_name: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) flavorprofile: Flavorprofile<'a>, - - #[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 Flavor_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/flavorprofiles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("flavorprofile", serde_json::to_value(&self.flavorprofile)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavorprofile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavorprofile( - FlavorprofileBuilder::default() - .flavor_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavorprofile( - FlavorprofileBuilder::default() - .flavor_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavorprofile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/flavorprofiles".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavorprofile": {} })); - }); - - let endpoint = Request::builder() - .flavorprofile( - FlavorprofileBuilder::default() - .flavor_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/flavorprofiles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavorprofile": {} })); - }); - - let endpoint = Request::builder() - .flavorprofile( - FlavorprofileBuilder::default() - .flavor_data("foo") - .name("foo") - .provider_name("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/delete.rs b/openstack_sdk/src/api/load_balancer/v2/flavor_profile/delete.rs deleted file mode 100644 index 809180067..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/delete.rs +++ /dev/null @@ -1,182 +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`. - -//! Deletes a Flavor Profile -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavorprofile_id parameter for - /// /v2/lbaas/flavorprofiles/{flavorprofile_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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/flavorprofiles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/flavorprofiles/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/flavorprofiles/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/find.rs b/openstack_sdk/src/api/load_balancer/v2/flavor_profile/find.rs deleted file mode 100644 index 243212157..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::flavor_profile::{get as Get, list as List}; - -/// Find for flavor_profile 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/get.rs b/openstack_sdk/src/api/load_balancer/v2/flavor_profile/get.rs deleted file mode 100644 index 3b2685102..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/get.rs +++ /dev/null @@ -1,185 +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`. - -//! Gets a flavor profile's detail. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavorprofile_id parameter for - /// /v2/lbaas/flavorprofiles/{flavorprofile_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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/flavorprofiles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavorprofile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavorprofile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavorprofile": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavorprofile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/list.rs b/openstack_sdk/src/api/load_balancer/v2/flavor_profile/list.rs deleted file mode 100644 index b5c32c628..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/list.rs +++ /dev/null @@ -1,211 +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`. - -//! Lists all flavor profiles. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - flavor_data: Option>, - - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - name: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - #[builder(default, setter(into))] - provider_name: 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> { - /// Add a single header to the Flavor_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/flavorprofiles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("flavor_data", self.flavor_data.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("provider_name", self.provider_name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/flavorprofiles".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/flavorprofiles".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/set.rs b/openstack_sdk/src/api/load_balancer/v2/flavor_profile/set.rs deleted file mode 100644 index 402de8b40..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/flavor_profile/set.rs +++ /dev/null @@ -1,230 +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`. - -//! Updates a flavor Profile. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines the attributes of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavorprofile<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) flavor_data: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) provider_name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines the attributes of a PUT request. - #[builder(setter(into))] - pub(crate) flavorprofile: Flavorprofile<'a>, - - /// flavorprofile_id parameter for - /// /v2/lbaas/flavorprofiles/{flavorprofile_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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/flavorprofiles/{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("flavorprofile", serde_json::to_value(&self.flavorprofile)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavorprofile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavorprofile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavorprofile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavorprofile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/create.rs b/openstack_sdk/src/api/load_balancer/v2/healthmonitor/create.rs deleted file mode 100644 index 567969f83..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/create.rs +++ /dev/null @@ -1,422 +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`. - -//! Creates a health monitor on a pool. -//! -//! Health monitors define how the load balancer monitors backend servers to -//! determine if they are available to service requests. -//! -//! This operation provisions a new health monitor by using the configuration -//! that you define in the request object. After the API validates the request -//! and starts the provisioning process, the API returns a response object that -//! contains a unique ID and the status of provisioning the health monitor. -//! -//! In the response, the health monitor [provisioning status](#prov-status) is -//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. -//! -//! If the status is `PENDING_CREATE`, issue GET -//! `/v2/lbaas/healthmonitors/{healthmonitor_id}` to view the progress of the -//! provisioning operation. When the health monitor status changes to `ACTIVE`, -//! the health monitor is successfully provisioned and is ready for further -//! configuration. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! Specifying a project_id is deprecated. The health monitor will inherit the -//! project_id of the parent load balancer. -//! -//! At a minimum, you must specify these health monitor attributes: -//! -//! Some attributes receive default values if you omit them from the request: -//! -//! To create a health monitor, the parent load balancer must have an `ACTIVE` -//! provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HttpMethod { - #[serde(rename = "CONNECT")] - Connect, - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "OPTIONS")] - Options, - #[serde(rename = "PATCH")] - Patch, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, - #[serde(rename = "TRACE")] - Trace, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PING")] - Ping, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TLS-HELLO")] - TlsHello, - #[serde(rename = "UDP-CONNECT")] - UdpConnect, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Healthmonitor<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// The time, in seconds, between sending probes to members. - #[serde()] - #[builder(setter(into))] - pub(crate) delay: i32, - - /// The domain name, which be injected into the HTTP Host Header to the - /// backend server for HTTP health check. - /// - /// **New in version 2.10** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - /// The list of HTTP status codes expected in response from the member to - /// declare it healthy. Specify one of the following values: - /// - /// - A single value, such as `200` - /// - A list, such as `200, 202` - /// - A range, such as `200-204` - /// - /// The default is 200. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - /// The HTTP method that the health monitor uses for requests. One of - /// `CONNECT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, `PATCH`, `POST`, `PUT`, - /// or `TRACE`. The default is `GET`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - /// The HTTP version. One of `1.0` or `1.1`. The default is `1.0`. - /// - /// **New in version 2.10** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - /// The number of successful checks before changing the `operating status` - /// of the member to `ONLINE`. A valid value is from `1` to `10`. - #[serde()] - #[builder(setter(into))] - pub(crate) max_retries: i32, - - /// The number of allowed check failures before changing the - /// `operating status` of the member to `ERROR`. A valid value is from `1` - /// to `10`. The default is `3`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the pool. - #[serde()] - #[builder(setter(into))] - pub(crate) pool_id: Cow<'a, str>, - - /// The ID of the project owning this resource. (deprecated) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The maximum time, in seconds, that a monitor waits to connect before it - /// times out. This value must be less than the delay value. - #[serde()] - #[builder(setter(into))] - pub(crate) timeout: i32, - - /// The type of health monitor. One of `HTTP`, `HTTPS`, `PING`, `SCTP`, - /// `TCP`, `TLS-HELLO`, or `UDP-CONNECT`. - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, - - /// The HTTP URL path of the request sent by the monitor to test the health - /// of a backend member. Must be a string that begins with a forward slash - /// (`/`). The default URL path is `/`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) healthmonitor: Healthmonitor<'a>, - - #[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 Healthmonitor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/healthmonitors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("healthmonitor", serde_json::to_value(&self.healthmonitor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("healthmonitor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .healthmonitor( - HealthmonitorBuilder::default() - ._type(Type::Http) - .delay(123) - .max_retries(123) - .pool_id("foo") - .timeout(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .healthmonitor( - HealthmonitorBuilder::default() - ._type(Type::Http) - .delay(123) - .max_retries(123) - .pool_id("foo") - .timeout(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "healthmonitor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/healthmonitors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitor": {} })); - }); - - let endpoint = Request::builder() - .healthmonitor( - HealthmonitorBuilder::default() - ._type(Type::Http) - .delay(123) - .max_retries(123) - .pool_id("foo") - .timeout(123) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/healthmonitors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitor": {} })); - }); - - let endpoint = Request::builder() - .healthmonitor( - HealthmonitorBuilder::default() - ._type(Type::Http) - .delay(123) - .max_retries(123) - .pool_id("foo") - .timeout(123) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/delete.rs b/openstack_sdk/src/api/load_balancer/v2/healthmonitor/delete.rs deleted file mode 100644 index 223c4462e..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Removes a health monitor and its associated configuration from the project. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// healthmonitor_id parameter for - /// /v2/lbaas/healthmonitors/{healthmonitor_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<'a> RequestBuilder<'a> { - /// Add a single header to the Healthmonitor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/healthmonitors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/healthmonitors/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/healthmonitors/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/find.rs b/openstack_sdk/src/api/load_balancer/v2/healthmonitor/find.rs deleted file mode 100644 index 3ff7ccbf2..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::healthmonitor::{get as Get, list as List}; - -/// Find for healthmonitor 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/get.rs b/openstack_sdk/src/api/load_balancer/v2/healthmonitor/get.rs deleted file mode 100644 index 6c421ef0b..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows the details of a health monitor. -//! -//! If you are not an administrative user and the parent load balancer does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// healthmonitor_id parameter for - /// /v2/lbaas/healthmonitors/{healthmonitor_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<'a> RequestBuilder<'a> { - /// Add a single header to the Healthmonitor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/healthmonitors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("healthmonitor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "healthmonitor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/healthmonitors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitor": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/healthmonitors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/list.rs b/openstack_sdk/src/api/load_balancer/v2/healthmonitor/list.rs deleted file mode 100644 index 99c3ec660..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/list.rs +++ /dev/null @@ -1,326 +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`. - -//! Lists all health monitors for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list health monitors for other projects. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The type of health monitor. - #[builder(default, setter(into))] - _type: Option>, - - /// The administrative state of the resource - #[builder(default)] - admin_state_up: Option, - - /// The UTC date and timestamp when the resource was created. - #[builder(default, setter(into))] - created_at: Option>, - - /// The time, in seconds, between sending probes to members. - #[builder(default)] - delay: Option, - - /// A human-readable description for the resource. - #[builder(default, setter(into))] - description: Option>, - - /// The list of HTTP status codes expected in response from the member to - /// declare it healthy. - #[builder(default, setter(into))] - expected_codes: Option>, - - /// The HTTP method that the health monitor uses for requests. - #[builder(default, setter(into))] - http_method: Option>, - - /// The ID of the resource - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - /// The number of successful checks before changing the operating status of - /// the member to ONLINE. A valid value is from 1 to 10. - #[builder(default)] - max_retries: Option, - - /// The number of allowed check failures before changing the operating - /// status of the member to ERROR. A valid value is from 1 to 10. - #[builder(default)] - max_retries_down: Option, - - /// Human-readable name of the resource. - #[builder(default, setter(into))] - name: Option>, - - /// Return the list of entities that do not have one or more of the given - /// tags. - #[builder(default, setter(into))] - not_tags: Option>, - - /// Return the list of entities that do not have at least one of the given - /// tags. - #[builder(default, setter(into))] - not_tags_any: Option>, - - /// The operating status of the resource. - #[builder(default, setter(into))] - operating_status: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - /// The ID of the pool. - #[builder(default, setter(into))] - pool_id: Option>, - - /// The ID of the project owning this resource. - #[builder(default, setter(into))] - project_id: Option>, - - /// The provisioning status of the resource. - #[builder(default, setter(into))] - provisioning_status: Option>, - - /// Return the list of entities that have this tag or tags. - #[builder(default, setter(into))] - tags: Option>, - - /// Return the list of entities that have one or more of the given tags. - #[builder(default, setter(into))] - tags_any: Option>, - - /// The maximum time, in seconds, that a monitor waits to connect before it - /// times out. - #[builder(default)] - timeout: Option, - - /// The UTC date and timestamp when the resource was last updated. - #[builder(default, setter(into))] - updated_at: Option>, - - /// The HTTP URL path of the request sent by the monitor to test the health - /// of a backend member. Must be a string that begins with a forward slash - /// (/). - #[builder(default, setter(into))] - url_path: 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> { - /// Add a single header to the Healthmonitor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/healthmonitors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("delay", self.delay); - params.push_opt("description", self.description.as_ref()); - params.push_opt("expected_codes", self.expected_codes.as_ref()); - params.push_opt("http_method", self.http_method.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("max_retries", self.max_retries); - params.push_opt("max_retries_down", self.max_retries_down); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("operating_status", self.operating_status.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("pool_id", self.pool_id.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("provisioning_status", self.provisioning_status.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("timeout", self.timeout); - params.push_opt("type", self._type.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - params.push_opt("url_path", self.url_path.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("healthmonitors".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "healthmonitors" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/healthmonitors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitors": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/healthmonitors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitors": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/set.rs b/openstack_sdk/src/api/load_balancer/v2/healthmonitor/set.rs deleted file mode 100644 index 30939757b..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/healthmonitor/set.rs +++ /dev/null @@ -1,331 +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`. - -//! Update an existing health monitor. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the update, check that the health monitor provisioning -//! status is `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation -//! to poll the health monitor object for changes. -//! -//! This operation returns the updated health monitor object with the `ACTIVE`, -//! `PENDING_UPDATE`, or `ERROR` provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HttpMethod { - #[serde(rename = "CONNECT")] - Connect, - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "OPTIONS")] - Options, - #[serde(rename = "PATCH")] - Patch, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, - #[serde(rename = "TRACE")] - Trace, -} - -/// Defines attributes that are acceptable of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Healthmonitor<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// The time, in seconds, between sending probes to members. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) delay: Option, - - /// The domain name, which be injected into the HTTP Host Header to the - /// backend server for HTTP health check. - /// - /// **New in version 2.10** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - /// The list of HTTP status codes expected in response from the member to - /// declare it healthy. Specify one of the following values: - /// - /// - A single value, such as `200` - /// - A list, such as `200, 202` - /// - A range, such as `200-204` - /// - /// The default is 200. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - /// The HTTP method that the health monitor uses for requests. One of - /// `CONNECT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, `PATCH`, `POST`, `PUT`, - /// or `TRACE`. The default is `GET`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - /// The HTTP version. One of `1.0` or `1.1`. The default is `1.0`. - /// - /// **New in version 2.10** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - /// The number of successful checks before changing the `operating status` - /// of the member to `ONLINE`. A valid value is from `1` to `10`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries: Option, - - /// The number of allowed check failures before changing the - /// `operating status` of the member to `ERROR`. A valid value is from `1` - /// to `10`. The default is `3`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// The maximum time, in seconds, that a monitor waits to connect before it - /// times out. This value must be less than the delay value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout: Option, - - /// The HTTP URL path of the request sent by the monitor to test the health - /// of a backend member. Must be a string that begins with a forward slash - /// (`/`). The default URL path is `/`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines attributes that are acceptable of a PUT request. - #[builder(setter(into))] - pub(crate) healthmonitor: Healthmonitor<'a>, - - /// healthmonitor_id parameter for - /// /v2/lbaas/healthmonitors/{healthmonitor_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<'a> RequestBuilder<'a> { - /// Add a single header to the Healthmonitor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/healthmonitors/{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("healthmonitor", serde_json::to_value(&self.healthmonitor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("healthmonitor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "healthmonitor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/healthmonitors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/healthmonitors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "healthmonitor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/create.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/create.rs deleted file mode 100644 index c56dbb0ae..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/create.rs +++ /dev/null @@ -1,432 +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`. - -//! Creates a L7 policy. -//! -//! This operation provisions a new L7 policy by using the configuration that -//! you define in the request object. After the API validates the request and -//! starts the provisioning process, the API returns a response object that -//! contains a unique ID and the status of provisioning the L7 policy. -//! -//! In the response, the L7 policy [provisioning status](#prov-status) is -//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. -//! -//! If the status is `PENDING_CREATE`, issue GET -//! `/v2/lbaas/l7policies/{l7policy_id}` to view the progress of the -//! provisioning operation. When the L7 policy status changes to `ACTIVE`, the -//! L7 policy is successfully provisioned and is ready for further -//! configuration. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! All the rules associated with a given policy are logically ANDead together. -//! A request must match all the policy’s rules to match the policy. -//! -//! If you need to express a logical OR operation between rules, then do this -//! by creating multiple policies with the same action. -//! -//! If a new policy is created with a position that matches that of an existing -//! policy, then the new policy is inserted at the given position. -//! -//! L7 policies with `action` of `REDIRECT_TO_URL` will return the default HTTP -//! `Found (302)` response code with the `redirect_url`. Also, specify -//! `redirect_http_code` to configure the needed HTTP response code, such as, -//! 301, 302, 303, 307 and 308. -//! -//! L7 policies with `action` of `REJECT` will return a `Forbidden (403)` -//! response code to the requester. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Action { - #[serde(rename = "REDIRECT_PREFIX")] - RedirectPrefix, - #[serde(rename = "REDIRECT_TO_POOL")] - RedirectToPool, - #[serde(rename = "REDIRECT_TO_URL")] - RedirectToUrl, - #[serde(rename = "REJECT")] - Reject, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum CompareType { - #[serde(rename = "CONTAINS")] - Contains, - #[serde(rename = "ENDS_WITH")] - EndsWith, - #[serde(rename = "EQUAL_TO")] - EqualTo, - #[serde(rename = "REGEX")] - Regex, - #[serde(rename = "STARTS_WITH")] - StartsWith, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "COOKIE")] - Cookie, - #[serde(rename = "FILE_TYPE")] - FileType, - #[serde(rename = "HEADER")] - Header, - #[serde(rename = "HOST_NAME")] - HostName, - #[serde(rename = "PATH")] - Path, - #[serde(rename = "SSL_CONN_HAS_CERT")] - SslConnHasCert, - #[serde(rename = "SSL_DN_FIELD")] - SslDnField, - #[serde(rename = "SSL_VERIFY_RESULT")] - SslVerifyResult, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Rules<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder()] - pub(crate) compare_type: CompareType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) invert: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, - - #[serde()] - #[builder(setter(into))] - pub(crate) value: Cow<'a, str>, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct L7policy<'a> { - /// The L7 policy action. One of `REDIRECT_PREFIX`, `REDIRECT_TO_POOL`, - /// `REDIRECT_TO_URL`, or `REJECT`. - #[serde()] - #[builder()] - pub(crate) action: Action, - - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The ID of the listener. - #[serde()] - #[builder(setter(into))] - pub(crate) listener_id: Cow<'a, str>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The position of this policy on the listener. Positions start at 1. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) position: Option, - - /// The ID of the project owning this resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// Requests matching this policy will be redirected to the specified URL - /// or Prefix URL with the HTTP response code. Valid if `action` is - /// `REDIRECT_TO_URL` or `REDIRECT_PREFIX`. Valid options are: 301, 302, - /// 303, 307, or 308. Default is 302. - /// - /// **New in version 2.9** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_http_code: Option, - - /// Requests matching this policy will be redirected to the pool with this - /// ID. Only valid if `action` is `REDIRECT_TO_POOL`. The pool has some - /// restrictions, See - /// [Protocol Combinations (Listener/Pool)](#valid-protocol). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_pool_id: Option>, - - /// Requests matching this policy will be redirected to this Prefix URL. - /// Only valid if `action` is `REDIRECT_PREFIX`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_prefix: Option>, - - /// Requests matching this policy will be redirected to this URL. Only - /// valid if `action` is `REDIRECT_TO_URL`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_url: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) rules: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) l7policy: L7policy<'a>, - - #[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 L7Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/l7policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("l7policy", serde_json::to_value(&self.l7policy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("l7policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .l7policy( - L7policyBuilder::default() - .action(Action::RedirectPrefix) - .listener_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .l7policy( - L7policyBuilder::default() - .action(Action::RedirectPrefix) - .listener_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "l7policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/l7policies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policy": {} })); - }); - - let endpoint = Request::builder() - .l7policy( - L7policyBuilder::default() - .action(Action::RedirectPrefix) - .listener_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/l7policies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policy": {} })); - }); - - let endpoint = Request::builder() - .l7policy( - L7policyBuilder::default() - .action(Action::RedirectPrefix) - .listener_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/delete.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/delete.rs deleted file mode 100644 index 7f54d921a..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Removes a L7 policy and its associated configuration from the project. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// l7policy_id parameter for /v2/lbaas/l7policies/{l7policy_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<'a> RequestBuilder<'a> { - /// Add a single header to the L7Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/l7policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/l7policies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/l7policies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/find.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/find.rs deleted file mode 100644 index 62735b558..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::l7policy::{get as Get, list as List}; - -/// Find for l7policy 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/get.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/get.rs deleted file mode 100644 index e78c643f3..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/get.rs +++ /dev/null @@ -1,190 +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`. - -//! Shows the details of a L7 policy. -//! -//! If you are not an administrative user and the L7 policy object does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// l7policy_id parameter for /v2/lbaas/l7policies/{l7policy_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<'a> RequestBuilder<'a> { - /// Add a single header to the L7Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/l7policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("l7policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "l7policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/l7policies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policy": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/l7policies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/list.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/list.rs deleted file mode 100644 index fff5c0693..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/list.rs +++ /dev/null @@ -1,256 +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`. - -//! Lists all L7 policies for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list L7 policies for other projects. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - action: Option>, - - #[builder(default)] - admin_state_up: Option, - - #[builder(default, setter(into))] - description: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - #[builder(default, setter(into))] - listener_id: Option>, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - name: Option>, - - #[builder(default, setter(into))] - operating_status: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - #[builder(default, setter(into))] - position: Option>, - - #[builder(default, setter(into))] - project_id: Option>, - - #[builder(default, setter(into))] - provisioning_status: Option>, - - #[builder(default, setter(into))] - redirect_pool_id: Option>, - - #[builder(default, setter(into))] - redirect_prefix: Option>, - - #[builder(default, setter(into))] - redirect_url: 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> { - /// Add a single header to the L7Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/l7policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("action", self.action.as_ref()); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("description", self.description.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("listener_id", self.listener_id.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("operating_status", self.operating_status.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("position", self.position.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("provisioning_status", self.provisioning_status.as_ref()); - params.push_opt("redirect_pool_id", self.redirect_pool_id.as_ref()); - params.push_opt("redirect_prefix", self.redirect_prefix.as_ref()); - params.push_opt("redirect_url", self.redirect_url.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("l7policies".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "l7policies" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/l7policies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policies": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/l7policies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policies": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/create.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/create.rs deleted file mode 100644 index 340989671..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/create.rs +++ /dev/null @@ -1,366 +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`. - -//! Creates a L7 rule. -//! -//! This operation provisions a new L7 rule by using the configuration that you -//! define in the request object. After the API validates the request and -//! starts the provisioning process, the API returns a response object that -//! contains a unique ID and the status of provisioning the L7 rule. -//! -//! In the response, the L7 rule [provisioning status](#prov-status) is -//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. -//! -//! If the status is `PENDING_CREATE`, issue GET -//! `/v2/lbaas/l7policies/{l7policy_id}/rules/{l7rule_id}` to view the progress -//! of the provisioning operation. When the L7 rule status changes to `ACTIVE`, -//! the L7 rule is successfully provisioned and is ready for further -//! configuration. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! All the rules associated with a given policy are logically ANDead together. -//! A request must match all the policy’s rules to match the policy. -//! -//! If you need to express a logical OR operation between rules, then do this -//! by creating multiple policies with the same action. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum CompareType { - #[serde(rename = "CONTAINS")] - Contains, - #[serde(rename = "ENDS_WITH")] - EndsWith, - #[serde(rename = "EQUAL_TO")] - EqualTo, - #[serde(rename = "REGEX")] - Regex, - #[serde(rename = "STARTS_WITH")] - StartsWith, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "COOKIE")] - Cookie, - #[serde(rename = "FILE_TYPE")] - FileType, - #[serde(rename = "HEADER")] - Header, - #[serde(rename = "HOST_NAME")] - HostName, - #[serde(rename = "PATH")] - Path, - #[serde(rename = "SSL_CONN_HAS_CERT")] - SslConnHasCert, - #[serde(rename = "SSL_DN_FIELD")] - SslDnField, - #[serde(rename = "SSL_VERIFY_RESULT")] - SslVerifyResult, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Rule<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// The comparison type for the L7 rule. One of `CONTAINS`, `ENDS_WITH`, - /// `EQUAL_TO`, `REGEX`, or `STARTS_WITH`. - #[serde()] - #[builder()] - pub(crate) compare_type: CompareType, - - /// When `true` the logic of the rule is inverted. For example, with invert - /// `true`, equal to would become not equal to. Default is `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) invert: Option, - - /// The key to use for the comparison. For example, the name of the cookie - /// to evaluate. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key: Option>, - - /// The ID of the project owning this resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The L7 rule type. One of `COOKIE`, `FILE_TYPE`, `HEADER`, `HOST_NAME`, - /// `PATH`, `SSL_CONN_HAS_CERT`, `SSL_VERIFY_RESULT`, or `SSL_DN_FIELD`. - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: Type, - - /// The value to use for the comparison. For example, the file type to - /// compare. - #[serde()] - #[builder(setter(into))] - pub(crate) value: Cow<'a, str>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) rule: Rule<'a>, - - /// l7policy_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - l7policy_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 Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "lbaas/l7policies/{l7policy_id}/rules", - l7policy_id = self.l7policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("rule", serde_json::to_value(&self.rule)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .rule( - RuleBuilder::default() - ._type(Type::Cookie) - .compare_type(CompareType::Contains) - .value("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .rule( - RuleBuilder::default() - ._type(Type::Cookie) - .compare_type(CompareType::Contains) - .value("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/lbaas/l7policies/{l7policy_id}/rules", - l7policy_id = "l7policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .rule( - RuleBuilder::default() - ._type(Type::Cookie) - .compare_type(CompareType::Contains) - .value("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/lbaas/l7policies/{l7policy_id}/rules", - l7policy_id = "l7policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .rule( - RuleBuilder::default() - ._type(Type::Cookie) - .compare_type(CompareType::Contains) - .value("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/delete.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/delete.rs deleted file mode 100644 index 9ed04e8c1..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Removes a L7 rule and its associated configuration from the project. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// rule_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// l7policy_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - l7policy_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 Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = self.l7policy_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = "l7policy_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = "l7policy_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() - .l7policy_id("l7policy_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/get.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/get.rs deleted file mode 100644 index 7b45592ae..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/get.rs +++ /dev/null @@ -1,213 +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`. - -//! Shows the details of a L7 rule. -//! -//! If you are not an administrative user and the L7 rule object does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// rule_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// l7policy_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - l7policy_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 Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = self.l7policy_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = "l7policy_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = "l7policy_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/list.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/list.rs deleted file mode 100644 index 276d6edc1..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/list.rs +++ /dev/null @@ -1,270 +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`. - -//! Lists all L7 rules for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list L7 policies for other projects. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - _type: Option>, - - #[builder(default)] - admin_state_up: Option, - - #[builder(default, setter(into))] - compare_type: Option>, - - #[builder(default, setter(into))] - created_at: Option>, - - #[builder(default, setter(into))] - invert: Option>, - - #[builder(default, setter(into))] - key: Option>, - - /// l7policy_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - l7policy_id: Cow<'a, str>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - operating_status: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - #[builder(default, setter(into))] - project_id: Option>, - - #[builder(default, setter(into))] - provisioning_status: Option>, - - #[builder(default, setter(into))] - rule_value: Option>, - - #[builder(default, setter(into))] - 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<'a> RequestBuilder<'a> { - /// Add a single header to the Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/l7policies/{l7policy_id}/rules", - l7policy_id = self.l7policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("compare_type", self.compare_type.as_ref()); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("invert", self.invert.as_ref()); - params.push_opt("key", self.key.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("operating_status", self.operating_status.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("provisioning_status", self.provisioning_status.as_ref()); - params.push_opt("rule_value", self.rule_value.as_ref()); - params.push_opt("type", self._type.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/lbaas/l7policies/{l7policy_id}/rules", - l7policy_id = "l7policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rules": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/lbaas/l7policies/{l7policy_id}/rules", - l7policy_id = "l7policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rules": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/set.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/set.rs deleted file mode 100644 index 31b2eb561..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule/set.rs +++ /dev/null @@ -1,322 +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`. - -//! Updates a L7 rule. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the update, check that the L7 rule provisioning status is -//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll -//! the L7 rule object for changes. -//! -//! This operation returns the updated L7 rule object with the `ACTIVE`, -//! `PENDING_UPDATE`, or `ERROR` provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum CompareType { - #[serde(rename = "CONTAINS")] - Contains, - #[serde(rename = "ENDS_WITH")] - EndsWith, - #[serde(rename = "EQUAL_TO")] - EqualTo, - #[serde(rename = "REGEX")] - Regex, - #[serde(rename = "STARTS_WITH")] - StartsWith, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "COOKIE")] - Cookie, - #[serde(rename = "FILE_TYPE")] - FileType, - #[serde(rename = "HEADER")] - Header, - #[serde(rename = "HOST_NAME")] - HostName, - #[serde(rename = "PATH")] - Path, - #[serde(rename = "SSL_CONN_HAS_CERT")] - SslConnHasCert, - #[serde(rename = "SSL_DN_FIELD")] - SslDnField, - #[serde(rename = "SSL_VERIFY_RESULT")] - SslVerifyResult, -} - -/// Defines attributes that are acceptable of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Rule<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// The comparison type for the L7 rule. One of `CONTAINS`, `ENDS_WITH`, - /// `EQUAL_TO`, `REGEX`, or `STARTS_WITH`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) compare_type: Option, - - /// When `true` the logic of the rule is inverted. For example, with invert - /// `true`, equal to would become not equal to. Default is `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) invert: Option, - - /// The key to use for the comparison. For example, the name of the cookie - /// to evaluate. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// The L7 rule type. One of `COOKIE`, `FILE_TYPE`, `HEADER`, `HOST_NAME`, - /// `PATH`, `SSL_CONN_HAS_CERT`, `SSL_VERIFY_RESULT`, or `SSL_DN_FIELD`. - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, - - /// The value to use for the comparison. For example, the file type to - /// compare. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) value: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines attributes that are acceptable of a PUT request. - #[builder(setter(into))] - pub(crate) rule: Rule<'a>, - - /// rule_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// l7policy_id parameter for - /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API - #[builder(default, setter(into))] - l7policy_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 Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = self.l7policy_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("rule", serde_json::to_value(&self.rule)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .rule(RuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .rule(RuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = "l7policy_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .id("id") - .rule(RuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/lbaas/l7policies/{l7policy_id}/rules/{id}", - l7policy_id = "l7policy_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule": {} })); - }); - - let endpoint = Request::builder() - .l7policy_id("l7policy_id") - .id("id") - .rule(RuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/set.rs b/openstack_sdk/src/api/load_balancer/v2/l7policy/set.rs deleted file mode 100644 index f83033351..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/l7policy/set.rs +++ /dev/null @@ -1,304 +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`. - -//! Updates a L7 policy. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the update, check that the L7 policy provisioning status -//! is `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll -//! the L7 policy object for changes. -//! -//! This operation returns the updated L7 policy object with the `ACTIVE`, -//! `PENDING_UPDATE`, or `ERROR` provisioning status. -//! -//! If a policy is updated with a position that matches that of an existing -//! policy, then the updated policy is inserted at the given position. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Action { - #[serde(rename = "REDIRECT_PREFIX")] - RedirectPrefix, - #[serde(rename = "REDIRECT_TO_POOL")] - RedirectToPool, - #[serde(rename = "REDIRECT_TO_URL")] - RedirectToUrl, - #[serde(rename = "REJECT")] - Reject, -} - -/// Defines attributes that are acceptable of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct L7policy<'a> { - /// The L7 policy action. One of `REDIRECT_PREFIX`, `REDIRECT_TO_POOL`, - /// `REDIRECT_TO_URL`, or `REJECT`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) action: Option, - - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The position of this policy on the listener. Positions start at 1. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) position: Option, - - /// Requests matching this policy will be redirected to the specified URL - /// or Prefix URL with the HTTP response code. Valid if `action` is - /// `REDIRECT_TO_URL` or `REDIRECT_PREFIX`. Valid options are: 301, 302, - /// 303, 307, or 308. Default is 302. - /// - /// **New in version 2.9** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_http_code: Option, - - /// Requests matching this policy will be redirected to the pool with this - /// ID. Only valid if `action` is `REDIRECT_TO_POOL`. The pool has some - /// restrictions, See - /// [Protocol Combinations (Listener/Pool)](#valid-protocol). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_pool_id: Option>, - - /// Requests matching this policy will be redirected to this Prefix URL. - /// Only valid if `action` is `REDIRECT_PREFIX`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_prefix: Option>, - - /// Requests matching this policy will be redirected to this URL. Only - /// valid if `action` is `REDIRECT_TO_URL`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_url: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines attributes that are acceptable of a PUT request. - #[builder(setter(into))] - pub(crate) l7policy: L7policy<'a>, - - /// l7policy_id parameter for /v2/lbaas/l7policies/{l7policy_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<'a> RequestBuilder<'a> { - /// Add a single header to the L7Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/l7policies/{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("l7policy", serde_json::to_value(&self.l7policy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("l7policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .l7policy(L7policyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .l7policy(L7policyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "l7policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/l7policies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .l7policy(L7policyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/l7policies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "l7policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .l7policy(L7policyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener/create.rs b/openstack_sdk/src/api/load_balancer/v2/listener/create.rs deleted file mode 100644 index ed4bff613..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/listener/create.rs +++ /dev/null @@ -1,1115 +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`. - -//! Creates a listener for a load balancer. -//! -//! The listener configures a port and protocol for the load balancer to listen -//! on for incoming requests. A load balancer may have zero or more listeners -//! configured. -//! -//! This operation provisions a new listener by using the configuration that -//! you define in the request object. After the API validates the request and -//! starts the provisioning process, the API returns a response object that -//! contains a unique ID and the status of provisioning the listener. -//! -//! In the response, the listener [provisioning status](#prov-status) is -//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. -//! -//! If the status is `PENDING_CREATE`, issue GET -//! `/v2/lbaas/listeners/{listener_id}` to view the progress of the -//! provisioning operation. When the listener status changes to `ACTIVE`, the -//! listener is successfully provisioned and is ready for further -//! configuration. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! Specifying a project_id is deprecated. The listener will inherit the -//! project_id of the parent load balancer. -//! -//! You can configure all documented features of the listener at creation time -//! by specifying the additional elements or attributes in the request. -//! -//! To create a listener, the parent load balancer must have an `ACTIVE` -//! provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 ClientAuthentication { - #[serde(rename = "MANDATORY")] - Mandatory, - #[serde(rename = "NONE")] - None, - #[serde(rename = "OPTIONAL")] - Optional, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HttpMethod { - #[serde(rename = "CONNECT")] - Connect, - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "OPTIONS")] - Options, - #[serde(rename = "PATCH")] - Patch, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, - #[serde(rename = "TRACE")] - Trace, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HealthmonitorType { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PING")] - Ping, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TLS-HELLO")] - TlsHello, - #[serde(rename = "UDP-CONNECT")] - UdpConnect, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Healthmonitor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) delay: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) max_retries: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) timeout: i32, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: HealthmonitorType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum LbAlgorithm { - #[serde(rename = "LEAST_CONNECTIONS")] - LeastConnections, - #[serde(rename = "ROUND_ROBIN")] - RoundRobin, - #[serde(rename = "SOURCE_IP")] - SourceIp, - #[serde(rename = "SOURCE_IP_PORT")] - SourceIpPort, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Members<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) address: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) backup: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_address: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_port: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_port: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) request_sriov: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) weight: Option, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum DefaultPoolProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROXY")] - Proxy, - #[serde(rename = "PROXYV2")] - Proxyv2, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "UDP")] - Udp, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum SessionPersistenceType { - #[serde(rename = "APP_COOKIE")] - AppCookie, - #[serde(rename = "HTTP_COOKIE")] - HttpCookie, - #[serde(rename = "SOURCE_IP")] - SourceIp, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SessionPersistence<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cookie_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_granularity: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_timeout: Option, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: SessionPersistenceType, -} - -/// A pool object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct DefaultPool<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 - /// - /// **New in version 2.20** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ca_tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) crl_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) healthmonitor: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) lb_algorithm: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) members: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) session_persistence: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// List of ciphers in OpenSSL format (colon-separated). See - /// - /// - /// **New in version 2.15** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_enabled: Option, - - /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, - /// TLSv1.1, TLSv1.2, TLSv1.3 - /// - /// **New in version 2.17** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Action { - #[serde(rename = "REDIRECT_PREFIX")] - RedirectPrefix, - #[serde(rename = "REDIRECT_TO_POOL")] - RedirectToPool, - #[serde(rename = "REDIRECT_TO_URL")] - RedirectToUrl, - #[serde(rename = "REJECT")] - Reject, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum RedirectPoolHealthmonitorType { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PING")] - Ping, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TLS-HELLO")] - TlsHello, - #[serde(rename = "UDP-CONNECT")] - UdpConnect, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RedirectPoolHealthmonitor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) delay: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) max_retries: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) timeout: i32, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: RedirectPoolHealthmonitorType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum RedirectPoolProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROXY")] - Proxy, - #[serde(rename = "PROXYV2")] - Proxyv2, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "UDP")] - Udp, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "APP_COOKIE")] - AppCookie, - #[serde(rename = "HTTP_COOKIE")] - HttpCookie, - #[serde(rename = "SOURCE_IP")] - SourceIp, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RedirectPool<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ca_tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) crl_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) healthmonitor: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) lb_algorithm: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) members: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) session_persistence: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_enabled: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum CompareType { - #[serde(rename = "CONTAINS")] - Contains, - #[serde(rename = "ENDS_WITH")] - EndsWith, - #[serde(rename = "EQUAL_TO")] - EqualTo, - #[serde(rename = "REGEX")] - Regex, - #[serde(rename = "STARTS_WITH")] - StartsWith, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum RulesType { - #[serde(rename = "COOKIE")] - Cookie, - #[serde(rename = "FILE_TYPE")] - FileType, - #[serde(rename = "HEADER")] - Header, - #[serde(rename = "HOST_NAME")] - HostName, - #[serde(rename = "PATH")] - Path, - #[serde(rename = "SSL_CONN_HAS_CERT")] - SslConnHasCert, - #[serde(rename = "SSL_DN_FIELD")] - SslDnField, - #[serde(rename = "SSL_VERIFY_RESULT")] - SslVerifyResult, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Rules<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder()] - pub(crate) compare_type: CompareType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) invert: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: RulesType, - - #[serde()] - #[builder(setter(into))] - pub(crate) value: Cow<'a, str>, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct L7policies<'a> { - #[serde()] - #[builder()] - pub(crate) action: Action, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) position: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_http_code: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_pool: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_url: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) rules: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum ListenerProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROMETHEUS")] - Prometheus, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TERMINATED_HTTPS")] - TerminatedHttps, - #[serde(rename = "UDP")] - Udp, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Listener<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A list of IPv4, IPv6 or mix of both CIDRs. The default is all allowed. - /// When a list of CIDRs is provided, the default switches to deny all. - /// - /// **New in version 2.12** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allowed_cidrs: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - /// The TLS client authentication mode. One of the options `NONE`, - /// `OPTIONAL` or `MANDATORY`. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) client_authentication: Option, - - /// The ref of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format client CA certificate bundle for - /// `TERMINATED_HTTPS` listeners. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) client_ca_tls_container_ref: Option>, - - /// The URI of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format CA revocation list file for - /// `TERMINATED_HTTPS` listeners. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) client_crl_container_ref: Option>, - - /// The maximum number of connections permitted for this listener. Default - /// value is -1 which represents infinite connections or a default value - /// defined by the provider driver. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) connection_limit: Option, - - /// A pool object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_pool: Option>, - - /// The ID of the pool used by the listener if no L7 policies match. The - /// pool has some restrictions. See - /// [Protocol Combinations (Listener/Pool)](#valid-protocol). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_pool_id: Option>, - - /// The URI of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PKCS12 format certificate/key bundle for - /// `TERMINATED_HTTPS` listeners. DEPRECATED: A secret container of type - /// “certificate” containing the certificate and key for `TERMINATED_HTTPS` - /// listeners. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_tls_container_ref: Option>, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines whether the `includeSubDomains` directive should be added to - /// the Strict-Transport-Security HTTP response header. This requires - /// setting the `hsts_max_age` option as well in order to become effective. - /// - /// **New in version 2.27** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_include_subdomains: Option, - - /// The value of the `max_age` directive for the Strict-Transport-Security - /// HTTP response header. Setting this enables HTTP Strict Transport - /// Security (HSTS) for the TLS-terminated listener. - /// - /// **New in version 2.27** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_max_age: Option, - - /// Defines whether the `preload` directive should be added to the - /// Strict-Transport-Security HTTP response header. This requires setting - /// the `hsts_max_age` option as well in order to become effective. - /// - /// **New in version 2.27** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_preload: Option, - - /// A dictionary of optional headers to insert into the request before it - /// is sent to the backend `member`. See - /// [Supported HTTP Header Insertions](#header-insertions). Both keys and - /// values are always specified as strings. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_insert_headers"))] - pub(crate) insert_headers: Option, Cow<'a, str>>>, - - /// A list of L7 policy objects. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) l7policies: Option>>, - - /// The ID of the load balancer. - #[serde()] - #[builder(setter(into))] - pub(crate) loadbalancer_id: Cow<'a, str>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the project owning this resource. (deprecated) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The protocol for the resource. One of `HTTP`, `HTTPS`, `SCTP`, - /// `PROMETHEUS`, `TCP`, `TERMINATED_HTTPS`, or `UDP`. - #[serde()] - #[builder()] - pub(crate) protocol: ListenerProtocol, - - /// The protocol port number for the resource. - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_port: i32, - - /// A list of URIs to the - /// [key manager service](https://docs.openstack.org/barbican/latest/) - /// secrets containing PKCS12 format certificate/key bundles for - /// `TERMINATED_HTTPS` listeners. (DEPRECATED) Secret containers of type - /// “certificate” containing the certificates and keys for - /// `TERMINATED_HTTPS` listeners. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) sni_container_refs: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// Frontend client inactivity timeout in milliseconds. Default: 50000. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_client_data: Option, - - /// Backend member connection timeout in milliseconds. Default: 5000. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_member_connect: Option, - - /// Backend member inactivity timeout in milliseconds. Default: 50000. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_member_data: Option, - - /// Time, in milliseconds, to wait for additional TCP packets for content - /// inspection. Default: 0. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_tcp_inspect: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -impl<'a> ListenerBuilder<'a> { - /// A dictionary of optional headers to insert into the request before it - /// is sent to the backend `member`. See - /// [Supported HTTP Header Insertions](#header-insertions). Both keys and - /// values are always specified as strings. - pub fn insert_headers(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.insert_headers - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) listener: Listener<'a>, - - #[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 Listener. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/listeners".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("listener", serde_json::to_value(&self.listener)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("listener".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .listener( - ListenerBuilder::default() - .loadbalancer_id("foo") - .protocol(ListenerProtocol::Http) - .protocol_port(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .listener( - ListenerBuilder::default() - .loadbalancer_id("foo") - .protocol(ListenerProtocol::Http) - .protocol_port(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "listener" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/listeners".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listener": {} })); - }); - - let endpoint = Request::builder() - .listener( - ListenerBuilder::default() - .loadbalancer_id("foo") - .protocol(ListenerProtocol::Http) - .protocol_port(123) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/listeners".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listener": {} })); - }); - - let endpoint = Request::builder() - .listener( - ListenerBuilder::default() - .loadbalancer_id("foo") - .protocol(ListenerProtocol::Http) - .protocol_port(123) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener/delete.rs b/openstack_sdk/src/api/load_balancer/v2/listener/delete.rs deleted file mode 100644 index 528903cc0..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/listener/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Removes a listener and its associated configuration from the project. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// listener_id parameter for /v2/lbaas/listeners/{listener_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<'a> RequestBuilder<'a> { - /// Add a single header to the Listener. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/listeners/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/listeners/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/listeners/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener/find.rs b/openstack_sdk/src/api/load_balancer/v2/listener/find.rs deleted file mode 100644 index 5c8247873..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/listener/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::listener::{get as Get, list as List}; - -/// Find for listener 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener/get.rs b/openstack_sdk/src/api/load_balancer/v2/listener/get.rs deleted file mode 100644 index e0df657e5..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/listener/get.rs +++ /dev/null @@ -1,190 +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`. - -//! Shows the details of a listener. -//! -//! If you are not an administrative user and the parent load balancer does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// listener_id parameter for /v2/lbaas/listeners/{listener_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<'a> RequestBuilder<'a> { - /// Add a single header to the Listener. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/listeners/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("listener".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "listener" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/listeners/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listener": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/listeners/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listener": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener/list.rs b/openstack_sdk/src/api/load_balancer/v2/listener/list.rs deleted file mode 100644 index 913c61fb9..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/listener/list.rs +++ /dev/null @@ -1,356 +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`. - -//! Lists all listeners for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list listeners for other projects. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The administrative state of the resource - #[builder(default)] - admin_state_up: Option, - - /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 - #[builder(default, setter(into))] - alpn_protocols: Option>, - - /// The maximum number of connections permitted for this listener. Default - /// value is -1 which represents infinite connections or a default value - /// defined by the provider driver. - #[builder(default, setter(into))] - connection_limit: Option>, - - /// The UTC date and timestamp when the resource was created. - #[builder(default, setter(into))] - created_at: Option>, - - /// The ID of the pool used by the listener if no L7 policies match. - #[builder(default, setter(into))] - default_pool_id: Option>, - - /// A human-readable description for the resource. - #[builder(default, setter(into))] - description: Option>, - - /// Defines whether the includeSubDomains directive should be added to the - /// Strict-Transport-Security HTTP response header. - #[builder(default)] - hsts_include_subdomains: Option, - - /// The value of the max_age directive for the Strict-Transport-Security - /// HTTP response header. - #[builder(default)] - hsts_max_age: Option, - - /// Defines whether the preload directive should be added to the - /// Strict-Transport-Security HTTP response header. - #[builder(default)] - hsts_preload: Option, - - /// The ID of the resource - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// Load balancer ID - #[builder(default, setter(into))] - load_balancer_id: Option>, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - /// Human-readable name of the resource. - #[builder(default, setter(into))] - name: Option>, - - /// Return the list of entities that do not have one or more of the given - /// tags. - #[builder(default, setter(into))] - not_tags: Option>, - - /// Return the list of entities that do not have at least one of the given - /// tags. - #[builder(default, setter(into))] - not_tags_any: Option>, - - /// The operating status of the resource. - #[builder(default, setter(into))] - operating_status: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - /// The ID of the project owning this resource. - #[builder(default, setter(into))] - project_id: Option>, - - /// The protocol for the resource. - #[builder(default, setter(into))] - protocol: Option>, - - /// The protocol port number for the resource. - #[builder(default)] - protocol_port: Option, - - /// The provisioning status of the resource. - #[builder(default, setter(into))] - provisioning_status: Option>, - - /// Return the list of entities that have this tag or tags. - #[builder(default, setter(into))] - tags: Option>, - - /// Return the list of entities that have one or more of the given tags. - #[builder(default, setter(into))] - tags_any: Option>, - - /// Frontend client inactivity timeout in milliseconds. - #[builder(default)] - timeout_client_data: Option, - - /// Backend member connection timeout in milliseconds. - #[builder(default)] - timeout_member_connect: Option, - - /// Backend member inactivity timeout in milliseconds. - #[builder(default)] - timeout_member_data: Option, - - /// Time, in milliseconds, to wait for additional TCP packets for content - /// inspection. - #[builder(default)] - timeout_tcp_inspect: Option, - - /// List of ciphers in OpenSSL format - #[builder(default, setter(into))] - tls_ciphers: Option>, - - /// A list of TLS protocol versions. - #[builder(default, setter(into))] - tls_versions: Option>, - - /// The UTC date and timestamp when the resource was last updated. - #[builder(default, setter(into))] - 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<'a> RequestBuilder<'a> { - /// Add a single header to the Listener. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/listeners".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("alpn_protocols", self.alpn_protocols.as_ref()); - params.push_opt("connection_limit", self.connection_limit.as_ref()); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("default_pool_id", self.default_pool_id.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("hsts_include_subdomains", self.hsts_include_subdomains); - params.push_opt("hsts_max_age", self.hsts_max_age); - params.push_opt("hsts_preload", self.hsts_preload); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("load_balancer_id", self.load_balancer_id.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("operating_status", self.operating_status.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("protocol", self.protocol.as_ref()); - params.push_opt("protocol_port", self.protocol_port); - params.push_opt("provisioning_status", self.provisioning_status.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("timeout_client_data", self.timeout_client_data); - params.push_opt("timeout_member_connect", self.timeout_member_connect); - params.push_opt("timeout_member_data", self.timeout_member_data); - params.push_opt("timeout_tcp_inspect", self.timeout_tcp_inspect); - params.push_opt("tls_ciphers", self.tls_ciphers.as_ref()); - params.push_opt("tls_versions", self.tls_versions.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("listeners".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "listeners" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/listeners".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listeners": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/listeners".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listeners": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener/set.rs b/openstack_sdk/src/api/load_balancer/v2/listener/set.rs deleted file mode 100644 index 6167ae1af..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/listener/set.rs +++ /dev/null @@ -1,435 +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`. - -//! Update an existing listener. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the update, check that the listener provisioning status is -//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll -//! the listener object for changes. -//! -//! This operation returns the updated listener object with the `ACTIVE`, -//! `PENDING_UPDATE`, or `ERROR` provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 ClientAuthentication { - #[serde(rename = "MANDATORY")] - Mandatory, - #[serde(rename = "NONE")] - None, - #[serde(rename = "OPTIONAL")] - Optional, -} - -/// Defines attributes that are acceptable of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Listener<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A list of IPv4, IPv6 or mix of both CIDRs. The default is all allowed. - /// When a list of CIDRs is provided, the default switches to deny all. - /// - /// **New in version 2.12** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allowed_cidrs: Option>>, - - /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 - /// - /// **New in version 2.20** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - /// The TLS client authentication mode. One of the options `NONE`, - /// `OPTIONAL` or `MANDATORY`. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) client_authentication: Option, - - /// The ref of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format client CA certificate bundle for - /// `TERMINATED_HTTPS` listeners. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) client_ca_tls_container_ref: Option>, - - /// The URI of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format CA revocation list file for - /// `TERMINATED_HTTPS` listeners. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) client_crl_container_ref: Option>, - - /// The maximum number of connections permitted for this listener. Default - /// value is -1 which represents infinite connections or a default value - /// defined by the provider driver. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) connection_limit: Option, - - /// The ID of the pool used by the listener if no L7 policies match. The - /// pool has some restrictions. See - /// [Protocol Combinations (Listener/Pool)](#valid-protocol). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_pool_id: Option>, - - /// The URI of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PKCS12 format certificate/key bundle for - /// `TERMINATED_HTTPS` listeners. DEPRECATED: A secret container of type - /// “certificate” containing the certificate and key for `TERMINATED_HTTPS` - /// listeners. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_tls_container_ref: Option>, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines whether the `includeSubDomains` directive should be added to - /// the Strict-Transport-Security HTTP response header. This requires - /// setting the `hsts_max_age` option as well in order to become effective. - /// - /// **New in version 2.27** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_include_subdomains: Option, - - /// The value of the `max_age` directive for the Strict-Transport-Security - /// HTTP response header. Setting this enables HTTP Strict Transport - /// Security (HSTS) for the TLS-terminated listener. - /// - /// **New in version 2.27** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_max_age: Option, - - /// Defines whether the `preload` directive should be added to the - /// Strict-Transport-Security HTTP response header. This requires setting - /// the `hsts_max_age` option as well in order to become effective. - /// - /// **New in version 2.27** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_preload: Option, - - /// A dictionary of optional headers to insert into the request before it - /// is sent to the backend `member`. See - /// [Supported HTTP Header Insertions](#header-insertions). Both keys and - /// values are always specified as strings. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_insert_headers"))] - pub(crate) insert_headers: Option, Cow<'a, str>>>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of URIs to the - /// [key manager service](https://docs.openstack.org/barbican/latest/) - /// secrets containing PKCS12 format certificate/key bundles for - /// `TERMINATED_HTTPS` listeners. (DEPRECATED) Secret containers of type - /// “certificate” containing the certificates and keys for - /// `TERMINATED_HTTPS` listeners. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) sni_container_refs: Option>>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// Frontend client inactivity timeout in milliseconds. Default: 50000. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_client_data: Option, - - /// Backend member connection timeout in milliseconds. Default: 5000. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_member_connect: Option, - - /// Backend member inactivity timeout in milliseconds. Default: 50000. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_member_data: Option, - - /// Time, in milliseconds, to wait for additional TCP packets for content - /// inspection. Default: 0. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_tcp_inspect: Option, - - /// List of ciphers in OpenSSL format (colon-separated). See - /// - /// - /// **New in version 2.15** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, - /// TLSv1.1, TLSv1.2, TLSv1.3 - /// - /// **New in version 2.17** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -impl<'a> ListenerBuilder<'a> { - /// A dictionary of optional headers to insert into the request before it - /// is sent to the backend `member`. See - /// [Supported HTTP Header Insertions](#header-insertions). Both keys and - /// values are always specified as strings. - pub fn insert_headers(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.insert_headers - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines attributes that are acceptable of a PUT request. - #[builder(setter(into))] - pub(crate) listener: Listener<'a>, - - /// listener_id parameter for /v2/lbaas/listeners/{listener_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<'a> RequestBuilder<'a> { - /// Add a single header to the Listener. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/listeners/{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("listener", serde_json::to_value(&self.listener)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("listener".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .listener(ListenerBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .listener(ListenerBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "listener" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/listeners/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listener": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .listener(ListenerBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/listeners/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "listener": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .listener(ListenerBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener/stats.rs b/openstack_sdk/src/api/load_balancer/v2/listener/stats.rs deleted file mode 100644 index 74772332a..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/listener/stats.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows the current statistics for a listener. -//! -//! This operation returns the statistics of a listener object identified by -//! listener_id. -//! -//! If you are not an administrative user and the parent load balancer does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// listener_id parameter for /v2/lbaas/listeners/{listener_id}/stats 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<'a> RequestBuilder<'a> { - /// Add a single header to the Listener. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/listeners/{id}/stats", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("stats".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "stats" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/listeners/{id}/stats", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stats": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/listeners/{id}/stats", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stats": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/create.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/create.rs deleted file mode 100644 index 56659a1ec..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/create.rs +++ /dev/null @@ -1,1288 +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`. - -//! Creates a load balancer. -//! -//! This operation provisions a new load balancer by using the configuration -//! that you define in the request object. After the API validates the request -//! and starts the provisioning process, the API returns a response object that -//! contains a unique ID and the status of provisioning the load balancer. -//! -//! In the response, the load balancer [provisioning status](#prov-status) is -//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. -//! -//! If the status is `PENDING_CREATE`, issue GET -//! `/v2/lbaas/loadbalancers/{loadbalancer_id}` to view the progress of the -//! provisioning operation. When the load balancer status changes to `ACTIVE`, -//! the load balancer is successfully provisioned and is ready for further -//! configuration. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! Administrative users can specify a project ID that is different than their -//! own to create load balancers for other projects. -//! -//! An optional `flavor_id` attribute can be used to create the load balancer -//! using a pre-configured octavia flavor. Flavors are created by the operator -//! to allow custom load balancer configurations, such as allocating more -//! memory for the load balancer. -//! -//! An optional `vip_qos_policy_id` attribute from Neutron can be used to apply -//! QoS policies on a loadbalancer VIP, also could pass a ‘null’ value to -//! remove QoS policies. -//! -//! You can also specify the `provider` attribute when you create a load -//! balancer. The `provider` attribute specifies which backend should be used -//! to create the load balancer. This could be the default provider (`octavia`) -//! or a vendor supplied `provider` if one has been installed. Setting both a -//! flavor_id and a provider will result in a conflict error if the provider -//! does not match the provider of the configured flavor profiles. -//! -//! Specifying a Virtual IP (VIP) is mandatory. There are three ways to specify -//! a VIP network for the load balancer: -//! -//! Additional VIPs may also be specified in the `additional_vips` field, by -//! providing a list of JSON objects containing a `subnet_id` and optionally an -//! `ip_address`. All additional subnets must be part of the same network as -//! the primary VIP. -//! -//! An optional `vip_sg_ids` attribute can be used to set custom Neutron -//! Security Groups that are applied on the VIP port of the Load Balancer. When -//! this option is used, Octavia does not manage the security of the Listeners, -//! the user must set Security Group Rules to allow the network traffic on the -//! VIP port. `vip_sg_ids` are incompatible with SR-IOV load balancer and -//! cannot be set if the load balancer has a listener that uses -//! `allowed_cidrs`. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -/// Type for additional vips -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AdditionalVips<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_id: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) subnet_id: Cow<'a, str>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum ClientAuthentication { - #[serde(rename = "MANDATORY")] - Mandatory, - #[serde(rename = "NONE")] - None, - #[serde(rename = "OPTIONAL")] - Optional, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HttpMethod { - #[serde(rename = "CONNECT")] - Connect, - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "OPTIONS")] - Options, - #[serde(rename = "PATCH")] - Patch, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, - #[serde(rename = "TRACE")] - Trace, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HealthmonitorType { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PING")] - Ping, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TLS-HELLO")] - TlsHello, - #[serde(rename = "UDP-CONNECT")] - UdpConnect, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Healthmonitor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) delay: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) max_retries: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) timeout: i32, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: HealthmonitorType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum LbAlgorithm { - #[serde(rename = "LEAST_CONNECTIONS")] - LeastConnections, - #[serde(rename = "ROUND_ROBIN")] - RoundRobin, - #[serde(rename = "SOURCE_IP")] - SourceIp, - #[serde(rename = "SOURCE_IP_PORT")] - SourceIpPort, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Members<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) address: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) backup: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_address: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_port: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_port: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) request_sriov: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) weight: Option, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum DefaultPoolProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROXY")] - Proxy, - #[serde(rename = "PROXYV2")] - Proxyv2, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "UDP")] - Udp, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum SessionPersistenceType { - #[serde(rename = "APP_COOKIE")] - AppCookie, - #[serde(rename = "HTTP_COOKIE")] - HttpCookie, - #[serde(rename = "SOURCE_IP")] - SourceIp, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SessionPersistence<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cookie_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_granularity: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_timeout: Option, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: SessionPersistenceType, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct DefaultPool<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ca_tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) crl_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) healthmonitor: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) lb_algorithm: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) members: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) session_persistence: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_enabled: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Action { - #[serde(rename = "REDIRECT_PREFIX")] - RedirectPrefix, - #[serde(rename = "REDIRECT_TO_POOL")] - RedirectToPool, - #[serde(rename = "REDIRECT_TO_URL")] - RedirectToUrl, - #[serde(rename = "REJECT")] - Reject, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum RedirectPoolHealthmonitorType { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PING")] - Ping, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TLS-HELLO")] - TlsHello, - #[serde(rename = "UDP-CONNECT")] - UdpConnect, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RedirectPoolHealthmonitor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) delay: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) max_retries: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) timeout: i32, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: RedirectPoolHealthmonitorType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum RedirectPoolProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROXY")] - Proxy, - #[serde(rename = "PROXYV2")] - Proxyv2, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "UDP")] - Udp, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "APP_COOKIE")] - AppCookie, - #[serde(rename = "HTTP_COOKIE")] - HttpCookie, - #[serde(rename = "SOURCE_IP")] - SourceIp, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RedirectPool<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ca_tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) crl_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) healthmonitor: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) lb_algorithm: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) members: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) session_persistence: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_enabled: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum CompareType { - #[serde(rename = "CONTAINS")] - Contains, - #[serde(rename = "ENDS_WITH")] - EndsWith, - #[serde(rename = "EQUAL_TO")] - EqualTo, - #[serde(rename = "REGEX")] - Regex, - #[serde(rename = "STARTS_WITH")] - StartsWith, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum RulesType { - #[serde(rename = "COOKIE")] - Cookie, - #[serde(rename = "FILE_TYPE")] - FileType, - #[serde(rename = "HEADER")] - Header, - #[serde(rename = "HOST_NAME")] - HostName, - #[serde(rename = "PATH")] - Path, - #[serde(rename = "SSL_CONN_HAS_CERT")] - SslConnHasCert, - #[serde(rename = "SSL_DN_FIELD")] - SslDnField, - #[serde(rename = "SSL_VERIFY_RESULT")] - SslVerifyResult, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Rules<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder()] - pub(crate) compare_type: CompareType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) invert: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) key: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: RulesType, - - #[serde()] - #[builder(setter(into))] - pub(crate) value: Cow<'a, str>, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct L7policies<'a> { - #[serde()] - #[builder()] - pub(crate) action: Action, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) position: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_http_code: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_pool: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) redirect_url: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) rules: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum ListenersProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROMETHEUS")] - Prometheus, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TERMINATED_HTTPS")] - TerminatedHttps, - #[serde(rename = "UDP")] - Udp, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Listeners<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allowed_cidrs: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) client_authentication: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) client_ca_tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) client_crl_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) connection_limit: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_pool: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_pool_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_include_subdomains: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_max_age: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) hsts_preload: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_insert_headers"))] - pub(crate) insert_headers: Option, Cow<'a, str>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) l7policies: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde()] - #[builder()] - pub(crate) protocol: ListenersProtocol, - - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_port: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) sni_container_refs: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_client_data: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_member_connect: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_member_data: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) timeout_tcp_inspect: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -impl<'a> ListenersBuilder<'a> { - pub fn insert_headers(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.insert_headers - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum PoolsHealthmonitorType { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PING")] - Ping, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TLS-HELLO")] - TlsHello, - #[serde(rename = "UDP-CONNECT")] - UdpConnect, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PoolsHealthmonitor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) delay: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) max_retries: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) timeout: i32, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: PoolsHealthmonitorType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum PoolsProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROXY")] - Proxy, - #[serde(rename = "PROXYV2")] - Proxyv2, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "UDP")] - Udp, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Pools<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ca_tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) crl_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) healthmonitor: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) lb_algorithm: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) members: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) session_persistence: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_container_ref: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_enabled: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -/// A load balancer object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Loadbalancer<'a> { - /// A list of JSON objects defining “additional VIPs”. The format for these - /// is `{"subnet_id": , "ip_address": }`, where the - /// `subnet_id` field is mandatory and the `ip_address` field is optional. - /// Additional VIP subnets must all belong to the same network as the - /// primary VIP. - /// - /// **New in version 2.26** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) additional_vips: Option>>, - - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// An availability zone name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone: Option>, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The ID of the flavor. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) flavor_id: Option>, - - /// The associated listener IDs, if any. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) listeners: Option>>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) pools: Option>>, - - /// The ID of the project owning this resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// Provider name for the load balancer. Default is `octavia`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) provider: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The IP address of the Virtual IP (VIP). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_address: Option>, - - /// The ID of the network for the Virtual IP (VIP). One of - /// `vip_network_id`, `vip_port_id`, or `vip_subnet_id` must be specified. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_network_id: Option>, - - /// The ID of the Virtual IP (VIP) port. One of `vip_network_id`, - /// `vip_port_id`, or `vip_subnet_id` must be specified. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_port_id: Option>, - - /// The ID of the QoS Policy which will apply to the Virtual IP (VIP). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_qos_policy_id: Option>, - - /// The list of Security Group IDs of the Virtual IP (VIP) port of the Load - /// Balancer. - /// - /// **New in version 2.29** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_sg_ids: Option>>, - - /// The ID of the subnet for the Virtual IP (VIP). One of `vip_network_id`, - /// `vip_port_id`, or `vip_subnet_id` must be specified. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_subnet_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A load balancer object. - #[builder(setter(into))] - pub(crate) loadbalancer: Loadbalancer<'a>, - - #[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 Loadbalancer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/loadbalancers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("loadbalancer", serde_json::to_value(&self.loadbalancer)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("loadbalancer".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "loadbalancer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/loadbalancers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancer": {} })); - }); - - let endpoint = Request::builder() - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/loadbalancers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancer": {} })); - }); - - let endpoint = Request::builder() - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/delete.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/delete.rs deleted file mode 100644 index bf6f7f8f6..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/delete.rs +++ /dev/null @@ -1,195 +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`. - -//! Removes a load balancer and its associated configuration from the project. -//! -//! The optional parameter `cascade` when defined as `true` will delete all -//! child objects of the load balancer. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// If true will delete all child objects of the load balancer. - #[builder(default)] - cascade: Option, - - /// loadbalancer_id parameter for /v2/lbaas/loadbalancers/{loadbalancer_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<'a> RequestBuilder<'a> { - /// Add a single header to the Loadbalancer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/loadbalancers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("cascade", self.cascade); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/loadbalancers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/loadbalancers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/failover.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/failover.rs deleted file mode 100644 index 918eede03..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/failover.rs +++ /dev/null @@ -1,185 +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`. - -//! Performs a failover of a load balancer. -//! -//! This operation is only available to users with load balancer administrative -//! rights. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// loadbalancer_id parameter for - /// /v2/lbaas/loadbalancers/{loadbalancer_id}/failover 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<'a> RequestBuilder<'a> { - /// Add a single header to the Loadbalancer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/loadbalancers/{id}/failover", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/loadbalancers/{id}/failover", 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/loadbalancers/{id}/failover", 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/find.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/find.rs deleted file mode 100644 index 98248488b..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::loadbalancer::{get as Get, list as List}; - -/// Find for loadbalancer 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/get.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/get.rs deleted file mode 100644 index 45d0cb376..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows the details of a load balancer. -//! -//! If you are not an administrative user and the load balancer object does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// loadbalancer_id parameter for /v2/lbaas/loadbalancers/{loadbalancer_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<'a> RequestBuilder<'a> { - /// Add a single header to the Loadbalancer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/loadbalancers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("loadbalancer".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "loadbalancer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/loadbalancers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancer": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/loadbalancers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/list.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/list.rs deleted file mode 100644 index 866f6069b..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/list.rs +++ /dev/null @@ -1,310 +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`. - -//! Lists all load balancers for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list load balancers for other projects. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An availability zone name. - #[builder(default, setter(into))] - availability_zone: Option>, - - /// The UTC date and timestamp when the resource was created. - #[builder(default, setter(into))] - created_at: Option>, - - /// A human-readable description for the resource. - #[builder(default, setter(into))] - description: Option>, - - /// The ID of the flavor. - #[builder(default, setter(into))] - flavor_id: Option>, - - /// The ID of the resource - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - /// Human-readable name of the resource. - #[builder(default, setter(into))] - name: Option>, - - /// Return the list of entities that do not have one or more of the given - /// tags. - #[builder(default, setter(into))] - not_tags: Option>, - - /// Return the list of entities that do not have at least one of the given - /// tags. - #[builder(default, setter(into))] - not_tags_any: Option>, - - /// The operating status of the resource. - #[builder(default, setter(into))] - operating_status: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - /// The ID of the project owning this resource. - #[builder(default, setter(into))] - project_id: Option>, - - /// Provider name for the load balancer. - #[builder(default, setter(into))] - provider: Option>, - - /// The provisioning status of the resource. - #[builder(default, setter(into))] - provisioning_status: Option>, - - /// Return the list of entities that have this tag or tags. - #[builder(default, setter(into))] - tags: Option>, - - /// Return the list of entities that have one or more of the given tags. - #[builder(default, setter(into))] - tags_any: Option>, - - /// The UTC date and timestamp when the resource was last updated. - #[builder(default, setter(into))] - updated_at: Option>, - - /// The IP address of the Virtual IP (VIP). - #[builder(default, setter(into))] - vip_address: Option>, - - /// The ID of the network for the Virtual IP (VIP). - #[builder(default, setter(into))] - vip_network_id: Option>, - - /// The ID of the Virtual IP (VIP) port. - #[builder(default, setter(into))] - vip_port_id: Option>, - - /// The ID of the QoS Policy which will apply to the Virtual IP (VIP). - #[builder(default, setter(into))] - vip_qos_policy_id: Option>, - - /// The ID of the subnet for the Virtual IP (VIP). - #[builder(default, setter(into))] - vip_subnet_id: 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> { - /// Add a single header to the Loadbalancer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/loadbalancers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("availability_zone", self.availability_zone.as_ref()); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("flavor_id", self.flavor_id.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("operating_status", self.operating_status.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("provider", self.provider.as_ref()); - params.push_opt("provisioning_status", self.provisioning_status.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - params.push_opt("vip_address", self.vip_address.as_ref()); - params.push_opt("vip_network_id", self.vip_network_id.as_ref()); - params.push_opt("vip_port_id", self.vip_port_id.as_ref()); - params.push_opt("vip_qos_policy_id", self.vip_qos_policy_id.as_ref()); - params.push_opt("vip_subnet_id", self.vip_subnet_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("loadbalancers".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "loadbalancers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/loadbalancers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/loadbalancers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/set.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/set.rs deleted file mode 100644 index 6f8f16e34..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/set.rs +++ /dev/null @@ -1,258 +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`. - -//! Updates a load balancer. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the update, check that the load balancer provisioning -//! status is `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation -//! to poll the load balancer object for changes. -//! -//! This operation returns the updated load balancer object with the `ACTIVE`, -//! `PENDING_UPDATE`, or `ERROR` provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A load balancer object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Loadbalancer<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// The ID of the QoS Policy which will apply to the Virtual IP (VIP). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_qos_policy_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vip_sg_ids: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A load balancer object. - #[builder(setter(into))] - pub(crate) loadbalancer: Loadbalancer<'a>, - - /// loadbalancer_id parameter for /v2/lbaas/loadbalancers/{loadbalancer_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<'a> RequestBuilder<'a> { - /// Add a single header to the Loadbalancer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/loadbalancers/{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("loadbalancer", serde_json::to_value(&self.loadbalancer)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("loadbalancer".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "loadbalancer" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/loadbalancers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/loadbalancers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loadbalancer": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/stats.rs b/openstack_sdk/src/api/load_balancer/v2/loadbalancer/stats.rs deleted file mode 100644 index fe2fffb2e..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/stats.rs +++ /dev/null @@ -1,194 +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`. - -//! Shows the current statistics for a load balancer. -//! -//! This operation returns the statistics of a load balancer object identified -//! by loadbalancer_id. -//! -//! If you are not an administrative user and the load balancer object does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// loadbalancer_id parameter for - /// /v2/lbaas/loadbalancers/{loadbalancer_id}/stats 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<'a> RequestBuilder<'a> { - /// Add a single header to the Loadbalancer. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/loadbalancers/{id}/stats", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("stats".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "stats" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/loadbalancers/{id}/stats", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stats": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/loadbalancers/{id}/stats", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "stats": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/octavia/get.rs b/openstack_sdk/src/api/load_balancer/v2/octavia/get.rs deleted file mode 100644 index 8d0633288..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/octavia/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Octavia. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "octavia".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/octavia".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/octavia".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/create.rs b/openstack_sdk/src/api/load_balancer/v2/pool/create.rs deleted file mode 100644 index 8c2b07559..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/create.rs +++ /dev/null @@ -1,614 +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`. - -//! Creates a pool for a load balancer. -//! -//! The pool defines how requests should be balanced across the backend member -//! servers. -//! -//! This operation provisions a pool by using the configuration that you define -//! in the request object. After the API validates the request and starts the -//! provisioning process, the API returns a response object, which contains a -//! unique ID. -//! -//! In the response, the pool [provisioning status](#prov-status) is `ACTIVE`, -//! `PENDING_CREATE`, or `ERROR`. -//! -//! If the status is `PENDING_CREATE`, issue GET `/v2/lbaas/pools/{pool_id}` to -//! view the progress of the provisioning operation. When the pool status -//! changes to `ACTIVE`, the pool is successfully provisioned and is ready for -//! further configuration. -//! -//! At a minimum, you must specify these pool attributes: -//! -//! Some attributes receive default values if you omit them from the request: -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! Specifying a project_id is deprecated. The pool will inherit the project_id -//! of the parent load balancer. -//! -//! You can configure all documented features of the pool at creation time by -//! specifying the additional elements or attributes in the request. -//! -//! To create a pool, the parent load balancer must have an `ACTIVE` -//! provisioning status. -//! -//! `SOURCE_IP_PORT` algorithm is available from version 2.13. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HttpMethod { - #[serde(rename = "CONNECT")] - Connect, - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "OPTIONS")] - Options, - #[serde(rename = "PATCH")] - Patch, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, - #[serde(rename = "TRACE")] - Trace, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum HealthmonitorType { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PING")] - Ping, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "TLS-HELLO")] - TlsHello, - #[serde(rename = "UDP-CONNECT")] - UdpConnect, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Healthmonitor<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) delay: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) expected_codes: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) http_method: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) http_version: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) max_retries: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_retries_down: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) timeout: i32, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: HealthmonitorType, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) url_path: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum LbAlgorithm { - #[serde(rename = "LEAST_CONNECTIONS")] - LeastConnections, - #[serde(rename = "ROUND_ROBIN")] - RoundRobin, - #[serde(rename = "SOURCE_IP")] - SourceIp, - #[serde(rename = "SOURCE_IP_PORT")] - SourceIpPort, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Members<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) address: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) backup: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_address: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_port: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_port: i32, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) request_sriov: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) weight: Option, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Protocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "HTTPS")] - Https, - #[serde(rename = "PROXY")] - Proxy, - #[serde(rename = "PROXYV2")] - Proxyv2, - #[serde(rename = "SCTP")] - Sctp, - #[serde(rename = "TCP")] - Tcp, - #[serde(rename = "UDP")] - Udp, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum SessionPersistenceType { - #[serde(rename = "APP_COOKIE")] - AppCookie, - #[serde(rename = "HTTP_COOKIE")] - HttpCookie, - #[serde(rename = "SOURCE_IP")] - SourceIp, -} - -/// A JSON object specifying the session persistence for the pool or `null` for -/// no session persistence. See -/// [Pool Session Persistence](#session-persistence). Default is `null`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SessionPersistence<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cookie_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_granularity: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_timeout: Option, - - #[serde(rename = "type")] - #[builder()] - pub(crate) _type: SessionPersistenceType, -} - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Pool<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 - /// - /// **New in version 2.24** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - /// The reference of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format CA certificate bundle for `tls_enabled` - /// pools. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ca_tls_container_ref: Option>, - - /// The reference of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format CA revocation list file for - /// `tls_enabled` pools. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) crl_container_ref: Option>, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Defines mandatory and optional attributes of a POST request. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) healthmonitor: Option>, - - /// The load balancing algorithm for the pool. One of `LEAST_CONNECTIONS`, - /// `ROUND_ROBIN`, `SOURCE_IP`, or `SOURCE_IP_PORT`. - #[serde()] - #[builder()] - pub(crate) lb_algorithm: LbAlgorithm, - - /// The ID of the listener for the pool. Either `listener_id` or - /// `loadbalancer_id` must be specified. The listener has some - /// restrictions, See - /// [Protocol Combinations (Listener/Pool)](#valid-protocol). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) listener_id: Option>, - - /// The ID of the load balancer for the pool. Either `listener_id` or - /// `loadbalancer_id` must be specified. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) loadbalancer_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) members: Option>>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the project owning this resource. (deprecated) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The protocol for the resource. One of `HTTP`, `HTTPS`, `PROXY`, - /// `PROXYV2`, `SCTP`, `TCP`, or `UDP`. - #[serde()] - #[builder()] - pub(crate) protocol: Protocol, - - /// A JSON object specifying the session persistence for the pool or `null` - /// for no session persistence. See - /// [Pool Session Persistence](#session-persistence). Default is `null`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) session_persistence: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// List of ciphers in OpenSSL format (colon-separated). See - /// - /// - /// **New in version 2.15** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - /// The reference to the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PKCS12 format certificate/key bundle for - /// `tls_enabled` pools for TLS client authentication to the member - /// servers. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_container_ref: Option>, - - /// When `true` connections to backend member servers will use TLS - /// encryption. Default is `false`. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_enabled: Option, - - /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, - /// TLSv1.1, TLSv1.2, TLSv1.3 - /// - /// **New in version 2.17** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) pool: Pool<'a>, - - #[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 Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/pools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("pool", serde_json::to_value(&self.pool)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("pool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .pool( - PoolBuilder::default() - .lb_algorithm(LbAlgorithm::LeastConnections) - .protocol(Protocol::Http) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .pool( - PoolBuilder::default() - .lb_algorithm(LbAlgorithm::LeastConnections) - .protocol(Protocol::Http) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "pool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/pools".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pool": {} })); - }); - - let endpoint = Request::builder() - .pool( - PoolBuilder::default() - .lb_algorithm(LbAlgorithm::LeastConnections) - .protocol(Protocol::Http) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/lbaas/pools".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pool": {} })); - }); - - let endpoint = Request::builder() - .pool( - PoolBuilder::default() - .lb_algorithm(LbAlgorithm::LeastConnections) - .protocol(Protocol::Http) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/delete.rs b/openstack_sdk/src/api/load_balancer/v2/pool/delete.rs deleted file mode 100644 index 98ffb1188..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Removes a pool and its associated configuration from the load balancer. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// pool_id parameter for /v2/lbaas/pools/{pool_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<'a> RequestBuilder<'a> { - /// Add a single header to the Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/pools/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/pools/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/lbaas/pools/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/find.rs b/openstack_sdk/src/api/load_balancer/v2/pool/find.rs deleted file mode 100644 index b43879e3a..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::pool::{get as Get, list as List}; - -/// Find for pool 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/get.rs b/openstack_sdk/src/api/load_balancer/v2/pool/get.rs deleted file mode 100644 index 42ee10dac..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/get.rs +++ /dev/null @@ -1,190 +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`. - -//! Shows the details of a pool. -//! -//! If you are not an administrative user and the parent load balancer does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// pool_id parameter for /v2/lbaas/pools/{pool_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<'a> RequestBuilder<'a> { - /// Add a single header to the Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("lbaas/pools/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("pool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "pool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/pools/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pool": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/lbaas/pools/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/list.rs b/openstack_sdk/src/api/load_balancer/v2/pool/list.rs deleted file mode 100644 index 9fff70bbb..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/list.rs +++ /dev/null @@ -1,299 +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`. - -//! Lists all pools for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list pools for other projects. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The administrative state of the resource - #[builder(default)] - admin_state_up: Option, - - /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 - #[builder(default, setter(into))] - alpn_protocols: Option>, - - /// The UTC date and timestamp when the resource was created. - #[builder(default, setter(into))] - created_at: Option>, - - /// A human-readable description for the resource. - #[builder(default, setter(into))] - description: Option>, - - /// The ID of the resource - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// The ID of the load balancer for the pool. - #[builder(default, setter(into))] - loadbalancer_id: Option>, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - /// Human-readable name of the resource. - #[builder(default, setter(into))] - name: Option>, - - /// Return the list of entities that do not have one or more of the given - /// tags. - #[builder(default, setter(into))] - not_tags: Option>, - - /// Return the list of entities that do not have at least one of the given - /// tags. - #[builder(default, setter(into))] - not_tags_any: Option>, - - /// The operating status of the resource. - #[builder(default, setter(into))] - operating_status: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - /// The ID of the project owning this resource. - #[builder(default, setter(into))] - project_id: Option>, - - /// The provisioning status of the resource. - #[builder(default, setter(into))] - provisioning_status: Option>, - - /// Return the list of entities that have this tag or tags. - #[builder(default, setter(into))] - tags: Option>, - - /// Return the list of entities that have one or more of the given tags. - #[builder(default, setter(into))] - tags_any: Option>, - - /// List of ciphers in OpenSSL format - #[builder(default, setter(into))] - tls_ciphers: Option>, - - #[builder(default)] - tls_enabled: Option, - - /// A list of TLS protocol versions. - #[builder(default, setter(into))] - tls_versions: Option>, - - /// The UTC date and timestamp when the resource was last updated. - #[builder(default, setter(into))] - 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<'a> RequestBuilder<'a> { - /// Add a single header to the Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/pools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("alpn_protocols", self.alpn_protocols.as_ref()); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("loadbalancer_id", self.loadbalancer_id.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("operating_status", self.operating_status.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("provisioning_status", self.provisioning_status.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tls_ciphers", self.tls_ciphers.as_ref()); - params.push_opt("tls_enabled", self.tls_enabled); - params.push_opt("tls_versions", self.tls_versions.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("pools".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "pools" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/pools".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pools": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/pools".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pools": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member/create.rs b/openstack_sdk/src/api/load_balancer/v2/pool/member/create.rs deleted file mode 100644 index 012b2b745..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/member/create.rs +++ /dev/null @@ -1,368 +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`. - -//! This operation provisions a member and adds it to a pool by using the -//! configuration that you define in the request object. After the API -//! validates the request and starts the provisioning process, it returns a -//! response object, which contains a unique ID. -//! -//! In the response, the member [provisioning status](#prov-status) is -//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. -//! -//! If the status is `PENDING_CREATE`, issue GET -//! `/v2/lbaas/pools/{pool_id}/members/{member_id}` to view the progress of the -//! provisioning operation. When the member status changes to `ACTIVE`, the -//! member is successfully provisioned and is ready for further configuration. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! At a minimum, you must specify these member attributes: -//! -//! Some attributes receive default values if you omit them from the request: -//! -//! If you omit the `subnet_id` parameter, the `vip_subnet_id` for the parent -//! load balancer will be used for the member subnet UUID. -//! -//! The member `address` does not necessarily need to be a member of the -//! `subnet_id` subnet. Members can be routable from the subnet specified -//! either via the default route or by using `host_routes` defined on the -//! subnet. -//! -//! Administrative users can specify a project ID that is different than their -//! own to create members for other projects. -//! -//! `monitor_address` and/or `monitor_port` can be used to have the health -//! monitor, if one is configured for the pool, connect to an alternate IP -//! address and port when executing a health check on the member. -//! -//! To create a member, the load balancer must have an `ACTIVE` provisioning -//! status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Member<'a> { - /// The IP address of the resource. - #[serde()] - #[builder(setter(into))] - pub(crate) address: Cow<'a, str>, - - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// Is the member a backup? Backup members only receive traffic when all - /// non-backup members are down. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) backup: Option, - - /// An alternate IP address used for health monitoring a backend member. - /// Default is `null` which monitors the member `address`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_address: Option>, - - /// An alternate protocol port used for health monitoring a backend member. - /// Default is `null` which monitors the member `protocol_port`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_port: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the project owning this resource. (deprecated) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The protocol port number for the resource. - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_port: i32, - - /// Request that an SR-IOV VF be used for the member network port. Defaults - /// to `false`. - /// - /// **New in version 2.29** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) request_sriov: Option, - - /// The subnet ID the member service is accessible from. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The weight of a member determines the portion of requests or - /// connections it services compared to the other members of the pool. For - /// example, a member with a weight of 10 receives five times as many - /// requests as a member with a weight of 2. A value of 0 means the member - /// does not receive new connections but continues to service existing - /// connections. A valid value is from `0` to `256`. Default is `1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) weight: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines mandatory and optional attributes of a POST request. - #[builder(setter(into))] - pub(crate) member: Member<'a>, - - /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API - #[builder(default, setter(into))] - pool_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "lbaas/pools/{pool_id}/members", - pool_id = self.pool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("member", serde_json::to_value(&self.member)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("member".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .member( - MemberBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .member( - MemberBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "member" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/lbaas/pools/{pool_id}/members", - pool_id = "pool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .pool_id("pool_id") - .member( - MemberBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/lbaas/pools/{pool_id}/members", - pool_id = "pool_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .pool_id("pool_id") - .member( - MemberBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member/delete.rs b/openstack_sdk/src/api/load_balancer/v2/pool/member/delete.rs deleted file mode 100644 index fe295c347..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/member/delete.rs +++ /dev/null @@ -1,206 +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`. - -//! Removes a member and its associated configuration from the pool. -//! -//! The API immediately purges any and all configuration data, depending on the -//! configuration settings. You cannot recover it. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// member_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API - #[builder(default, setter(into))] - pool_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/pools/{pool_id}/members/{id}", - id = self.id.as_ref(), - pool_id = self.pool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/lbaas/pools/{pool_id}/members/{id}", - id = "id", - pool_id = "pool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .pool_id("pool_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/lbaas/pools/{pool_id}/members/{id}", - id = "id", - pool_id = "pool_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") - .pool_id("pool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member/find.rs b/openstack_sdk/src/api/load_balancer/v2/pool/member/find.rs deleted file mode 100644 index ef9ff0c13..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/member/find.rs +++ /dev/null @@ -1,96 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::load_balancer::v2::pool::member::{get as Get, list as List}; - -/// Find for pool/member by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[builder(default, setter(into))] - pool_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 Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.pool_id(self.pool_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - let mut ep = List::Request::builder(); - ep.pool_id(self.pool_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member/get.rs b/openstack_sdk/src/api/load_balancer/v2/pool/member/get.rs deleted file mode 100644 index d53fe879c..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/member/get.rs +++ /dev/null @@ -1,212 +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`. - -//! Shows the details of a pool member. -//! -//! If you are not an administrative user and the parent load balancer does not -//! belong to your project, the service returns the HTTP `Forbidden (403)` -//! response code. -//! -//! This operation does not require a request body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// member_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API - #[builder(default, setter(into))] - pool_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/pools/{pool_id}/members/{id}", - id = self.id.as_ref(), - pool_id = self.pool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("member".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "member" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/lbaas/pools/{pool_id}/members/{id}", - id = "id", - pool_id = "pool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .pool_id("pool_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/lbaas/pools/{pool_id}/members/{id}", - id = "id", - pool_id = "pool_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .pool_id("pool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member/list.rs b/openstack_sdk/src/api/load_balancer/v2/pool/member/list.rs deleted file mode 100644 index d86920b7b..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/member/list.rs +++ /dev/null @@ -1,325 +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`. - -//! Lists all members for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list members for other projects. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The IP address of the backend member server. - #[builder(default, setter(into))] - address: Option>, - - /// The administrative state of the resource - #[builder(default)] - admin_state_up: Option, - - /// Is the member a backup? - #[builder(default)] - backup: Option, - - /// The UTC date and timestamp when the resource was created. - #[builder(default, setter(into))] - created_at: Option>, - - /// A human-readable description for the resource. - #[builder(default, setter(into))] - description: Option>, - - /// The ID of the resource - #[builder(default, setter(into))] - id: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - /// An alternate IP address used for health monitoring a backend member. - #[builder(default, setter(into))] - monitor_address: Option>, - - /// An alternate protocol port used for health monitoring a backend member. - #[builder(default, setter(into))] - monitor_port: Option>, - - /// Human-readable name of the resource. - #[builder(default, setter(into))] - name: Option>, - - /// Return the list of entities that do not have one or more of the given - /// tags. - #[builder(default, setter(into))] - not_tags: Option>, - - /// Return the list of entities that do not have at least one of the given - /// tags. - #[builder(default, setter(into))] - not_tags_any: Option>, - - /// The operating status of the resource. - #[builder(default, setter(into))] - operating_status: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: Option, - - /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API - #[builder(default, setter(into))] - pool_id: Cow<'a, str>, - - /// The ID of the project owning this resource. - #[builder(default, setter(into))] - project_id: Option>, - - /// The protocol port number the backend member server is listening on. - #[builder(default)] - protocol_port: Option, - - /// The provisioning status of the resource. - #[builder(default, setter(into))] - provisioning_status: Option>, - - /// The subnet ID the member service is accessible from. - #[builder(default, setter(into))] - subnet_id: Option>, - - /// Return the list of entities that have this tag or tags. - #[builder(default, setter(into))] - tags: Option>, - - /// Return the list of entities that have one or more of the given tags. - #[builder(default, setter(into))] - tags_any: Option>, - - /// The UTC date and timestamp when the resource was last updated. - #[builder(default, setter(into))] - updated_at: Option>, - - /// The weight of a member determines the portion of requests or - /// connections it services compared to the other members of the pool. - #[builder(default)] - weight: 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> { - /// Add a single header to the Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/pools/{pool_id}/members", - pool_id = self.pool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("address", self.address.as_ref()); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("backup", self.backup); - params.push_opt("created_at", self.created_at.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("monitor_address", self.monitor_address.as_ref()); - params.push_opt("monitor_port", self.monitor_port.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("operating_status", self.operating_status.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("protocol_port", self.protocol_port); - params.push_opt("provisioning_status", self.provisioning_status.as_ref()); - params.push_opt("subnet_id", self.subnet_id.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("updated_at", self.updated_at.as_ref()); - params.push_opt("weight", self.weight); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("members".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "members" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/lbaas/pools/{pool_id}/members", - pool_id = "pool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "members": {} })); - }); - - let endpoint = Request::builder().pool_id("pool_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/lbaas/pools/{pool_id}/members", - pool_id = "pool_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "members": {} })); - }); - - let endpoint = Request::builder() - .pool_id("pool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member/replace.rs b/openstack_sdk/src/api/load_balancer/v2/pool/member/replace.rs deleted file mode 100644 index c9fb553f4..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/member/replace.rs +++ /dev/null @@ -1,347 +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`. - -//! Set the state of members for a pool in one API call. This may include -//! creating new members, deleting old members, and updating existing members. -//! Existing members are matched based on address/port combination. -//! -//! For example, assume a pool currently has two members. These members have -//! the following address/port combinations: ‘192.0.2.15:80’ and -//! ‘192.0.2.16:80’. Now assume a PUT request is made that includes members -//! with address/port combinations: ‘192.0.2.16:80’ and ‘192.0.2.17:80’. -//! -//! The member ‘192.0.2.15:80’ will be deleted, because it was not in the -//! request. -//! -//! The member ‘192.0.2.16:80’ will be updated to match the request data for -//! that member, because it was matched. -//! -//! The member ‘192.0.2.17:80’ will be created, because no such member existed. -//! -//! The optional parameter `additive_only` when defined as `true` will skip -//! deletions for members missing from the provided list. If this were set in -//! the above example, the member ‘192.0.2.15:80’ would have remained in the -//! pool. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the updates, check that the member provisioning statuses -//! are `ACTIVE` for new or updated members, and that any unspecified members -//! were correctly deleted. If the statuses are `PENDING_UPDATE` or -//! `PENDING_DELETE`, use GET to poll the member objects for changes. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines mandatory and optional attributes of a POST request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Members<'a> { - /// The IP address of the resource. - #[serde()] - #[builder(setter(into))] - pub(crate) address: Cow<'a, str>, - - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// Is the member a backup? Backup members only receive traffic when all - /// non-backup members are down. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) backup: Option, - - /// An alternate IP address used for health monitoring a backend member. - /// Default is `null` which monitors the member `address`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_address: Option>, - - /// An alternate protocol port used for health monitoring a backend member. - /// Default is `null` which monitors the member `protocol_port`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_port: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the project owning this resource. (deprecated) - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The protocol port number for the resource. - #[serde()] - #[builder(setter(into))] - pub(crate) protocol_port: i32, - - /// Request that an SR-IOV VF be used for the member network port. Defaults - /// to `false`. - /// - /// **New in version 2.29** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) request_sriov: Option, - - /// The subnet ID the member service is accessible from. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The weight of a member determines the portion of requests or - /// connections it services compared to the other members of the pool. For - /// example, a member with a weight of 10 receives five times as many - /// requests as a member with a weight of 2. A value of 0 means the member - /// does not receive new connections but continues to service existing - /// connections. A valid value is from `0` to `256`. Default is `1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) weight: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) members: Vec>, - - /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API - #[builder(default, setter(into))] - pool_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "lbaas/pools/{pool_id}/members", - pool_id = self.pool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("members", serde_json::to_value(&self.members)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("member".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .members(Vec::from([MembersBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap()])) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .members(Vec::from([MembersBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "member" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/lbaas/pools/{pool_id}/members", - pool_id = "pool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .pool_id("pool_id") - .members(Vec::from([MembersBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/lbaas/pools/{pool_id}/members", - pool_id = "pool_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .pool_id("pool_id") - .members(Vec::from([MembersBuilder::default() - .address("foo") - .protocol_port(123) - .build() - .unwrap()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member/set.rs b/openstack_sdk/src/api/load_balancer/v2/pool/member/set.rs deleted file mode 100644 index 2c533b1d5..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/member/set.rs +++ /dev/null @@ -1,296 +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`. - -//! Update an existing member. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the update, check that the member provisioning status is -//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll -//! the member object for changes. -//! -//! Setting the member weight to `0` means that the member will not receive new -//! requests but will finish any existing connections. This “drains” the -//! backend member of active connections. -//! -//! This operation returns the updated member object with the `ACTIVE`, -//! `PENDING_UPDATE`, or `ERROR` provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Defines attributes that are acceptable of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Member<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// Is the member a backup? Backup members only receive traffic when all - /// non-backup members are down. - /// - /// **New in version 2.1** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) backup: Option, - - /// An alternate IP address used for health monitoring a backend member. - /// Default is `null` which monitors the member `address`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_address: Option>, - - /// An alternate protocol port used for health monitoring a backend member. - /// Default is `null` which monitors the member `protocol_port`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) monitor_port: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// The weight of a member determines the portion of requests or - /// connections it services compared to the other members of the pool. For - /// example, a member with a weight of 10 receives five times as many - /// requests as a member with a weight of 2. A value of 0 means the member - /// does not receive new connections but continues to service existing - /// connections. A valid value is from `0` to `256`. Default is `1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) weight: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines attributes that are acceptable of a PUT request. - #[builder(setter(into))] - pub(crate) member: Member<'a>, - - /// member_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API - #[builder(default, setter(into))] - pool_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 Member. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "lbaas/pools/{pool_id}/members/{id}", - id = self.id.as_ref(), - pool_id = self.pool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("member", serde_json::to_value(&self.member)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("member".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .member(MemberBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .member(MemberBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "member" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/lbaas/pools/{pool_id}/members/{id}", - id = "id", - pool_id = "pool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .pool_id("pool_id") - .member(MemberBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/lbaas/pools/{pool_id}/members/{id}", - id = "id", - pool_id = "pool_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "member": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .pool_id("pool_id") - .member(MemberBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/set.rs b/openstack_sdk/src/api/load_balancer/v2/pool/set.rs deleted file mode 100644 index 58f12b507..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/pool/set.rs +++ /dev/null @@ -1,366 +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`. - -//! Update an existing pool. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. To confirm the update, check that the pool provisioning status is -//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll -//! the pool object for changes. -//! -//! This operation returns the updated pool object with the `ACTIVE`, -//! `PENDING_UPDATE`, or `ERROR` provisioning status. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum LbAlgorithm { - #[serde(rename = "LEAST_CONNECTIONS")] - LeastConnections, - #[serde(rename = "ROUND_ROBIN")] - RoundRobin, - #[serde(rename = "SOURCE_IP")] - SourceIp, - #[serde(rename = "SOURCE_IP_PORT")] - SourceIpPort, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "APP_COOKIE")] - AppCookie, - #[serde(rename = "HTTP_COOKIE")] - HttpCookie, - #[serde(rename = "SOURCE_IP")] - SourceIp, -} - -/// A JSON object specifying the session persistence for the pool or `null` for -/// no session persistence. See -/// [Pool Session Persistence](#session-persistence). Default is `null`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SessionPersistence<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cookie_name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_granularity: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) persistence_timeout: Option, - - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -/// Defines attributes that are acceptable of a PUT request. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Pool<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 - /// - /// **New in version 2.24** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) alpn_protocols: Option>>, - - /// The reference of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format CA certificate bundle for `tls_enabled` - /// pools. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ca_tls_container_ref: Option>, - - /// The reference of the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PEM format CA revocation list file for - /// `tls_enabled` pools. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) crl_container_ref: Option>, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The load balancing algorithm for the pool. One of `LEAST_CONNECTIONS`, - /// `ROUND_ROBIN`, or `SOURCE_IP`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) lb_algorithm: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A JSON object specifying the session persistence for the pool or `null` - /// for no session persistence. See - /// [Pool Session Persistence](#session-persistence). Default is `null`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) session_persistence: Option>, - - /// A list of simple strings assigned to the resource. - /// - /// **New in version 2.5** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// List of ciphers in OpenSSL format (colon-separated). See - /// - /// - /// **New in version 2.15** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_ciphers: Option>, - - /// The reference to the - /// [key manager service](https://docs.openstack.org/castellan/latest/) - /// secret containing a PKCS12 format certificate/key bundle for - /// `tls_enabled` pools for TLS client authentication to the member - /// servers. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_container_ref: Option>, - - /// When `true` connections to backend member servers will use TLS - /// encryption. Default is `false`. - /// - /// **New in version 2.8** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_enabled: Option, - - /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, - /// TLSv1.1, TLSv1.2, TLSv1.3 - /// - /// **New in version 2.17** - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tls_versions: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Defines attributes that are acceptable of a PUT request. - #[builder(setter(into))] - pub(crate) pool: Pool<'a>, - - /// pool_id parameter for /v2/lbaas/pools/{pool_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<'a> RequestBuilder<'a> { - /// Add a single header to the Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("lbaas/pools/{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("pool", serde_json::to_value(&self.pool)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("pool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .pool(PoolBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .pool(PoolBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "pool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/pools/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .pool(PoolBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/lbaas/pools/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "pool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .pool(PoolBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/provider/availability_zone_capability/list.rs b/openstack_sdk/src/api/load_balancer/v2/provider/availability_zone_capability/list.rs deleted file mode 100644 index 140db8d36..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/provider/availability_zone_capability/list.rs +++ /dev/null @@ -1,202 +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`. - -//! Shows the provider driver availability zone capabilities. These are the -//! features of the provider driver that can be configured in an Octavia -//! availability zone. This API returns a list of dictionaries with the name -//! and description of each availability zone capability of the provider. -//! -//! The list might be empty and a provider driver may not implement this -//! feature. -//! -//! **New in version 2.14** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// provider parameter for - /// /v2/lbaas/providers/{provider}/availability_zone_capabilities API - #[builder(default, setter(into))] - provider: 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 Availability_Zone_Capability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/providers/{provider}/availability_zone_capabilities", - provider = self.provider.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("availability_zone_capabilities".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availability_zone_capabilities" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/lbaas/providers/{provider}/availability_zone_capabilities", - provider = "provider", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_capabilities": {} })); - }); - - let endpoint = Request::builder().provider("provider").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/lbaas/providers/{provider}/availability_zone_capabilities", - provider = "provider", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zone_capabilities": {} })); - }); - - let endpoint = Request::builder() - .provider("provider") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/provider/flavor_capability/list.rs b/openstack_sdk/src/api/load_balancer/v2/provider/flavor_capability/list.rs deleted file mode 100644 index 2096edb50..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/provider/flavor_capability/list.rs +++ /dev/null @@ -1,202 +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`. - -//! Shows the provider driver flavor capabilities. These are the features of -//! the provider driver that can be configured in an Octavia flavor. This API -//! returns a list of dictionaries with the name and description of each flavor -//! capability of the provider. -//! -//! The list might be empty and a provider driver may not implement this -//! feature. -//! -//! **New in version 2.6** -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// provider parameter for - /// /v2/lbaas/providers/{provider}/flavor_capabilities API - #[builder(default, setter(into))] - provider: 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 Flavor_Capability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/providers/{provider}/flavor_capabilities", - provider = self.provider.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("flavor_capabilities".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavor_capabilities" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/lbaas/providers/{provider}/flavor_capabilities", - provider = "provider", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor_capabilities": {} })); - }); - - let endpoint = Request::builder().provider("provider").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/lbaas/providers/{provider}/flavor_capabilities", - provider = "provider", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor_capabilities": {} })); - }); - - let endpoint = Request::builder() - .provider("provider") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/provider/list.rs b/openstack_sdk/src/api/load_balancer/v2/provider/list.rs deleted file mode 100644 index 89133336c..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/provider/list.rs +++ /dev/null @@ -1,211 +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`. - -//! Lists all enabled provider drivers. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(default, setter(into))] - description: Option>, - - /// Page size - #[builder(default)] - limit: Option, - - /// ID of the last item in the previous list - #[builder(default, setter(into))] - marker: Option>, - - #[builder(default, setter(into))] - name: Option>, - - /// The page direction. - #[builder(default)] - page_reverse: 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> { - /// Add a single header to the Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("description", self.description.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("providers".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "providers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "providers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "providers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/quota/delete.rs b/openstack_sdk/src/api/load_balancer/v2/quota/delete.rs deleted file mode 100644 index 0ae5d1a13..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/quota/delete.rs +++ /dev/null @@ -1,190 +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`. - -//! Resets a project quota to use the deployment default quota. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v2/lbaas/quotas/{project_id} API - #[builder(default, setter(into))] - project_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 Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/quotas/{project_id}", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/lbaas/quotas/{project_id}", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/lbaas/quotas/{project_id}", - project_id = "project_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() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/quota/get.rs b/openstack_sdk/src/api/load_balancer/v2/quota/get.rs deleted file mode 100644 index ebccf348f..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/quota/get.rs +++ /dev/null @@ -1,203 +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 quota for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to show quota for other projects. -//! -//! A quota of `-1` means the quota is unlimited. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// project_id parameter for /v2/lbaas/quotas/{project_id} API - #[builder(default, setter(into))] - project_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 Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "lbaas/quotas/{project_id}", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("quota".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/lbaas/quotas/{project_id}", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - let endpoint = Request::builder().project_id("project_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/lbaas/quotas/{project_id}", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/quota/list.rs b/openstack_sdk/src/api/load_balancer/v2/quota/list.rs deleted file mode 100644 index 58f1a3a18..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/quota/list.rs +++ /dev/null @@ -1,192 +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`. - -//! Lists all quotas for the project. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. Additionally, you can filter results by using query -//! string parameters. For information, see -//! [Filtering and column selection](#filtering). -//! -//! Administrative users can specify a project ID that is different than their -//! own to list quotas for other projects. -//! -//! If the quota is listed as `null` the quota is using the deployment default -//! quota settings. -//! -//! A quota of `-1` means the quota is unlimited. -//! -//! The list might be empty. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas/quotas".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quotas" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas/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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/quota/set.rs b/openstack_sdk/src/api/load_balancer/v2/quota/set.rs deleted file mode 100644 index 5cae7de59..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/quota/set.rs +++ /dev/null @@ -1,291 +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`. - -//! Updates a quota for a project. -//! -//! If the request is valid, the service returns the `Accepted (202)` response -//! code. -//! -//! This operation returns the updated quota object. -//! -//! If the quota is specified as `null` the quota will use the deployment -//! default quota settings. -//! -//! Specifying a quota of `-1` means the quota is unlimited. -//! -//! Specifying a quota of `0` means the project cannot create any of the -//! resource. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// Individual quota definitions. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Quota { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) health_monitor: Option, - - /// The configured health monitor quota limit. A setting of `null` means it - /// is using the deployment default quota. A setting of `-1` means - /// unlimited. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) healthmonitor: Option, - - /// The configured l7policy quota limit. A setting of `null` means it is - /// using the deployment default quota. A setting of `-1` means unlimited. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) l7policy: Option, - - /// The configured l7rule quota limit. A setting of `null` means it is - /// using the deployment default quota. A setting of `-1` means unlimited. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) l7rule: Option, - - /// The configured listener quota limit. A setting of `null` means it is - /// using the deployment default quota. A setting of `-1` means unlimited. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) listener: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) load_balancer: Option, - - /// The configured load balancer quota limit. A setting of `null` means it - /// is using the deployment default quota. A setting of `-1` means - /// unlimited. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) loadbalancer: Option, - - /// The configured member quota limit. A setting of `null` means it is - /// using the deployment default quota. A setting of `-1` means unlimited. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) member: Option, - - /// The configured pool quota limit. A setting of `null` means it is using - /// the deployment default quota. A setting of `-1` means unlimited. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) pool: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Individual quota definitions. - #[builder(setter(into))] - pub(crate) quota: Quota, - - /// project_id parameter for /v2/lbaas/quotas/{project_id} API - #[builder(default, setter(into))] - project_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 Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "lbaas/quotas/{project_id}", - project_id = self.project_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("quota", serde_json::to_value(&self.quota)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - fn response_key(&self) -> Option> { - Some("quota".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota(QuotaBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota(QuotaBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/lbaas/quotas/{project_id}", - project_id = "project_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .quota(QuotaBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/lbaas/quotas/{project_id}", - project_id = "project_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .project_id("project_id") - .quota(QuotaBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/load_balancer/v2/version/get.rs b/openstack_sdk/src/api/load_balancer/v2/version/get.rs deleted file mode 100644 index 22574f4b4..000000000 --- a/openstack_sdk/src/api/load_balancer/v2/version/get.rs +++ /dev/null @@ -1,172 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "lbaas".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::LoadBalancer - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::LoadBalancer - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/lbaas".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network.rs b/openstack_sdk/src/api/network.rs index f5008f3d8..7a2d88f32 100644 --- a/openstack_sdk/src/api/network.rs +++ b/openstack_sdk/src/api/network.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Network API (Neutron) bindings -pub mod v2; +//! # Network API (Neutron) bindings +pub use openstack_sdk_network::*; diff --git a/openstack_sdk/src/api/network/v2/address_group/create.rs b/openstack_sdk/src/api/network/v2/address_group/create.rs deleted file mode 100644 index 8784c3ffd..000000000 --- a/openstack_sdk/src/api/network/v2/address_group/create.rs +++ /dev/null @@ -1,234 +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`. - -//! Creates an address group. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// An `address group` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AddressGroup<'a> { - /// A list of IP addresses. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) addresses: Option>>, - - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `address group` object. - #[builder(setter(into))] - pub(crate) address_group: AddressGroup<'a>, - - #[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 Address_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "address-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("address_group", serde_json::to_value(&self.address_group)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .address_group(AddressGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .address_group(AddressGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "address_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/address-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_group": {} })); - }); - - let endpoint = Request::builder() - .address_group(AddressGroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/address-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_group": {} })); - }); - - let endpoint = Request::builder() - .address_group(AddressGroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_group/delete.rs b/openstack_sdk/src/api/network/v2/address_group/delete.rs deleted file mode 100644 index d2ac1e77d..000000000 --- a/openstack_sdk/src/api/network/v2/address_group/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes an address group. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/address-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Address_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("address-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/address-groups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/address-groups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_group/find.rs b/openstack_sdk/src/api/network/v2/address_group/find.rs deleted file mode 100644 index b2c2d9965..000000000 --- a/openstack_sdk/src/api/network/v2/address_group/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::address_group::{get as Get, list as List}; - -/// Find for address_group 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/address_group/get.rs b/openstack_sdk/src/api/network/v2/address_group/get.rs deleted file mode 100644 index 1fd0ee73d..000000000 --- a/openstack_sdk/src/api/network/v2/address_group/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows information for an address group. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/address-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Address_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("address-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "address_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/address-groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_group": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/address-groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_group/list.rs b/openstack_sdk/src/api/network/v2/address_group/list.rs deleted file mode 100644 index 8e28e60f8..000000000 --- a/openstack_sdk/src/api/network/v2/address_group/list.rs +++ /dev/null @@ -1,293 +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`. - -//! Lists address groups that the project has access to. -//! -//! Default policy settings return only the address groups owned by the project -//! of the user submitting the request, unless the user has administrative -//! role. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/address-groups API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/address-groups API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/address-groups API - #[builder(default, setter(into))] - name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// project_id query parameter for /v2.0/address-groups API - #[builder(default, setter(into))] - project_id: Option>, - - /// revision_number query parameter for /v2.0/address-groups API - #[builder(default, setter(into))] - revision_number: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Address_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "address-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_groups".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "address_groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/address-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/address-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_group/set.rs b/openstack_sdk/src/api/network/v2/address_group/set.rs deleted file mode 100644 index dc4671c69..000000000 --- a/openstack_sdk/src/api/network/v2/address_group/set.rs +++ /dev/null @@ -1,231 +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`. - -//! Updates an address group. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// An `address group` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AddressGroup<'a> { - /// A human-readable description for the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `address group` object. - #[builder(setter(into))] - pub(crate) address_group: AddressGroup<'a>, - - /// id parameter for /v2.0/address-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Address_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("address-groups/{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("address_group", serde_json::to_value(&self.address_group)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .address_group(AddressGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .address_group(AddressGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "address_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/address-groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .address_group(AddressGroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/address-groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .address_group(AddressGroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_scope/create.rs b/openstack_sdk/src/api/network/v2/address_scope/create.rs deleted file mode 100644 index 4c7902c18..000000000 --- a/openstack_sdk/src/api/network/v2/address_scope/create.rs +++ /dev/null @@ -1,238 +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`. - -//! Creates an address scope. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// An `address scope` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AddressScope<'a> { - /// The IP protocol version. Valid value is `4` or `6`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_version: Option, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Indicates whether this resource is shared across all projects. By - /// default, only administrative users can change this value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `address scope` object. - #[builder(setter(into))] - pub(crate) address_scope: AddressScope<'a>, - - #[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 Address_Scope. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "address-scopes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("address_scope", serde_json::to_value(&self.address_scope)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_scope".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "address_scope" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/address-scopes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scope": {} })); - }); - - let endpoint = Request::builder() - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/address-scopes".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scope": {} })); - }); - - let endpoint = Request::builder() - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_scope/delete.rs b/openstack_sdk/src/api/network/v2/address_scope/delete.rs deleted file mode 100644 index 799609128..000000000 --- a/openstack_sdk/src/api/network/v2/address_scope/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes an address scope. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/address-scopes/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Address_Scope. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("address-scopes/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/address-scopes/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/address-scopes/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_scope/find.rs b/openstack_sdk/src/api/network/v2/address_scope/find.rs deleted file mode 100644 index 83b47a276..000000000 --- a/openstack_sdk/src/api/network/v2/address_scope/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::address_scope::{get as Get, list as List}; - -/// Find for address_scope 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/address_scope/get.rs b/openstack_sdk/src/api/network/v2/address_scope/get.rs deleted file mode 100644 index 8dfa3d284..000000000 --- a/openstack_sdk/src/api/network/v2/address_scope/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows information for an address scope. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/address-scopes/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Address_Scope. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("address-scopes/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_scope".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "address_scope" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/address-scopes/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scope": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/address-scopes/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scope": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_scope/list.rs b/openstack_sdk/src/api/network/v2/address_scope/list.rs deleted file mode 100644 index 11bf17f5d..000000000 --- a/openstack_sdk/src/api/network/v2/address_scope/list.rs +++ /dev/null @@ -1,293 +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`. - -//! Lists address scopes that the project has access to. -//! -//! Default policy settings return only the address scopes owned by the project -//! of the user submitting the request, unless the user has administrative -//! role. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id query parameter for /v2.0/address-scopes API - #[builder(default, setter(into))] - id: Option>, - - /// ip_version query parameter for /v2.0/address-scopes API - #[builder(default)] - ip_version: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/address-scopes API - #[builder(default, setter(into))] - name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// shared query parameter for /v2.0/address-scopes API - #[builder(default)] - shared: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tenant_id query parameter for /v2.0/address-scopes API - #[builder(default, setter(into))] - tenant_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Address_Scope. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "address-scopes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("id", self.id.as_ref()); - params.push_opt("ip_version", self.ip_version); - params.push_opt("name", self.name.as_ref()); - params.push_opt("shared", self.shared); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_scopes".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "address_scopes" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/address-scopes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scopes": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/address-scopes".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scopes": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/address_scope/set.rs b/openstack_sdk/src/api/network/v2/address_scope/set.rs deleted file mode 100644 index 7b81670a2..000000000 --- a/openstack_sdk/src/api/network/v2/address_scope/set.rs +++ /dev/null @@ -1,232 +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`. - -//! Updates an address scope. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// An `address scope` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AddressScope<'a> { - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Indicates whether this resource is shared across all projects. By - /// default, only administrative users can change this value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `address scope` object. - #[builder(setter(into))] - pub(crate) address_scope: AddressScope<'a>, - - /// id parameter for /v2.0/address-scopes/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Address_Scope. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("address-scopes/{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("address_scope", serde_json::to_value(&self.address_scope)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("address_scope".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "address_scope" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/address-scopes/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scope": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/address-scopes/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "address_scope": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .address_scope(AddressScopeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/create.rs b/openstack_sdk/src/api/network/v2/agent/create.rs deleted file mode 100644 index a94419adc..000000000 --- a/openstack_sdk/src/api/network/v2/agent/create.rs +++ /dev/null @@ -1,214 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_agent"))] - pub(crate) agent: BTreeMap, Value>, - - #[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 agent(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.agent - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "agents".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("agent", serde_json::to_value(&self.agent)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("agent".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .agent(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .agent(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "agent" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/agents".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agent": {} })); - }); - - let endpoint = Request::builder() - .agent(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/agents".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agent": {} })); - }); - - let endpoint = Request::builder() - .agent(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/delete.rs b/openstack_sdk/src/api/network/v2/agent/delete.rs deleted file mode 100644 index aa9a105b4..000000000 --- a/openstack_sdk/src/api/network/v2/agent/delete.rs +++ /dev/null @@ -1,186 +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`. - -//! Agents that won’t be used anymore can be removed. Before deleting agents -//! via API, the agent should be stopped/disabled. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/agents/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("agents/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/agents/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/agents/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/dhcp_network/create.rs b/openstack_sdk/src/api/network/v2/agent/dhcp_network/create.rs deleted file mode 100644 index e10a2c80b..000000000 --- a/openstack_sdk/src/api/network/v2/agent/dhcp_network/create.rs +++ /dev/null @@ -1,221 +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`. - -//! Add a network to a DHCP agent -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 403, 409, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Dhcp_Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "agents/{agent_id}/dhcp-networks", - agent_id = self.agent_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/agents/{agent_id}/dhcp-networks", - agent_id = "agent_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().agent_id("agent_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/agents/{agent_id}/dhcp-networks", - agent_id = "agent_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() - .agent_id("agent_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/dhcp_network/delete.rs b/openstack_sdk/src/api/network/v2/agent/dhcp_network/delete.rs deleted file mode 100644 index 2d6d21c4a..000000000 --- a/openstack_sdk/src/api/network/v2/agent/dhcp_network/delete.rs +++ /dev/null @@ -1,206 +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`. - -//! Removes a network from a dhcp agent. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Dhcp_Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "agents/{agent_id}/dhcp-networks/{id}", - agent_id = self.agent_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/agents/{agent_id}/dhcp-networks/{id}", - agent_id = "agent_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .agent_id("agent_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/agents/{agent_id}/dhcp-networks/{id}", - agent_id = "agent_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() - .agent_id("agent_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/dhcp_network/get.rs b/openstack_sdk/src/api/network/v2/agent/dhcp_network/get.rs deleted file mode 100644 index dc2803f3d..000000000 --- a/openstack_sdk/src/api/network/v2/agent/dhcp_network/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Dhcp_Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "agents/{agent_id}/dhcp-networks/{id}", - agent_id = self.agent_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/agents/{agent_id}/dhcp-networks/{id}", - agent_id = "agent_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .agent_id("agent_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/agents/{agent_id}/dhcp-networks/{id}", - agent_id = "agent_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() - .agent_id("agent_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/dhcp_network/list.rs b/openstack_sdk/src/api/network/v2/agent/dhcp_network/list.rs deleted file mode 100644 index bfc51f4c4..000000000 --- a/openstack_sdk/src/api/network/v2/agent/dhcp_network/list.rs +++ /dev/null @@ -1,275 +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`. - -//! Lists networks that a DHCP agent hosts. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Dhcp_Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "agents/{agent_id}/dhcp-networks", - agent_id = self.agent_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/agents/{agent_id}/dhcp-networks", - agent_id = "agent_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().agent_id("agent_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/agents/{agent_id}/dhcp-networks", - agent_id = "agent_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() - .agent_id("agent_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/dhcp_network/set.rs b/openstack_sdk/src/api/network/v2/agent/dhcp_network/set.rs deleted file mode 100644 index f7f742479..000000000 --- a/openstack_sdk/src/api/network/v2/agent/dhcp_network/set.rs +++ /dev/null @@ -1,227 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Dhcp_Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "agents/{agent_id}/dhcp-networks/{id}", - agent_id = self.agent_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/agents/{agent_id}/dhcp-networks/{id}", - agent_id = "agent_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .agent_id("agent_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/agents/{agent_id}/dhcp-networks/{id}", - agent_id = "agent_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() - .agent_id("agent_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/get.rs b/openstack_sdk/src/api/network/v2/agent/get.rs deleted file mode 100644 index 1a9f3ccdd..000000000 --- a/openstack_sdk/src/api/network/v2/agent/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for an agent. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/agents/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("agents/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("agent".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "agent" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/agents/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agent": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/agents/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agent": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/l3_router/create.rs b/openstack_sdk/src/api/network/v2/agent/l3_router/create.rs deleted file mode 100644 index a8b200c49..000000000 --- a/openstack_sdk/src/api/network/v2/agent/l3_router/create.rs +++ /dev/null @@ -1,222 +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`. - -//! Add a router to an l3 agent. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The ID of the router. - #[builder(setter(into))] - pub(crate) router_id: Cow<'a, str>, - - /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API - #[builder(default, setter(into))] - agent_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 L3_Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "agents/{agent_id}/l3-routers", - agent_id = self.agent_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("router_id", serde_json::to_value(&self.router_id)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .router_id("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .router_id("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/agents/{agent_id}/l3-routers", - agent_id = "agent_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .agent_id("agent_id") - .router_id("foo") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/agents/{agent_id}/l3-routers", - agent_id = "agent_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() - .agent_id("agent_id") - .router_id("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/l3_router/delete.rs b/openstack_sdk/src/api/network/v2/agent/l3_router/delete.rs deleted file mode 100644 index 3f847209d..000000000 --- a/openstack_sdk/src/api/network/v2/agent/l3_router/delete.rs +++ /dev/null @@ -1,206 +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`. - -//! Removes a router from an l3 agent. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// id parameter for /v2.0/agents/{agent_id}/l3-routers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the L3_Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "agents/{agent_id}/l3-routers/{id}", - agent_id = self.agent_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/agents/{agent_id}/l3-routers/{id}", - agent_id = "agent_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .agent_id("agent_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/agents/{agent_id}/l3-routers/{id}", - agent_id = "agent_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() - .agent_id("agent_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/l3_router/get.rs b/openstack_sdk/src/api/network/v2/agent/l3_router/get.rs deleted file mode 100644 index c870fd59d..000000000 --- a/openstack_sdk/src/api/network/v2/agent/l3_router/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// id parameter for /v2.0/agents/{agent_id}/l3-routers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the L3_Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "agents/{agent_id}/l3-routers/{id}", - agent_id = self.agent_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/agents/{agent_id}/l3-routers/{id}", - agent_id = "agent_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .agent_id("agent_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/agents/{agent_id}/l3-routers/{id}", - agent_id = "agent_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() - .agent_id("agent_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/l3_router/list.rs b/openstack_sdk/src/api/network/v2/agent/l3_router/list.rs deleted file mode 100644 index e0301a8c1..000000000 --- a/openstack_sdk/src/api/network/v2/agent/l3_router/list.rs +++ /dev/null @@ -1,275 +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`. - -//! Lists routers that an l3 agent hosts. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the L3_Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "agents/{agent_id}/l3-routers", - agent_id = self.agent_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/agents/{agent_id}/l3-routers", - agent_id = "agent_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().agent_id("agent_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/agents/{agent_id}/l3-routers", - agent_id = "agent_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() - .agent_id("agent_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/l3_router/set.rs b/openstack_sdk/src/api/network/v2/agent/l3_router/set.rs deleted file mode 100644 index cca2b6a8b..000000000 --- a/openstack_sdk/src/api/network/v2/agent/l3_router/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API - #[builder(default, setter(into))] - agent_id: Cow<'a, str>, - - /// id parameter for /v2.0/agents/{agent_id}/l3-routers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the L3_Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "agents/{agent_id}/l3-routers/{id}", - agent_id = self.agent_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/agents/{agent_id}/l3-routers/{id}", - agent_id = "agent_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .agent_id("agent_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/agents/{agent_id}/l3-routers/{id}", - agent_id = "agent_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() - .agent_id("agent_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/list.rs b/openstack_sdk/src/api/network/v2/agent/list.rs deleted file mode 100644 index eed810d18..000000000 --- a/openstack_sdk/src/api/network/v2/agent/list.rs +++ /dev/null @@ -1,309 +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`. - -//! Lists all agents. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// admin_state_up query parameter for /v2.0/agents API - #[builder(default)] - admin_state_up: Option, - - /// agent_type query parameter for /v2.0/agents API - #[builder(default, setter(into))] - agent_type: Option>, - - /// alive query parameter for /v2.0/agents API - #[builder(default, setter(into))] - alive: Option>, - - /// availability_zone query parameter for /v2.0/agents API - #[builder(default, setter(into))] - availability_zone: Option>, - - /// binary query parameter for /v2.0/agents API - #[builder(default, setter(into))] - binary: Option>, - - /// description query parameter for /v2.0/agents API - #[builder(default, setter(into))] - description: Option>, - - /// host query parameter for /v2.0/agents API - #[builder(default, setter(into))] - host: Option>, - - /// id query parameter for /v2.0/agents API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// topic query parameter for /v2.0/agents API - #[builder(default, setter(into))] - topic: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "agents".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("agent_type", self.agent_type.as_ref()); - params.push_opt("alive", self.alive.as_ref()); - params.push_opt("availability_zone", self.availability_zone.as_ref()); - params.push_opt("binary", self.binary.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("host", self.host.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("topic", self.topic.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("agents".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "agents" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/agents".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agents": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/agents".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agents": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/agent/set.rs b/openstack_sdk/src/api/network/v2/agent/set.rs deleted file mode 100644 index 69dbb0b89..000000000 --- a/openstack_sdk/src/api/network/v2/agent/set.rs +++ /dev/null @@ -1,231 +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`. - -//! Updates an agent. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Agent<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) agent: Agent<'a>, - - /// id parameter for /v2.0/agents/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("agents/{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("agent", serde_json::to_value(&self.agent)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("agent".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .agent(AgentBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .agent(AgentBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "agent" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/agents/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agent": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .agent(AgentBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/agents/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "agent": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .agent(AgentBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/auto_allocated_topology/create.rs b/openstack_sdk/src/api/network/v2/auto_allocated_topology/create.rs deleted file mode 100644 index 82cb19d95..000000000 --- a/openstack_sdk/src/api/network/v2/auto_allocated_topology/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_auto_allocated_topology"))] - pub(crate) auto_allocated_topology: BTreeMap, Value>, - - #[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 auto_allocated_topology(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.auto_allocated_topology - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Auto_Allocated_Topology. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auto-allocated-topology".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "auto_allocated_topology", - serde_json::to_value(&self.auto_allocated_topology)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("auto_allocated_topology".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "auto_allocated_topology" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auto-allocated-topology".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topology": {} })); - }); - - let endpoint = Request::builder() - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auto-allocated-topology".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topology": {} })); - }); - - let endpoint = Request::builder() - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/auto_allocated_topology/delete.rs b/openstack_sdk/src/api/network/v2/auto_allocated_topology/delete.rs deleted file mode 100644 index bf2b21d8e..000000000 --- a/openstack_sdk/src/api/network/v2/auto_allocated_topology/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes the auto allocated topology. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/auto-allocated-topology/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Auto_Allocated_Topology. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("auto-allocated-topology/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/auto-allocated-topology/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/auto-allocated-topology/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/auto_allocated_topology/get.rs b/openstack_sdk/src/api/network/v2/auto_allocated_topology/get.rs deleted file mode 100644 index 07027f649..000000000 --- a/openstack_sdk/src/api/network/v2/auto_allocated_topology/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for an auto allocated topology. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/auto-allocated-topology/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Auto_Allocated_Topology. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("auto-allocated-topology/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("auto_allocated_topology".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "auto_allocated_topology" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/auto-allocated-topology/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topology": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/auto-allocated-topology/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topology": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/auto_allocated_topology/list.rs b/openstack_sdk/src/api/network/v2/auto_allocated_topology/list.rs deleted file mode 100644 index c0bfcb6c9..000000000 --- a/openstack_sdk/src/api/network/v2/auto_allocated_topology/list.rs +++ /dev/null @@ -1,245 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Auto_Allocated_Topology. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "auto-allocated-topology".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("auto_allocated_topologies".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "auto_allocated_topologies" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auto-allocated-topology".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topologies": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/auto-allocated-topology".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topologies": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/auto_allocated_topology/set.rs b/openstack_sdk/src/api/network/v2/auto_allocated_topology/set.rs deleted file mode 100644 index 533688326..000000000 --- a/openstack_sdk/src/api/network/v2/auto_allocated_topology/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_auto_allocated_topology"))] - pub(crate) auto_allocated_topology: BTreeMap, Value>, - - /// id parameter for /v2.0/auto-allocated-topology/{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<'a> RequestBuilder<'a> { - pub fn auto_allocated_topology(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.auto_allocated_topology - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Auto_Allocated_Topology. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("auto-allocated-topology/{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( - "auto_allocated_topology", - serde_json::to_value(&self.auto_allocated_topology)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("auto_allocated_topology".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "auto_allocated_topology" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/auto-allocated-topology/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topology": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/auto-allocated-topology/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "auto_allocated_topology": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .auto_allocated_topology(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/availability_zone/list.rs b/openstack_sdk/src/api/network/v2/availability_zone/list.rs deleted file mode 100644 index 68d73077c..000000000 --- a/openstack_sdk/src/api/network/v2/availability_zone/list.rs +++ /dev/null @@ -1,279 +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`. - -//! Lists all availability zones. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/availability_zones API - #[builder(default, setter(into))] - name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// resource query parameter for /v2.0/availability_zones API - #[builder(default, setter(into))] - resource: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// state query parameter for /v2.0/availability_zones API - #[builder(default, setter(into))] - state: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Availability_Zone. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "availability_zones".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("name", self.name.as_ref()); - params.push_opt("resource", self.resource.as_ref()); - params.push_opt("state", self.state.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("availability_zones".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "availability_zones" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/availability_zones".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zones": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/availability_zones".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "availability_zones": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/default_security_group_rule/create.rs b/openstack_sdk/src/api/network/v2/default_security_group_rule/create.rs deleted file mode 100644 index 39dc7593a..000000000 --- a/openstack_sdk/src/api/network/v2/default_security_group_rule/create.rs +++ /dev/null @@ -1,324 +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`. - -//! Creates an Openstack Networking security group rule template. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Ethertype { - #[serde(rename = "IPv4")] - Ipv4, - #[serde(rename = "IPv6")] - Ipv6, -} - -/// A `default_security_group_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct DefaultSecurityGroupRule<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Ingress or egress, which is the direction in which the security group - /// rule is applied. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - /// Must be IPv4 or IPv6, and addresses represented in CIDR must match the - /// ingress or egress rules. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) ethertype: Option, - - /// The maximum port number in the range that is matched by the security - /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this - /// value must be greater than or equal to the `port_range_min` attribute - /// value. If the protocol is ICMP, this value must be an ICMP code. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_range_max: Option>, - - /// The minimum port number in the range that is matched by the security - /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this - /// value must be less than or equal to the `port_range_max` attribute - /// value. If the protocol is ICMP, this value must be an ICMP type. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_range_min: Option>, - - /// The IP protocol can be represented by a string, an integer, or `null`. - /// Valid string or integer values are `any` or `0`, `ah` or `51`, `dccp` - /// or `33`, `egp` or `8`, `esp` or `50`, `gre` or `47`, `icmp` or `1`, - /// `icmpv6` or `58`, `igmp` or `2`, `ipip` or `4`, `ipv6-encap` or `41`, - /// `ipv6-frag` or `44`, `ipv6-icmp` or `58`, `ipv6-nonxt` or `59`, - /// `ipv6-opts` or `60`, `ipv6-route` or `43`, `ospf` or `89`, `pgm` or - /// `113`, `rsvp` or `46`, `sctp` or `132`, `tcp` or `6`, `udp` or `17`, - /// `udplite` or `136`, `vrrp` or `112`. Additionally, any integer value - /// between [0-255] is also valid. The string `any` (or integer `0`) means - /// `all` IP protocols. See the constants in `neutron_lib.constants` for - /// the most up-to-date list of supported strings. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) protocol: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_address_group_id: Option>, - - /// The remote group UUID to associate with this security group rule. You - /// can specify either the `remote_group_id` or `remote_ip_prefix` - /// attribute in the request body. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_group_id: Option>, - - /// The remote IP prefix that is matched by this security group rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_ip_prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// Whether this security group rule template should be used in default - /// security group created automatically for each new project. Default - /// value is `False`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) used_in_default_sg: Option, - - /// Whether this security group rule template should be used in custom - /// security groups created by project user. Default value is `True`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) used_in_non_default_sg: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `default_security_group_rule` object. - #[builder(setter(into))] - pub(crate) default_security_group_rule: DefaultSecurityGroupRule<'a>, - - #[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 Default_Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "default-security-group-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "default_security_group_rule", - serde_json::to_value(&self.default_security_group_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("default_security_group_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .default_security_group_rule( - DefaultSecurityGroupRuleBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .default_security_group_rule( - DefaultSecurityGroupRuleBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "default_security_group_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/default-security-group-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .default_security_group_rule( - DefaultSecurityGroupRuleBuilder::default().build().unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/default-security-group-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .default_security_group_rule( - DefaultSecurityGroupRuleBuilder::default().build().unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/default_security_group_rule/delete.rs b/openstack_sdk/src/api/network/v2/default_security_group_rule/delete.rs deleted file mode 100644 index bbb114839..000000000 --- a/openstack_sdk/src/api/network/v2/default_security_group_rule/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes an OpenStack Networking security group rule template. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/default-security-group-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Default_Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("default-security-group-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/default-security-group-rules/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/default-security-group-rules/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/default_security_group_rule/get.rs b/openstack_sdk/src/api/network/v2/default_security_group_rule/get.rs deleted file mode 100644 index f1d24c774..000000000 --- a/openstack_sdk/src/api/network/v2/default_security_group_rule/get.rs +++ /dev/null @@ -1,194 +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`. - -//! Shows detailed information for a security group default rule. -//! -//! The response body contains the following information about the security -//! group rule: -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/default-security-group-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Default_Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("default-security-group-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("default_security_group_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "default_security_group_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/default-security-group-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rule": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/default-security-group-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/default_security_group_rule/list.rs b/openstack_sdk/src/api/network/v2/default_security_group_rule/list.rs deleted file mode 100644 index 750303f6b..000000000 --- a/openstack_sdk/src/api/network/v2/default_security_group_rule/list.rs +++ /dev/null @@ -1,340 +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`. - -//! Lists a summary of all OpenStack Networking security group rules that are -//! used for every newly created Security Group. -//! -//! The list provides the ID for each security group default rule. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/default-security-group-rules API - #[builder(default, setter(into))] - description: Option>, - - /// direction query parameter for /v2.0/default-security-group-rules API - #[builder(default, setter(into))] - direction: Option>, - - /// ethertype query parameter for /v2.0/default-security-group-rules API - #[builder(default, setter(into))] - ethertype: Option>, - - /// id query parameter for /v2.0/default-security-group-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// port_range_max query parameter for /v2.0/default-security-group-rules - /// API - #[builder(default)] - port_range_max: Option, - - /// port_range_min query parameter for /v2.0/default-security-group-rules - /// API - #[builder(default)] - port_range_min: Option, - - /// protocol query parameter for /v2.0/default-security-group-rules API - #[builder(default, setter(into))] - protocol: Option>, - - /// remote_address_group_id query parameter for - /// /v2.0/default-security-group-rules API - #[builder(default, setter(into))] - remote_address_group_id: Option>, - - /// Filter the security group rule list result by the ID of the remote - /// group that associates with this security group rule. This field can - /// contains uuid of the security group or special word `PARENT` which - /// means that in the real rule created from this template, uuid of the - /// owner Security Group will be put as `remote_group_id`. - #[builder(default, setter(into))] - remote_group_id: Option>, - - /// remote_ip_prefix query parameter for /v2.0/default-security-group-rules - /// API - #[builder(default, setter(into))] - remote_ip_prefix: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// used_in_default_sg query parameter for - /// /v2.0/default-security-group-rules API - #[builder(default)] - used_in_default_sg: Option, - - /// used_in_non_default_sg query parameter for - /// /v2.0/default-security-group-rules API - #[builder(default)] - used_in_non_default_sg: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Default_Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "default-security-group-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("description", self.description.as_ref()); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("ethertype", self.ethertype.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("port_range_max", self.port_range_max); - params.push_opt("port_range_min", self.port_range_min); - params.push_opt("protocol", self.protocol.as_ref()); - params.push_opt( - "remote_address_group_id", - self.remote_address_group_id.as_ref(), - ); - params.push_opt("remote_group_id", self.remote_group_id.as_ref()); - params.push_opt("remote_ip_prefix", self.remote_ip_prefix.as_ref()); - params.push_opt("used_in_default_sg", self.used_in_default_sg); - params.push_opt("used_in_non_default_sg", self.used_in_non_default_sg); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("default_security_group_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "default_security_group_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/default-security-group-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rules": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/default-security-group-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rules": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/default_security_group_rule/set.rs b/openstack_sdk/src/api/network/v2/default_security_group_rule/set.rs deleted file mode 100644 index 546aeb244..000000000 --- a/openstack_sdk/src/api/network/v2/default_security_group_rule/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_default_security_group_rule"))] - pub(crate) default_security_group_rule: BTreeMap, Value>, - - /// id parameter for /v2.0/default-security-group-rules/{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<'a> RequestBuilder<'a> { - pub fn default_security_group_rule(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.default_security_group_rule - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Default_Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("default-security-group-rules/{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( - "default_security_group_rule", - serde_json::to_value(&self.default_security_group_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("default_security_group_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .default_security_group_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .default_security_group_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "default_security_group_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/default-security-group-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .default_security_group_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/default-security-group-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "default_security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .default_security_group_rule(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/extension/get.rs b/openstack_sdk/src/api/network/v2/extension/get.rs deleted file mode 100644 index ef649dcd5..000000000 --- a/openstack_sdk/src/api/network/v2/extension/get.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows details for an extension, by alias. The response shows the extension -//! name and its alias. To show details for an extension, you specify the -//! alias. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/extensions/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Extension. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("extensions/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("extension".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "extension" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/extensions/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extension": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/extensions/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extension": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/extension/list.rs b/openstack_sdk/src/api/network/v2/extension/list.rs deleted file mode 100644 index 3548f6ccc..000000000 --- a/openstack_sdk/src/api/network/v2/extension/list.rs +++ /dev/null @@ -1,196 +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`. - -//! Lists available extensions. -//! -//! Lists available Networking API v2.0 extensions. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Extension. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "extensions".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("extensions".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "extensions" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/extensions".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extensions": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/extensions".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "extensions": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/create.rs b/openstack_sdk/src/api/network/v2/flavor/create.rs deleted file mode 100644 index 44307d314..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/create.rs +++ /dev/null @@ -1,261 +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`. - -//! Creates a flavor. -//! -//! This operation establishes a new flavor. -//! -//! The service_type to which the flavor applies is a required parameter. The -//! corresponding service plugin must have been activated as part of the -//! configuration. Check [Service providers](#list-service-providers) for how -//! to see currently loaded service types. Additionally the service plugin -//! needs to support the use of flavors. -//! -//! Creation currently limited to administrators. Other users will receive a -//! `Forbidden 403` response code with a response body NeutronError message -//! expressing that creation is disallowed by policy. -//! -//! Until one or more service profiles are associated with the flavor by the -//! operator, attempts to use the flavor during resource creations will -//! currently return a `Not Found 404` with a response body that indicates no -//! service profile could be found. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `flavor` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavor<'a> { - /// The human-readable description for the flavor. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Indicates whether the flavor is enabled or not. Default is true. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option>, - - /// Name of the flavor. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_profiles: Option>>, - - /// Service type for the flavor. Example: FIREWALL. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_type: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `flavor` object. - #[builder(setter(into))] - pub(crate) flavor: Flavor<'a>, - - #[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 Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "flavors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("flavor", serde_json::to_value(&self.flavor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/flavors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/flavors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/delete.rs b/openstack_sdk/src/api/network/v2/flavor/delete.rs deleted file mode 100644 index 99b51d0df..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a flavor. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/flavors/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("flavors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/flavors/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/flavors/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/find.rs b/openstack_sdk/src/api/network/v2/flavor/find.rs deleted file mode 100644 index 0bcabb28e..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::flavor::{get as Get, list as List}; - -/// Find for flavor 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/get.rs b/openstack_sdk/src/api/network/v2/flavor/get.rs deleted file mode 100644 index 22f7ed7cf..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/get.rs +++ /dev/null @@ -1,195 +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`. - -//! Shows details for a flavor. -//! -//! This operation returns a flavor object by ID. If you are not an -//! administrative user and the flavor object is not visible to your project -//! account, the service returns the HTTP `Forbidden (403)` response code. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/flavors/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("flavors/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/flavors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/flavors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/list.rs b/openstack_sdk/src/api/network/v2/flavor/list.rs deleted file mode 100644 index 753a91fe3..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/list.rs +++ /dev/null @@ -1,291 +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`. - -//! Lists all flavors visible to the project. -//! -//! The list can be empty. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/flavors API - #[builder(default, setter(into))] - description: Option>, - - /// enabled query parameter for /v2.0/flavors API - #[builder(default)] - enabled: Option, - - /// id query parameter for /v2.0/flavors API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/flavors API - #[builder(default, setter(into))] - name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// service_type query parameter for /v2.0/flavors API - #[builder(default, setter(into))] - service_type: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "flavors".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("description", self.description.as_ref()); - params.push_opt("enabled", self.enabled); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("service_type", self.service_type.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("flavors".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "flavors" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/flavors".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/flavors".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavors": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/next_provider/create.rs b/openstack_sdk/src/api/network/v2/flavor/next_provider/create.rs deleted file mode 100644 index a0a064270..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/next_provider/create.rs +++ /dev/null @@ -1,231 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_next_provider"))] - pub(crate) next_provider: BTreeMap, Value>, - - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} - /// API - #[builder(default, setter(into))] - flavor_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> { - pub fn next_provider(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.next_provider - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Next_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "flavors/{flavor_id}/next_providers", - flavor_id = self.flavor_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("next_provider", serde_json::to_value(&self.next_provider)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("next_provider".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .next_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .next_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "next_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/flavors/{flavor_id}/next_providers", - flavor_id = "flavor_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_provider": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .next_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/flavors/{flavor_id}/next_providers", - flavor_id = "flavor_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_provider": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .next_provider(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/next_provider/delete.rs b/openstack_sdk/src/api/network/v2/flavor/next_provider/delete.rs deleted file mode 100644 index 205865652..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/next_provider/delete.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.0/flavors/{flavor_id}/next_providers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Next_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/next_providers/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/flavors/{flavor_id}/next_providers/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/flavors/{flavor_id}/next_providers/{id}", - flavor_id = "flavor_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() - .flavor_id("flavor_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/next_provider/get.rs b/openstack_sdk/src/api/network/v2/flavor/next_provider/get.rs deleted file mode 100644 index 954d1a6d1..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/next_provider/get.rs +++ /dev/null @@ -1,204 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.0/flavors/{flavor_id}/next_providers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Next_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/next_providers/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("next_provider".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "next_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/flavors/{flavor_id}/next_providers/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_provider": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/flavors/{flavor_id}/next_providers/{id}", - flavor_id = "flavor_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_provider": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/next_provider/list.rs b/openstack_sdk/src/api/network/v2/flavor/next_provider/list.rs deleted file mode 100644 index 017cbab13..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/next_provider/list.rs +++ /dev/null @@ -1,260 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Next_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/next_providers", - flavor_id = self.flavor_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("next_providers".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "next_providers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/flavors/{flavor_id}/next_providers", - flavor_id = "flavor_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_providers": {} })); - }); - - let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/flavors/{flavor_id}/next_providers", - flavor_id = "flavor_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_providers": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/next_provider/set.rs b/openstack_sdk/src/api/network/v2/flavor/next_provider/set.rs deleted file mode 100644 index e9ff2991e..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/next_provider/set.rs +++ /dev/null @@ -1,240 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_next_provider"))] - pub(crate) next_provider: BTreeMap, Value>, - - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.0/flavors/{flavor_id}/next_providers/{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<'a> RequestBuilder<'a> { - pub fn next_provider(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.next_provider - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Next_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "flavors/{flavor_id}/next_providers/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("next_provider", serde_json::to_value(&self.next_provider)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("next_provider".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .next_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .next_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "next_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/flavors/{flavor_id}/next_providers/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_provider": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .next_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/flavors/{flavor_id}/next_providers/{id}", - flavor_id = "flavor_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "next_provider": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .next_provider(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/service_profile/create.rs b/openstack_sdk/src/api/network/v2/flavor/service_profile/create.rs deleted file mode 100644 index 07f58c205..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/service_profile/create.rs +++ /dev/null @@ -1,243 +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`. - -//! Associate a flavor with a service profile. -//! -//! A flavor can be associated with more than one profile. -//! -//! Will return `409 Conflict` if association already exists. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `service_profile` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ServiceProfile<'a> { - /// The UUID of the service profile. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `service_profile` object. - #[builder(setter(into))] - pub(crate) service_profile: ServiceProfile<'a>, - - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} - /// API - #[builder(default, setter(into))] - flavor_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 Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "flavors/{flavor_id}/service_profiles", - flavor_id = self.flavor_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "service_profile", - serde_json::to_value(&self.service_profile)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/flavors/{flavor_id}/service_profiles", - flavor_id = "flavor_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/flavors/{flavor_id}/service_profiles", - flavor_id = "flavor_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/service_profile/delete.rs b/openstack_sdk/src/api/network/v2/flavor/service_profile/delete.rs deleted file mode 100644 index 0a7a33fea..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/service_profile/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Disassociate a flavor from a service profile. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/service_profiles/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/flavors/{flavor_id}/service_profiles/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/flavors/{flavor_id}/service_profiles/{id}", - flavor_id = "flavor_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() - .flavor_id("flavor_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/service_profile/get.rs b/openstack_sdk/src/api/network/v2/flavor/service_profile/get.rs deleted file mode 100644 index 9057cf122..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/service_profile/get.rs +++ /dev/null @@ -1,204 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/service_profiles/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/flavors/{flavor_id}/service_profiles/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/flavors/{flavor_id}/service_profiles/{id}", - flavor_id = "flavor_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/service_profile/list.rs b/openstack_sdk/src/api/network/v2/flavor/service_profile/list.rs deleted file mode 100644 index e96011c19..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/service_profile/list.rs +++ /dev/null @@ -1,260 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "flavors/{flavor_id}/service_profiles", - flavor_id = self.flavor_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profiles".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_profiles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/flavors/{flavor_id}/service_profiles", - flavor_id = "flavor_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profiles": {} })); - }); - - let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/flavors/{flavor_id}/service_profiles", - flavor_id = "flavor_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profiles": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/service_profile/set.rs b/openstack_sdk/src/api/network/v2/flavor/service_profile/set.rs deleted file mode 100644 index d5a04ab46..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/service_profile/set.rs +++ /dev/null @@ -1,243 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_service_profile"))] - pub(crate) service_profile: BTreeMap, Value>, - - /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} - /// API - #[builder(default, setter(into))] - flavor_id: Cow<'a, str>, - - /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { - pub fn service_profile(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.service_profile - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "flavors/{flavor_id}/service_profiles/{id}", - flavor_id = self.flavor_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "service_profile", - serde_json::to_value(&self.service_profile)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_profile(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_profile(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/flavors/{flavor_id}/service_profiles/{id}", - flavor_id = "flavor_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .service_profile(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/flavors/{flavor_id}/service_profiles/{id}", - flavor_id = "flavor_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .flavor_id("flavor_id") - .id("id") - .service_profile(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/flavor/set.rs b/openstack_sdk/src/api/network/v2/flavor/set.rs deleted file mode 100644 index 4e5150764..000000000 --- a/openstack_sdk/src/api/network/v2/flavor/set.rs +++ /dev/null @@ -1,243 +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`. - -//! Updates a flavor. -//! -//! The service_type cannot be updated as there may be associated service -//! profiles and consumers depending on the value. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `flavor` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Flavor<'a> { - /// The human-readable description for the flavor. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Indicates whether the flavor is enabled or not. Default is true. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option>, - - /// Name of the flavor. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_profiles: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `flavor` object. - #[builder(setter(into))] - pub(crate) flavor: Flavor<'a>, - - /// id parameter for /v2.0/flavors/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Flavor. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("flavors/{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("flavor", serde_json::to_value(&self.flavor)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("flavor".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "flavor" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/flavors/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .flavor(FlavorBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/flavors/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "flavor": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .flavor(FlavorBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/create.rs b/openstack_sdk/src/api/network/v2/floatingip/create.rs deleted file mode 100644 index e9e8f923c..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/create.rs +++ /dev/null @@ -1,330 +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`. - -//! Creates a floating IP, and, if you specify port information, associates the -//! floating IP with an internal port. -//! -//! To associate the floating IP with an internal port, specify the port ID -//! attribute in the request body. If you do not specify a port ID in the -//! request, you can issue a PUT request instead of a POST request. -//! -//! Default policy settings enable only administrative users to set floating IP -//! addresses and some non-administrative users might require a floating IP -//! address. If you do not specify a floating IP address in the request, the -//! operation automatically allocates one. -//! -//! By default, this operation associates the floating IP address with a single -//! fixed IP address that is configured on an OpenStack Networking port. If a -//! port has multiple IP addresses, you must specify the `fixed_ip_address` -//! attribute in the request body to associate a fixed IP address with the -//! floating IP address. -//! -//! You can create floating IPs on only external networks. When you create a -//! floating IP, you must specify the ID of the network on which you want to -//! create the floating IP. Alternatively, you can create a floating IP on a -//! subnet in the external network, based on the costs and quality of that -//! subnet. -//! -//! You must configure an IP address with the internal OpenStack Networking -//! port that is associated with the floating IP address. -//! -//! The operation returns the `Bad Request (400)` response code for one of -//! reasons: -//! -//! If the port ID is not valid, this operation returns `404` response code. -//! -//! The operation returns the `Conflict (409)` response code for one of -//! reasons: -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `floatingip` object. When you associate a floating IP address with a VM, -/// the instance has the same public IP address each time that it boots, -/// basically to maintain a consistent IP address for maintaining DNS -/// assignment. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Floatingip<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// A valid DNS domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_domain: Option>, - - /// A valid DNS name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_name: Option>, - - /// The fixed IP address that is associated with the floating IP. If an - /// internal port has multiple associated IP addresses, the service chooses - /// the first IP address unless you explicitly define a fixed IP address in - /// the `fixed_ip_address` parameter. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ip_address: Option>>, - - /// The floating IP address. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) floating_ip_address: Option>>, - - /// The ID of the network associated with the floating IP. - #[serde()] - #[builder(setter(into))] - pub(crate) floating_network_id: Cow<'a, str>, - - /// The ID of a port associated with the floating IP. To associate the - /// floating IP with a fixed IP at creation time, you must specify the - /// identifier of the internal port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_id: Option>>, - - /// The ID of the QoS policy associated with the floating IP. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, - - /// The subnet ID on which you want to create the floating IP. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>>, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `floatingip` object. When you associate a floating IP address with a - /// VM, the instance has the same public IP address each time that it - /// boots, basically to maintain a consistent IP address for maintaining - /// DNS assignment. - #[builder(setter(into))] - pub(crate) floatingip: Floatingip<'a>, - - #[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 Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "floatingips".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("floatingip", serde_json::to_value(&self.floatingip)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingip".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .floatingip( - FloatingipBuilder::default() - .floating_network_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .floatingip( - FloatingipBuilder::default() - .floating_network_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "floatingip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/floatingips".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip": {} })); - }); - - let endpoint = Request::builder() - .floatingip( - FloatingipBuilder::default() - .floating_network_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/floatingips".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip": {} })); - }); - - let endpoint = Request::builder() - .floatingip( - FloatingipBuilder::default() - .floating_network_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/delete.rs b/openstack_sdk/src/api/network/v2/floatingip/delete.rs deleted file mode 100644 index 7ff0dd982..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/delete.rs +++ /dev/null @@ -1,187 +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`. - -//! Deletes a floating IP and, if present, its associated port. -//! -//! This example deletes a floating IP: -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/floatingips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("floatingips/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/floatingips/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/floatingips/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/find.rs b/openstack_sdk/src/api/network/v2/floatingip/find.rs deleted file mode 100644 index 73d28bd56..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/find.rs +++ /dev/null @@ -1,87 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use crate::api::find::Findable; -use crate::api::rest_endpoint_prelude::*; - -use crate::api::network::v2::floatingip::{get as Get, list as List}; - -/// Find for floatingip by floating_ip_addressOrId. -#[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<'a> RequestBuilder<'a> { - /// 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<'a>; - 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<'a> { - 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.floating_ip_address(self.id.clone()); - ep.build().unwrap() - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/get.rs b/openstack_sdk/src/api/network/v2/floatingip/get.rs deleted file mode 100644 index c4ce2ba7a..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/get.rs +++ /dev/null @@ -1,195 +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`. - -//! Shows details for a floating IP. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! This example request shows details for a floating IP in JSON format. This -//! example also filters the result by the `fixed_ip_address` and -//! `floating_ip_address` fields. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/floatingips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("floatingips/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingip".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floatingip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/floatingips/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/floatingips/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/list.rs b/openstack_sdk/src/api/network/v2/floatingip/list.rs deleted file mode 100644 index da961fd04..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/list.rs +++ /dev/null @@ -1,392 +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`. - -//! Lists floating IPs visible to the user. -//! -//! Default policy settings return only the floating IPs owned by the user’s -//! project, unless the user has admin role. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! This example request lists floating IPs in JSON format: -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - description: Option>, - - /// fixed_ip_address query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - fixed_ip_address: Option>, - - /// floating_ip_address query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - floating_ip_address: Option>, - - /// floating_network_id query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - floating_network_id: Option>, - - /// id query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// not-tags query parameter for /v2.0/floatingips API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/floatingips API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// port_id query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - port_id: Option>, - - /// revision_number query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - revision_number: Option>, - - /// router_id query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - router_id: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// status query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - status: Option>, - - /// tags query parameter for /v2.0/floatingips API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/floatingips API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/floatingips API - #[builder(default, setter(into))] - tenant_id: 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> { - /// not-tags query parameter for /v2.0/floatingips API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/floatingips API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/floatingips API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/floatingips API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "floatingips".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("description", self.description.as_ref()); - params.push_opt("fixed_ip_address", self.fixed_ip_address.as_ref()); - params.push_opt("floating_ip_address", self.floating_ip_address.as_ref()); - params.push_opt("floating_network_id", self.floating_network_id.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("port_id", self.port_id.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("router_id", self.router_id.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingips".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floatingips" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/floatingips".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingips": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/floatingips".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingips": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/create.rs b/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/create.rs deleted file mode 100644 index 86688f03c..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/create.rs +++ /dev/null @@ -1,301 +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`. - -//! Creates a floating IP port forwarding. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Protocol { - #[serde(rename = "dccp")] - Dccp, - #[serde(rename = "icmp")] - Icmp, - #[serde(rename = "ipv6-icmp")] - Ipv6Icmp, - #[serde(rename = "sctp")] - Sctp, - #[serde(rename = "tcp")] - Tcp, - #[serde(rename = "udp")] - Udp, -} - -/// A `floating IP port forwarding` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PortForwarding<'a> { - /// A text describing the rule, which helps users to manage/find easily - /// theirs rules. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The TCP/UDP/other protocol port number of the port forwarding’s - /// floating IP address. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_port: Option>, - - /// The TCP/UDP/other protocol port range of the port forwarding’s floating - /// IP address. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_port_range: Option, - - /// The fixed IPv4 address of the Neutron port associated to the floating - /// IP port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_ip_address: Option>, - - /// The TCP/UDP/other protocol port number of the Neutron port fixed IP - /// address associated to the floating ip port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_port: Option>, - - /// The ID of the Neutron port associated to the floating IP port - /// forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_port_id: Option>, - - /// The TCP/UDP/other protocol port range of the Neutron port fixed IP - /// address associated to the floating ip port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_port_range: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The IP protocol used in the floating IP port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `floating IP port forwarding` object. - #[builder(setter(into))] - pub(crate) port_forwarding: PortForwarding<'a>, - - /// floatingip_id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API - #[builder(default, setter(into))] - floatingip_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 Port_Forwarding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "floatingips/{floatingip_id}/port_forwardings", - floatingip_id = self.floatingip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "port_forwarding", - serde_json::to_value(&self.port_forwarding)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_forwarding".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "port_forwarding" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/floatingips/{floatingip_id}/port_forwardings", - floatingip_id = "floatingip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwarding": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/floatingips/{floatingip_id}/port_forwardings", - floatingip_id = "floatingip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwarding": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/delete.rs b/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/delete.rs deleted file mode 100644 index ae7fdccd6..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/delete.rs +++ /dev/null @@ -1,208 +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`. - -//! Deletes a floating IP port forwarding. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// floatingip_id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Port_Forwarding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = self.floatingip_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = "floatingip_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = "floatingip_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() - .floatingip_id("floatingip_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/find.rs b/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/find.rs deleted file mode 100644 index b97bdc7ab..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/find.rs +++ /dev/null @@ -1,118 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use tracing::trace; - -use crate::api::find::Findable; -use crate::api::rest_endpoint_prelude::*; - -use crate::api::{ApiError, RestClient}; - -use crate::api::network::v2::floatingip::port_forwarding::{get as Get, list as List}; - -/// Find for floatingip/port_forwarding by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[builder(default, setter(into))] - floatingip_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 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<'a>; - fn get_ep(&self) -> Get::Request<'a> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.floatingip_id(self.floatingip_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<'a> { - let mut ep = List::Request::builder(); - ep.floatingip_id(self.floatingip_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().unwrap() - } - /// Locate floatingip/port_forwarding in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // floatingip/port_forwarding 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/network/v2/floatingip/port_forwarding/get.rs b/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/get.rs deleted file mode 100644 index 3ec14c990..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/get.rs +++ /dev/null @@ -1,214 +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`. - -//! Shows information for a floating IP port forwarding. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// floatingip_id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Port_Forwarding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = self.floatingip_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_forwarding".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "port_forwarding" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = "floatingip_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwarding": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = "floatingip_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwarding": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/list.rs b/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/list.rs deleted file mode 100644 index 205a7be59..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/list.rs +++ /dev/null @@ -1,322 +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`. - -//! Lists floating IP port forwardings that the project has access to. -//! -//! Default policy settings return only the port forwardings associated to -//! floating IPs owned by the project of the user submitting the request, -//! unless the user has administrative role. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings API - #[builder(default, setter(into))] - description: Option>, - - /// external_port query parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings API - #[builder(default)] - external_port: Option, - - /// external_port_range query parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings API - #[builder(default)] - external_port_range: Option, - - /// floatingip_id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// id query parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings API - #[builder(default, setter(into))] - id: Option>, - - /// internal_port_id query parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings API - #[builder(default, setter(into))] - internal_port_id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// protocol query parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings API - #[builder(default, setter(into))] - protocol: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Port_Forwarding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "floatingips/{floatingip_id}/port_forwardings", - floatingip_id = self.floatingip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("description", self.description.as_ref()); - params.push_opt("external_port", self.external_port); - params.push_opt("external_port_range", self.external_port_range); - params.push_opt("id", self.id.as_ref()); - params.push_opt("internal_port_id", self.internal_port_id.as_ref()); - params.push_opt("protocol", self.protocol.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_forwardings".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "port_forwardings" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/floatingips/{floatingip_id}/port_forwardings", - floatingip_id = "floatingip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwardings": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/floatingips/{floatingip_id}/port_forwardings", - floatingip_id = "floatingip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwardings": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/set.rs b/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/set.rs deleted file mode 100644 index ce135edd3..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding/set.rs +++ /dev/null @@ -1,305 +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`. - -//! Updates a floating IP port forwarding. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Protocol { - #[serde(rename = "dccp")] - Dccp, - #[serde(rename = "icmp")] - Icmp, - #[serde(rename = "ipv6-icmp")] - Ipv6Icmp, - #[serde(rename = "sctp")] - Sctp, - #[serde(rename = "tcp")] - Tcp, - #[serde(rename = "udp")] - Udp, -} - -/// A `floating IP port forwarding` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PortForwarding<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The TCP/UDP/other protocol port number of the port forwarding’s - /// floating IP address. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_port: Option>, - - /// The TCP/UDP/other protocol port range of the port forwarding’s floating - /// IP address. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_port_range: Option, - - /// The fixed IPv4 address of the Neutron port associated to the floating - /// IP port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_ip_address: Option>, - - /// The TCP/UDP/other protocol port number of the Neutron port fixed IP - /// address associated to the floating ip port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_port: Option>, - - /// The ID of the Neutron port associated to the floating IP port - /// forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_port_id: Option>, - - /// The TCP/UDP/other protocol port range of the Neutron port fixed IP - /// address associated to the floating ip port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) internal_port_range: Option, - - /// The IP protocol used in the floating IP port forwarding. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `floating IP port forwarding` object. - #[builder(setter(into))] - pub(crate) port_forwarding: PortForwarding<'a>, - - /// floatingip_id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// id parameter for - /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Port_Forwarding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = self.floatingip_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "port_forwarding", - serde_json::to_value(&self.port_forwarding)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_forwarding".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "port_forwarding" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = "floatingip_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwarding": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/floatingips/{floatingip_id}/port_forwardings/{id}", - floatingip_id = "floatingip_id", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_forwarding": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .port_forwarding(PortForwardingBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/set.rs b/openstack_sdk/src/api/network/v2/floatingip/set.rs deleted file mode 100644 index 73fec6298..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/set.rs +++ /dev/null @@ -1,263 +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`. - -//! Updates a floating IP and its association with an internal port. -//! -//! The association process is the same as the process for the create floating -//! IP operation. -//! -//! To disassociate a floating IP from a port, set the `port_id` attribute to -//! null or omit it from the request body. -//! -//! This example updates a floating IP: -//! -//! Depending on the request body that you submit, this request associates a -//! port with or disassociates a port from a floating IP. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404, 409, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `floatingip` object. When you associate a floating IP address with a VM, -/// the instance has the same public IP address each time that it boots, -/// basically to maintain a consistent IP address for maintaining DNS -/// assignment. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Floatingip<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The fixed IP address that is associated with the floating IP. If an - /// internal port has multiple associated IP addresses, the service chooses - /// the first IP address unless you explicitly define a fixed IP address in - /// the `fixed_ip_address` parameter. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ip_address: Option>>, - - /// The ID of a port associated with the floating IP. To associate the - /// floating IP with a fixed IP, you must specify the ID of the internal - /// port. To disassociate the floating IP, `null` should be specified. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_id: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `floatingip` object. When you associate a floating IP address with a - /// VM, the instance has the same public IP address each time that it - /// boots, basically to maintain a consistent IP address for maintaining - /// DNS assignment. - #[builder(setter(into))] - pub(crate) floatingip: Floatingip<'a>, - - /// id parameter for /v2.0/floatingips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floatingip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("floatingips/{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("floatingip", serde_json::to_value(&self.floatingip)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingip".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .floatingip(FloatingipBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .floatingip(FloatingipBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "floatingip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/floatingips/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .floatingip(FloatingipBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/floatingips/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .floatingip(FloatingipBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/tag/delete.rs b/openstack_sdk/src/api/network/v2/floatingip/tag/delete.rs deleted file mode 100644 index 828f50bb9..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/tag/delete.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} - /// API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// id parameter for /v2.0/floatingips/{floatingip_id}/tags/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "floatingips/{floatingip_id}/tags/{id}", - floatingip_id = self.floatingip_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/floatingips/{floatingip_id}/tags/{id}", - floatingip_id = "floatingip_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/floatingips/{floatingip_id}/tags/{id}", - floatingip_id = "floatingip_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() - .floatingip_id("floatingip_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/floatingip/tag/delete_all.rs deleted file mode 100644 index 5729fd957..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/tag/delete_all.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} - /// API - #[builder(default, setter(into))] - floatingip_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "floatingips/{floatingip_id}/tags", - floatingip_id = self.floatingip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/floatingips/{floatingip_id}/tags", - floatingip_id = "floatingip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/floatingips/{floatingip_id}/tags", - floatingip_id = "floatingip_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() - .floatingip_id("floatingip_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/tag/get.rs b/openstack_sdk/src/api/network/v2/floatingip/tag/get.rs deleted file mode 100644 index f719d4bb6..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/tag/get.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} - /// API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// id parameter for /v2.0/floatingips/{floatingip_id}/tags/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "floatingips/{floatingip_id}/tags/{id}", - floatingip_id = self.floatingip_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/floatingips/{floatingip_id}/tags/{id}", - floatingip_id = "floatingip_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/floatingips/{floatingip_id}/tags/{id}", - floatingip_id = "floatingip_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() - .floatingip_id("floatingip_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/tag/list.rs b/openstack_sdk/src/api/network/v2/floatingip/tag/list.rs deleted file mode 100644 index 1c90f6a1d..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/tag/list.rs +++ /dev/null @@ -1,263 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} - /// API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "floatingips/{floatingip_id}/tags", - floatingip_id = self.floatingip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/floatingips/{floatingip_id}/tags", - floatingip_id = "floatingip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/floatingips/{floatingip_id}/tags", - floatingip_id = "floatingip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/tag/replace.rs b/openstack_sdk/src/api/network/v2/floatingip/tag/replace.rs deleted file mode 100644 index 4f5fbe32d..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/tag/replace.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} - /// API - #[builder(default, setter(into))] - floatingip_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "floatingips/{floatingip_id}/tags", - floatingip_id = self.floatingip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/floatingips/{floatingip_id}/tags", - floatingip_id = "floatingip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/floatingips/{floatingip_id}/tags", - floatingip_id = "floatingip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip/tag/set.rs b/openstack_sdk/src/api/network/v2/floatingip/tag/set.rs deleted file mode 100644 index 84d5aaa09..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip/tag/set.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} - /// API - #[builder(default, setter(into))] - floatingip_id: Cow<'a, str>, - - /// id parameter for /v2.0/floatingips/{floatingip_id}/tags/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "floatingips/{floatingip_id}/tags/{id}", - floatingip_id = self.floatingip_id.as_ref(), - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/floatingips/{floatingip_id}/tags/{id}", - floatingip_id = "floatingip_id", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .floatingip_id("floatingip_id") - .id("id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/floatingips/{floatingip_id}/tags/{id}", - floatingip_id = "floatingip_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() - .floatingip_id("floatingip_id") - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip_pool/create.rs b/openstack_sdk/src/api/network/v2/floatingip_pool/create.rs deleted file mode 100644 index 9e01bc0de..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip_pool/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_floatingip_pool"))] - pub(crate) floatingip_pool: BTreeMap, Value>, - - #[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 floatingip_pool(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.floatingip_pool - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Floatingip_Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "floatingip-pools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "floatingip_pool", - serde_json::to_value(&self.floatingip_pool)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingip_pool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .floatingip_pool(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .floatingip_pool(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "floatingip_pool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/floatingip-pools".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pool": {} })); - }); - - let endpoint = Request::builder() - .floatingip_pool(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/floatingip-pools".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pool": {} })); - }); - - let endpoint = Request::builder() - .floatingip_pool(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip_pool/delete.rs b/openstack_sdk/src/api/network/v2/floatingip_pool/delete.rs deleted file mode 100644 index a651b658b..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip_pool/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/floatingip-pools/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floatingip_Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("floatingip-pools/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/floatingip-pools/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/floatingip-pools/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip_pool/get.rs b/openstack_sdk/src/api/network/v2/floatingip_pool/get.rs deleted file mode 100644 index c6dbd2438..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip_pool/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/floatingip-pools/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Floatingip_Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("floatingip-pools/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingip_pool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floatingip_pool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/floatingip-pools/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pool": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/floatingip-pools/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip_pool/list.rs b/openstack_sdk/src/api/network/v2/floatingip_pool/list.rs deleted file mode 100644 index dcf0ac45f..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip_pool/list.rs +++ /dev/null @@ -1,245 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Floatingip_Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "floatingip-pools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingip_pools".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "floatingip_pools" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/floatingip-pools".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pools": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/floatingip-pools".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pools": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/floatingip_pool/set.rs b/openstack_sdk/src/api/network/v2/floatingip_pool/set.rs deleted file mode 100644 index 400323c22..000000000 --- a/openstack_sdk/src/api/network/v2/floatingip_pool/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_floatingip_pool"))] - pub(crate) floatingip_pool: BTreeMap, Value>, - - /// id parameter for /v2.0/floatingip-pools/{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<'a> RequestBuilder<'a> { - pub fn floatingip_pool(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.floatingip_pool - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Floatingip_Pool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("floatingip-pools/{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( - "floatingip_pool", - serde_json::to_value(&self.floatingip_pool)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("floatingip_pool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .floatingip_pool(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .floatingip_pool(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "floatingip_pool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/floatingip-pools/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .floatingip_pool(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/floatingip-pools/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "floatingip_pool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .floatingip_pool(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/create.rs b/openstack_sdk/src/api/network/v2/local_ip/create.rs deleted file mode 100644 index 8c63f9575..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/create.rs +++ /dev/null @@ -1,243 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum IpMode { - #[serde(rename = "passthrough")] - Passthrough, - #[serde(rename = "translate")] - Translate, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct LocalIp<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) ip_mode: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) local_ip_address: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) local_port_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) network_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) local_ip: LocalIp<'a>, - - #[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 Local_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "local-ips".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("local_ip", serde_json::to_value(&self.local_ip)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("local_ip".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .local_ip(LocalIpBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .local_ip(LocalIpBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "local_ip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/local-ips".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ip": {} })); - }); - - let endpoint = Request::builder() - .local_ip(LocalIpBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/local-ips".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ip": {} })); - }); - - let endpoint = Request::builder() - .local_ip(LocalIpBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/delete.rs b/openstack_sdk/src/api/network/v2/local_ip/delete.rs deleted file mode 100644 index cb536d908..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/local-ips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Local_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("local-ips/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/local-ips/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/local-ips/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/find.rs b/openstack_sdk/src/api/network/v2/local_ip/find.rs deleted file mode 100644 index 72906d5ce..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::local_ip::{get as Get, list as List}; - -/// Find for local_ip 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/get.rs b/openstack_sdk/src/api/network/v2/local_ip/get.rs deleted file mode 100644 index a7d36348b..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/local-ips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Local_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("local-ips/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("local_ip".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "local_ip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/local-ips/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ip": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/local-ips/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ip": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/list.rs b/openstack_sdk/src/api/network/v2/local_ip/list.rs deleted file mode 100644 index 6a468d938..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/list.rs +++ /dev/null @@ -1,290 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - id: Option>, - - /// ip_mode query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - ip_mode: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// local_ip_address query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - local_ip_address: Option>, - - /// local_port_id query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - local_port_id: Option>, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - name: Option>, - - /// network_id query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - network_id: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// project_id query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - project_id: Option>, - - /// revision_number query parameter for /v2.0/local-ips API - #[builder(default, setter(into))] - revision_number: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Local_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "local-ips".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("ip_mode", self.ip_mode.as_ref()); - params.push_opt("local_ip_address", self.local_ip_address.as_ref()); - params.push_opt("local_port_id", self.local_port_id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("network_id", self.network_id.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("local_ips".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "local_ips" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/local-ips".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ips": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/local-ips".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ips": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/port_association/create.rs b/openstack_sdk/src/api/network/v2/local_ip/port_association/create.rs deleted file mode 100644 index 5c119b7d7..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/port_association/create.rs +++ /dev/null @@ -1,250 +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`. - -//! Creates a Local IP association with a given Port. If a Port has multiple -//! fixed IPs user must specify which IP to use for association. -//! -//! The operation returns the `Conflict (409)` response code for one of -//! reasons: -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PortAssociation<'a> { - /// The requested IP of the port associated with the Local IP. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ip: Option>>, - - /// The requested ID of the port associated with the Local IP. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_port_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) port_association: PortAssociation<'a>, - - /// local_ip_id parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API - #[builder(default, setter(into))] - local_ip_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 Port_Association. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "local_ips/{local_ip_id}/port_associations", - local_ip_id = self.local_ip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "port_association", - serde_json::to_value(&self.port_association)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_association".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .port_association(PortAssociationBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .port_association(PortAssociationBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "port_association" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/local_ips/{local_ip_id}/port_associations", - local_ip_id = "local_ip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_association": {} })); - }); - - let endpoint = Request::builder() - .local_ip_id("local_ip_id") - .port_association(PortAssociationBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/local_ips/{local_ip_id}/port_associations", - local_ip_id = "local_ip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_association": {} })); - }); - - let endpoint = Request::builder() - .local_ip_id("local_ip_id") - .port_association(PortAssociationBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/port_association/delete.rs b/openstack_sdk/src/api/network/v2/local_ip/port_association/delete.rs deleted file mode 100644 index 26a9d6d14..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/port_association/delete.rs +++ /dev/null @@ -1,208 +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`. - -//! Deletes a Local IP association. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/local_ips/{local_ip_id}/port_associations/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// local_ip_id parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API - #[builder(default, setter(into))] - local_ip_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 Port_Association. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "local_ips/{local_ip_id}/port_associations/{id}", - id = self.id.as_ref(), - local_ip_id = self.local_ip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/local_ips/{local_ip_id}/port_associations/{id}", - id = "id", - local_ip_id = "local_ip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .local_ip_id("local_ip_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/local_ips/{local_ip_id}/port_associations/{id}", - id = "id", - local_ip_id = "local_ip_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") - .local_ip_id("local_ip_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/port_association/get.rs b/openstack_sdk/src/api/network/v2/local_ip/port_association/get.rs deleted file mode 100644 index a8e9f7755..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/port_association/get.rs +++ /dev/null @@ -1,205 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/local_ips/{local_ip_id}/port_associations/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// local_ip_id parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API - #[builder(default, setter(into))] - local_ip_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 Port_Association. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "local_ips/{local_ip_id}/port_associations/{id}", - id = self.id.as_ref(), - local_ip_id = self.local_ip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_association".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "port_association" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/local_ips/{local_ip_id}/port_associations/{id}", - id = "id", - local_ip_id = "local_ip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_association": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .local_ip_id("local_ip_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/local_ips/{local_ip_id}/port_associations/{id}", - id = "id", - local_ip_id = "local_ip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_association": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .local_ip_id("local_ip_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/port_association/list.rs b/openstack_sdk/src/api/network/v2/local_ip/port_association/list.rs deleted file mode 100644 index 13ed23265..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/port_association/list.rs +++ /dev/null @@ -1,306 +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`. - -//! Lists Associations for the given Local IP. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// fixed_ip query parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations API - #[builder(default, setter(into))] - fixed_ip: Option>, - - /// fixed_port_id query parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations API - #[builder(default, setter(into))] - fixed_port_id: Option>, - - /// host query parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations API - #[builder(default, setter(into))] - host: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// local_ip_address query parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations API - #[builder(default, setter(into))] - local_ip_address: Option>, - - /// local_ip_id parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API - #[builder(default, setter(into))] - local_ip_id: Cow<'a, str>, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Port_Association. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "local_ips/{local_ip_id}/port_associations", - local_ip_id = self.local_ip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("fixed_ip", self.fixed_ip.as_ref()); - params.push_opt("fixed_port_id", self.fixed_port_id.as_ref()); - params.push_opt("host", self.host.as_ref()); - params.push_opt("local_ip_address", self.local_ip_address.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_associations".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "port_associations" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/local_ips/{local_ip_id}/port_associations", - local_ip_id = "local_ip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_associations": {} })); - }); - - let endpoint = Request::builder() - .local_ip_id("local_ip_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/local_ips/{local_ip_id}/port_associations", - local_ip_id = "local_ip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_associations": {} })); - }); - - let endpoint = Request::builder() - .local_ip_id("local_ip_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/port_association/set.rs b/openstack_sdk/src/api/network/v2/local_ip/port_association/set.rs deleted file mode 100644 index 17ee99040..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/port_association/set.rs +++ /dev/null @@ -1,244 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_port_association"))] - pub(crate) port_association: BTreeMap, Value>, - - /// id parameter for /v2.0/local_ips/{local_ip_id}/port_associations/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// local_ip_id parameter for - /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API - #[builder(default, setter(into))] - local_ip_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> { - pub fn port_association(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.port_association - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Port_Association. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "local_ips/{local_ip_id}/port_associations/{id}", - id = self.id.as_ref(), - local_ip_id = self.local_ip_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "port_association", - serde_json::to_value(&self.port_association)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port_association".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .port_association(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .port_association(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "port_association" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/local_ips/{local_ip_id}/port_associations/{id}", - id = "id", - local_ip_id = "local_ip_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_association": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .local_ip_id("local_ip_id") - .port_association(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/local_ips/{local_ip_id}/port_associations/{id}", - id = "id", - local_ip_id = "local_ip_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port_association": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .local_ip_id("local_ip_id") - .port_association(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/local_ip/set.rs b/openstack_sdk/src/api/network/v2/local_ip/set.rs deleted file mode 100644 index d7abbb76b..000000000 --- a/openstack_sdk/src/api/network/v2/local_ip/set.rs +++ /dev/null @@ -1,221 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct LocalIp<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) local_ip: LocalIp<'a>, - - /// id parameter for /v2.0/local-ips/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Local_Ip. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("local-ips/{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("local_ip", serde_json::to_value(&self.local_ip)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("local_ip".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .local_ip(LocalIpBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .local_ip(LocalIpBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "local_ip" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/local-ips/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ip": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .local_ip(LocalIpBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/local-ips/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "local_ip": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .local_ip(LocalIpBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/log/create.rs b/openstack_sdk/src/api/network/v2/log/log/create.rs deleted file mode 100644 index d387e6cbe..000000000 --- a/openstack_sdk/src/api/network/v2/log/log/create.rs +++ /dev/null @@ -1,280 +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`. - -//! Creates a log resource. -//! -//! Creates a log resource by using the configuration that you define in the -//! request object. A response object is returned. The object contains a unique -//! ID. -//! -//! If the caller is not an administrative user, this call returns the HTTP -//! `Forbidden (403)` response code. -//! -//! Users with an administrative role can create policies on behalf of other -//! projects by specifying a project ID that is different than their own. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Event { - #[serde(rename = "ACCEPT")] - Accept, - #[serde(rename = "ALL")] - All, - #[serde(rename = "DROP")] - Drop, -} - -/// A `log` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Log<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Indicates whether this log object is enabled or disabled. Default is - /// true. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// Type of security events to log. `ACCEPT`, `DROP`, or `ALL`. Default is - /// `ALL`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) event: Option, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The ID of resource log (e.g security group ID). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) resource_id: Option>>, - - /// The resource log type such as ‘security_group’. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) resource_type: Option>, - - /// The ID of resource target log such as port ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) target_id: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `log` object. - #[builder(setter(into))] - pub(crate) log: Log<'a>, - - #[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 Log. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "log/logs".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("log", serde_json::to_value(&self.log)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("log".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .log(LogBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .log(LogBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "log" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/log/logs".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "log": {} })); - }); - - let endpoint = Request::builder() - .log(LogBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/log/logs".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "log": {} })); - }); - - let endpoint = Request::builder() - .log(LogBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/log/delete.rs b/openstack_sdk/src/api/network/v2/log/log/delete.rs deleted file mode 100644 index 9a6e12e23..000000000 --- a/openstack_sdk/src/api/network/v2/log/log/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a log resource. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/log/logs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Log. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("log/logs/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/log/logs/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/log/logs/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/log/find.rs b/openstack_sdk/src/api/network/v2/log/log/find.rs deleted file mode 100644 index 44aa28457..000000000 --- a/openstack_sdk/src/api/network/v2/log/log/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::log::log::{get as Get, list as List}; - -/// Find for log/log 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/log/log/get.rs b/openstack_sdk/src/api/network/v2/log/log/get.rs deleted file mode 100644 index 270f54665..000000000 --- a/openstack_sdk/src/api/network/v2/log/log/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details log resource. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/log/logs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Log. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("log/logs/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("log".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "log" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/log/logs/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "log": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/log/logs/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "log": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/log/list.rs b/openstack_sdk/src/api/network/v2/log/log/list.rs deleted file mode 100644 index ad4661bfe..000000000 --- a/openstack_sdk/src/api/network/v2/log/log/list.rs +++ /dev/null @@ -1,316 +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`. - -//! Lists all log resources associated with your project. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! The list might be empty. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - description: Option>, - - /// enabled query parameter for /v2.0/log/logs API - #[builder(default)] - enabled: Option, - - /// event query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - event: Option>, - - /// id query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// project_id query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - project_id: Option>, - - /// resource_id query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - resource_id: Option>, - - /// resource_type query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - resource_type: Option>, - - /// revision_number query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - revision_number: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// target_id query parameter for /v2.0/log/logs API - #[builder(default, setter(into))] - target_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Log. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "log/logs".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("description", self.description.as_ref()); - params.push_opt("enabled", self.enabled); - params.push_opt("event", self.event.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("resource_id", self.resource_id.as_ref()); - params.push_opt("resource_type", self.resource_type.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("target_id", self.target_id.as_ref()); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("logs".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "logs" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/log/logs".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "logs": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/log/logs".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "logs": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/log/set.rs b/openstack_sdk/src/api/network/v2/log/log/set.rs deleted file mode 100644 index 821283090..000000000 --- a/openstack_sdk/src/api/network/v2/log/log/set.rs +++ /dev/null @@ -1,237 +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`. - -//! Updates a log resource. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `log` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Log<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Indicates whether this log object is enabled or disabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `log` object. - #[builder(setter(into))] - pub(crate) log: Log<'a>, - - /// id parameter for /v2.0/log/logs/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Log. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("log/logs/{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("log", serde_json::to_value(&self.log)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("log".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .log(LogBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .log(LogBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "log" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/log/logs/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "log": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .log(LogBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/log/logs/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "log": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .log(LogBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/loggable_resource/create.rs b/openstack_sdk/src/api/network/v2/log/loggable_resource/create.rs deleted file mode 100644 index f9e154878..000000000 --- a/openstack_sdk/src/api/network/v2/log/loggable_resource/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_loggable_resource"))] - pub(crate) loggable_resource: BTreeMap, Value>, - - #[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 loggable_resource(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.loggable_resource - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Loggable_Resource. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "log/loggable-resources".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "loggable_resource", - serde_json::to_value(&self.loggable_resource)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("loggable_resource".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .loggable_resource(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .loggable_resource(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "loggable_resource" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/log/loggable-resources".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resource": {} })); - }); - - let endpoint = Request::builder() - .loggable_resource(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/log/loggable-resources".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resource": {} })); - }); - - let endpoint = Request::builder() - .loggable_resource(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/loggable_resource/delete.rs b/openstack_sdk/src/api/network/v2/log/loggable_resource/delete.rs deleted file mode 100644 index 006141249..000000000 --- a/openstack_sdk/src/api/network/v2/log/loggable_resource/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/log/loggable-resources/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Loggable_Resource. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("log/loggable-resources/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/log/loggable-resources/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/log/loggable-resources/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/loggable_resource/get.rs b/openstack_sdk/src/api/network/v2/log/loggable_resource/get.rs deleted file mode 100644 index e8d3ffcfa..000000000 --- a/openstack_sdk/src/api/network/v2/log/loggable_resource/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/log/loggable-resources/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Loggable_Resource. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("log/loggable-resources/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("loggable_resource".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "loggable_resource" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/log/loggable-resources/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resource": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/log/loggable-resources/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resource": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/loggable_resource/list.rs b/openstack_sdk/src/api/network/v2/log/loggable_resource/list.rs deleted file mode 100644 index 5e685a3bc..000000000 --- a/openstack_sdk/src/api/network/v2/log/loggable_resource/list.rs +++ /dev/null @@ -1,264 +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`. - -//! Lists all resource log types are supporting. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Loggable_Resource. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "log/loggable-resources".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("loggable_resources".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "loggable_resources" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/log/loggable-resources".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resources": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/log/loggable-resources".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resources": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/log/loggable_resource/set.rs b/openstack_sdk/src/api/network/v2/log/loggable_resource/set.rs deleted file mode 100644 index 6a5c40d16..000000000 --- a/openstack_sdk/src/api/network/v2/log/loggable_resource/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_loggable_resource"))] - pub(crate) loggable_resource: BTreeMap, Value>, - - /// id parameter for /v2.0/log/loggable-resources/{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<'a> RequestBuilder<'a> { - pub fn loggable_resource(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.loggable_resource - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Loggable_Resource. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("log/loggable-resources/{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( - "loggable_resource", - serde_json::to_value(&self.loggable_resource)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("loggable_resource".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .loggable_resource(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .loggable_resource(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "loggable_resource" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/log/loggable-resources/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resource": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .loggable_resource(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/log/loggable-resources/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "loggable_resource": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .loggable_resource(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label/create.rs b/openstack_sdk/src/api/network/v2/metering/metering_label/create.rs deleted file mode 100644 index 53d57815f..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label/create.rs +++ /dev/null @@ -1,241 +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`. - -//! Creates an L3 metering label. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `metering_label` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct MeteringLabel<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Indicates whether this metering label is shared across all projects. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `metering_label` object. - #[builder(setter(into))] - pub(crate) metering_label: MeteringLabel<'a>, - - #[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 Metering_Label. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "metering/metering-labels".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "metering_label", - serde_json::to_value(&self.metering_label)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_label".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metering_label(MeteringLabelBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metering_label(MeteringLabelBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metering_label" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/metering/metering-labels".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label": {} })); - }); - - let endpoint = Request::builder() - .metering_label(MeteringLabelBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/metering/metering-labels".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label": {} })); - }); - - let endpoint = Request::builder() - .metering_label(MeteringLabelBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label/delete.rs b/openstack_sdk/src/api/network/v2/metering/metering_label/delete.rs deleted file mode 100644 index 5e3a040b7..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes an L3 metering label. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/metering/metering-labels/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Metering_Label. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("metering/metering-labels/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/metering/metering-labels/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/metering/metering-labels/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label/find.rs b/openstack_sdk/src/api/network/v2/metering/metering_label/find.rs deleted file mode 100644 index c2f4a45da..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::metering::metering_label::{get as Get, list as List}; - -/// Find for metering/metering_label 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label/get.rs b/openstack_sdk/src/api/network/v2/metering/metering_label/get.rs deleted file mode 100644 index 0b4ee84a3..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for a metering label. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/metering/metering-labels/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Metering_Label. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("metering/metering-labels/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_label".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "metering_label" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/metering/metering-labels/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/metering/metering-labels/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label/list.rs b/openstack_sdk/src/api/network/v2/metering/metering_label/list.rs deleted file mode 100644 index cc7ef4f52..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label/list.rs +++ /dev/null @@ -1,291 +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`. - -//! Lists all L3 metering labels that belong to the project. -//! -//! The list shows the ID for each metering label. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/metering/metering-labels API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/metering/metering-labels API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/metering/metering-labels API - #[builder(default, setter(into))] - name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// shared query parameter for /v2.0/metering/metering-labels API - #[builder(default)] - shared: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tenant_id query parameter for /v2.0/metering/metering-labels API - #[builder(default, setter(into))] - tenant_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Metering_Label. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "metering/metering-labels".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("shared", self.shared); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_labels".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "metering_labels" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metering/metering-labels".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_labels": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metering/metering-labels".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_labels": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label/set.rs b/openstack_sdk/src/api/network/v2/metering/metering_label/set.rs deleted file mode 100644 index c896bf674..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_metering_label"))] - pub(crate) metering_label: BTreeMap, Value>, - - /// id parameter for /v2.0/metering/metering-labels/{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<'a> RequestBuilder<'a> { - pub fn metering_label(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.metering_label - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Metering_Label. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("metering/metering-labels/{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( - "metering_label", - serde_json::to_value(&self.metering_label)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_label".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metering_label(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metering_label(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metering_label" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/metering/metering-labels/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .metering_label(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/metering/metering-labels/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .metering_label(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/create.rs b/openstack_sdk/src/api/network/v2/metering/metering_label_rule/create.rs deleted file mode 100644 index 20bade93c..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/create.rs +++ /dev/null @@ -1,263 +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`. - -//! Creates an L3 metering label rule. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -/// A `metering_label_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct MeteringLabelRule<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) destination_ip_prefix: Option>, - - /// Ingress or egress, which is the direction in which the metering rule is - /// applied. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - /// Indicates whether to count the traffic of a specific IP address with - /// the `remote_ip_prefix`, `source_ip_prefix`, or `destination_ip_prefix` - /// values. Default is `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) excluded: Option, - - /// The metering label ID associated with this metering rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) metering_label_id: Option>, - - /// (deprecated) The source IP prefix that is matched by this metering - /// rule. By source IP prefix, one should read the internal/private IPs - /// used in OpenStack. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_ip_prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) source_ip_prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `metering_label_rule` object. - #[builder(setter(into))] - pub(crate) metering_label_rule: MeteringLabelRule<'a>, - - #[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 Metering_Label_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "metering/metering-label-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "metering_label_rule", - serde_json::to_value(&self.metering_label_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_label_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metering_label_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/metering/metering-label-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rule": {} })); - }); - - let endpoint = Request::builder() - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/metering/metering-label-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rule": {} })); - }); - - let endpoint = Request::builder() - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/delete.rs b/openstack_sdk/src/api/network/v2/metering/metering_label_rule/delete.rs deleted file mode 100644 index c4d90a08b..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes an L3 metering label rule. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/metering/metering-label-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Metering_Label_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("metering/metering-label-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/metering/metering-label-rules/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/metering/metering-label-rules/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/get.rs b/openstack_sdk/src/api/network/v2/metering/metering_label_rule/get.rs deleted file mode 100644 index 09da0d831..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/get.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows details for a metering label rule. -//! -//! The response body shows this information for each metering label rule: -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/metering/metering-label-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Metering_Label_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("metering/metering-label-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_label_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "metering_label_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/metering/metering-label-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rule": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/metering/metering-label-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/list.rs b/openstack_sdk/src/api/network/v2/metering/metering_label_rule/list.rs deleted file mode 100644 index 1f1968902..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/list.rs +++ /dev/null @@ -1,316 +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`. - -//! Lists a summary of all L3 metering label rules that belong to the project. -//! -//! The list shows the ID for each metering label rule. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The destination IP prefix that the metering rule is associated with; in - /// this context, destination IP prefix represents the destination IP of - /// the network packet. Therefore, for an ingress rule, the destination IP - /// is the internal IP associated with some OpenStack VM. On the other - /// hand, for an egress rule, the destination IP prefix is the IP of some - /// external system that an application running inside some OpenStack - /// virtual machine is trying to access. Moreover, instead of an IP, one - /// can also use a CIDR as the destination IP prefix. - #[builder(default, setter(into))] - destination_ip_prefix: Option>, - - /// direction query parameter for /v2.0/metering/metering-label-rules API - #[builder(default, setter(into))] - direction: Option>, - - /// excluded query parameter for /v2.0/metering/metering-label-rules API - #[builder(default)] - excluded: Option, - - /// id query parameter for /v2.0/metering/metering-label-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// metering_label_id query parameter for - /// /v2.0/metering/metering-label-rules API - #[builder(default, setter(into))] - metering_label_id: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// remote_ip_prefix query parameter for - /// /v2.0/metering/metering-label-rules API - #[builder(default, setter(into))] - remote_ip_prefix: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// The source IP prefix that the metering rule is associated with; in this - /// context, source IP prefix represents the source IP of the network - /// packet. Therefore, for an ingress rule, the source IP is the IP of the - /// system accessing something inside OpenStack. On the other hand, for an - /// egress rule, the source IP is the internal IP associated with some - /// OpenStack VM. Moreover, instead of an IP, one can also use a CIDR as - /// the source IP prefix. - #[builder(default, setter(into))] - source_ip_prefix: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Metering_Label_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "metering/metering-label-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("destination_ip_prefix", self.destination_ip_prefix.as_ref()); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("excluded", self.excluded); - params.push_opt("id", self.id.as_ref()); - params.push_opt("metering_label_id", self.metering_label_id.as_ref()); - params.push_opt("remote_ip_prefix", self.remote_ip_prefix.as_ref()); - params.push_opt("source_ip_prefix", self.source_ip_prefix.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_label_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "metering_label_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metering/metering-label-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rules": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/metering/metering-label-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rules": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/set.rs b/openstack_sdk/src/api/network/v2/metering/metering_label_rule/set.rs deleted file mode 100644 index 22616742d..000000000 --- a/openstack_sdk/src/api/network/v2/metering/metering_label_rule/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct MeteringLabelRule<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) destination_ip_prefix: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) source_ip_prefix: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) metering_label_rule: MeteringLabelRule<'a>, - - /// id parameter for /v2.0/metering/metering-label-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Metering_Label_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("metering/metering-label-rules/{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( - "metering_label_rule", - serde_json::to_value(&self.metering_label_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("metering_label_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "metering_label_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/metering/metering-label-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/metering/metering-label-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "metering_label_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/ndp_proxy/create.rs b/openstack_sdk/src/api/network/v2/ndp_proxy/create.rs deleted file mode 100644 index 2beb4ac73..000000000 --- a/openstack_sdk/src/api/network/v2/ndp_proxy/create.rs +++ /dev/null @@ -1,231 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct NdpProxy<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) router_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) ndp_proxy: NdpProxy<'a>, - - #[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 Ndp_Proxy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "ndp-proxies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("ndp_proxy", serde_json::to_value(&self.ndp_proxy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ndp_proxy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ndp_proxy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/ndp-proxies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxy": {} })); - }); - - let endpoint = Request::builder() - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/ndp-proxies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxy": {} })); - }); - - let endpoint = Request::builder() - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/ndp_proxy/delete.rs b/openstack_sdk/src/api/network/v2/ndp_proxy/delete.rs deleted file mode 100644 index 81c37db6d..000000000 --- a/openstack_sdk/src/api/network/v2/ndp_proxy/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/ndp-proxies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ndp_Proxy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("ndp-proxies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/ndp-proxies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/ndp-proxies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/ndp_proxy/find.rs b/openstack_sdk/src/api/network/v2/ndp_proxy/find.rs deleted file mode 100644 index 4b6a3bc34..000000000 --- a/openstack_sdk/src/api/network/v2/ndp_proxy/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::ndp_proxy::{get as Get, list as List}; - -/// Find for ndp_proxy 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/ndp_proxy/get.rs b/openstack_sdk/src/api/network/v2/ndp_proxy/get.rs deleted file mode 100644 index cd5f7c570..000000000 --- a/openstack_sdk/src/api/network/v2/ndp_proxy/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/ndp-proxies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ndp_Proxy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("ndp-proxies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ndp_proxy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ndp_proxy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ndp-proxies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxy": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ndp-proxies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/ndp_proxy/list.rs b/openstack_sdk/src/api/network/v2/ndp_proxy/list.rs deleted file mode 100644 index 7d91119c4..000000000 --- a/openstack_sdk/src/api/network/v2/ndp_proxy/list.rs +++ /dev/null @@ -1,260 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/ndp-proxies API - #[builder(default, setter(into))] - description: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/ndp-proxies API - #[builder(default, setter(into))] - name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// revision_number query parameter for /v2.0/ndp-proxies API - #[builder(default, setter(into))] - revision_number: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Ndp_Proxy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "ndp-proxies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ndp_proxies".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ndp_proxies" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/ndp-proxies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxies": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/ndp-proxies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxies": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/ndp_proxy/set.rs b/openstack_sdk/src/api/network/v2/ndp_proxy/set.rs deleted file mode 100644 index d81a926d5..000000000 --- a/openstack_sdk/src/api/network/v2/ndp_proxy/set.rs +++ /dev/null @@ -1,221 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct NdpProxy<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) ndp_proxy: NdpProxy<'a>, - - /// id parameter for /v2.0/ndp-proxies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ndp_Proxy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("ndp-proxies/{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("ndp_proxy", serde_json::to_value(&self.ndp_proxy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ndp_proxy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ndp_proxy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/ndp-proxies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/ndp-proxies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ndp_proxy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/create.rs b/openstack_sdk/src/api/network/v2/network/create.rs deleted file mode 100644 index 8e1d324f3..000000000 --- a/openstack_sdk/src/api/network/v2/network/create.rs +++ /dev/null @@ -1,365 +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`. - -//! Creates a network. -//! -//! A request body is optional. An administrative user can specify another -//! project ID, which is the project that owns the network, in the request -//! body. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Segments<'a> { - #[serde( - rename = "provider:network_type", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_network_type: Option>, - - #[serde( - rename = "provider:physical_network", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_physical_network: Option>, - - #[serde( - rename = "provider:segmentation_id", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_segmentation_id: Option, -} - -/// A `network` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Network<'a> { - /// The administrative state of the network, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// The availability zone candidate for the network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone_hints: Option>>, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// A valid DNS domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_domain: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ha: Option, - - /// The network is default or not. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_default: Option, - - /// The maximum transmission unit (MTU) value to address fragmentation. - /// Minimum value is 68 for IPv4, and 1280 for IPv6. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) mtu: Option, - - /// Human-readable name of the network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The port security status of the network. Valid values are enabled - /// (`true`) and disabled (`false`). This value is used as the default - /// value of `port_security_enabled` field of a newly created port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_security_enabled: Option, - - /// The type of physical network that this network should be mapped to. For - /// example, `flat`, `vlan`, `vxlan`, or `gre`. Valid values depend on a - /// networking back-end. - #[serde( - rename = "provider:network_type", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_network_type: Option>, - - /// The physical network where this network should be implemented. The - /// Networking API v2.0 does not provide a way to list available physical - /// networks. For example, the Open vSwitch plug-in configuration file - /// defines a symbolic name that maps to specific bridges on each compute - /// host. - #[serde( - rename = "provider:physical_network", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_physical_network: Option>, - - /// The ID of the isolated segment on the physical network. The - /// `network_type` attribute defines the segmentation model. For example, - /// if the `network_type` value is vlan, this ID is a vlan identifier. If - /// the `network_type` value is gre, this ID is a gre key. - #[serde( - rename = "provider:segmentation_id", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_segmentation_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qinq: Option, - - /// The ID of the QoS policy associated with the network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, - - /// Indicates whether the network has an external routing facility that’s - /// not managed by the networking service. - #[serde(rename = "router:external", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) router_external: Option, - - /// A list of provider `segment` objects. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) segments: Option>>, - - /// Indicates whether this resource is shared across all projects. By - /// default, only administrative users can change this value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// Indicates the VLAN transparency mode of the network, which is VLAN - /// transparent (`true`) or not VLAN transparent (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vlan_transparent: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `network` object. - #[builder(setter(into))] - pub(crate) network: Network<'a>, - - #[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 Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "networks".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("network", serde_json::to_value(&self.network)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .network(NetworkBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .network(NetworkBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "network" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/networks".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network": {} })); - }); - - let endpoint = Request::builder() - .network(NetworkBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/networks".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network": {} })); - }); - - let endpoint = Request::builder() - .network(NetworkBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/delete.rs b/openstack_sdk/src/api/network/v2/network/delete.rs deleted file mode 100644 index 0fb0c7b53..000000000 --- a/openstack_sdk/src/api/network/v2/network/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a network and its associated resources. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// network_id parameter for /v2.0/networks/{network_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<'a> RequestBuilder<'a> { - /// Add a single header to the Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("networks/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/networks/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/networks/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/dhcp_agent/create.rs b/openstack_sdk/src/api/network/v2/network/dhcp_agent/create.rs deleted file mode 100644 index bf10684d6..000000000 --- a/openstack_sdk/src/api/network/v2/network/dhcp_agent/create.rs +++ /dev/null @@ -1,216 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} - /// API - #[builder(default, setter(into))] - network_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Dhcp_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "networks/{network_id}/dhcp-agents", - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/networks/{network_id}/dhcp-agents", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().network_id("network_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/networks/{network_id}/dhcp-agents", - network_id = "network_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() - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/dhcp_agent/delete.rs b/openstack_sdk/src/api/network/v2/network/dhcp_agent/delete.rs deleted file mode 100644 index cbfa03ad4..000000000 --- a/openstack_sdk/src/api/network/v2/network/dhcp_agent/delete.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} - /// API - #[builder(default, setter(into))] - network_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 Dhcp_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "networks/{network_id}/dhcp-agents/{id}", - id = self.id.as_ref(), - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/networks/{network_id}/dhcp-agents/{id}", - id = "id", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_id("network_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/networks/{network_id}/dhcp-agents/{id}", - id = "id", - network_id = "network_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") - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/dhcp_agent/get.rs b/openstack_sdk/src/api/network/v2/network/dhcp_agent/get.rs deleted file mode 100644 index 3a2d40fa2..000000000 --- a/openstack_sdk/src/api/network/v2/network/dhcp_agent/get.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} - /// API - #[builder(default, setter(into))] - network_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 Dhcp_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "networks/{network_id}/dhcp-agents/{id}", - id = self.id.as_ref(), - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/networks/{network_id}/dhcp-agents/{id}", - id = "id", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_id("network_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/networks/{network_id}/dhcp-agents/{id}", - id = "id", - network_id = "network_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") - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/dhcp_agent/list.rs b/openstack_sdk/src/api/network/v2/network/dhcp_agent/list.rs deleted file mode 100644 index 63b7aa24e..000000000 --- a/openstack_sdk/src/api/network/v2/network/dhcp_agent/list.rs +++ /dev/null @@ -1,276 +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`. - -//! Lists DHCP agents hosting a network. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} - /// API - #[builder(default, setter(into))] - network_id: Cow<'a, str>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Dhcp_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "networks/{network_id}/dhcp-agents", - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/networks/{network_id}/dhcp-agents", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().network_id("network_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/networks/{network_id}/dhcp-agents", - network_id = "network_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() - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/dhcp_agent/set.rs b/openstack_sdk/src/api/network/v2/network/dhcp_agent/set.rs deleted file mode 100644 index 058e3d778..000000000 --- a/openstack_sdk/src/api/network/v2/network/dhcp_agent/set.rs +++ /dev/null @@ -1,228 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} - /// API - #[builder(default, setter(into))] - network_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 Dhcp_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "networks/{network_id}/dhcp-agents/{id}", - id = self.id.as_ref(), - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/networks/{network_id}/dhcp-agents/{id}", - id = "id", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_id("network_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/networks/{network_id}/dhcp-agents/{id}", - id = "id", - network_id = "network_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") - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/find.rs b/openstack_sdk/src/api/network/v2/network/find.rs deleted file mode 100644 index 41a07cb35..000000000 --- a/openstack_sdk/src/api/network/v2/network/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::network::{get as Get, list as List}; - -/// Find for network 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/network/get.rs b/openstack_sdk/src/api/network/v2/network/get.rs deleted file mode 100644 index e4a2925c7..000000000 --- a/openstack_sdk/src/api/network/v2/network/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for a network. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// network_id parameter for /v2.0/networks/{network_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<'a> RequestBuilder<'a> { - /// Add a single header to the Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("networks/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "network" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/networks/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/networks/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/list.rs b/openstack_sdk/src/api/network/v2/network/list.rs deleted file mode 100644 index 6bd18c367..000000000 --- a/openstack_sdk/src/api/network/v2/network/list.rs +++ /dev/null @@ -1,429 +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`. - -//! Lists networks to which the project has access. -//! -//! Default policy settings return only networks that the project who submits -//! the request owns, unless an administrative user submits the request. In -//! addition, networks shared with the project who submits the request are also -//! returned. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! You can also use the `tags`, `tags-any`, `not-tags`, `not-tags-any` query -//! parameter to filter the response with tags. For information, see -//! [REST API Impact](http://specs.openstack.org/openstack/neutron-specs/specs/mitaka/add-tags-to-core-resources.html#rest-api-impact). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// admin_state_up query parameter for /v2.0/networks API - #[builder(default)] - admin_state_up: Option, - - /// description query parameter for /v2.0/networks API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/networks API - #[builder(default, setter(into))] - id: Option>, - - /// is_default query parameter for /v2.0/networks API - #[builder(default)] - is_default: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// mtu query parameter for /v2.0/networks API - #[builder(default)] - mtu: Option, - - /// name query parameter for /v2.0/networks API - #[builder(default, setter(into))] - name: Option>, - - /// not-tags query parameter for /v2.0/networks API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/networks API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// provider:network_type query parameter for /v2.0/networks API - #[builder(default, setter(into))] - provider_network_type: Option>, - - /// provider:physical_network query parameter for /v2.0/networks API - #[builder(default, setter(into))] - provider_physical_network: Option>, - - /// provider:segmentation_id query parameter for /v2.0/networks API - #[builder(default)] - provider_segmentation_id: Option, - - /// qinq query parameter for /v2.0/networks API - #[builder(default)] - qinq: Option, - - /// revision_number query parameter for /v2.0/networks API - #[builder(default, setter(into))] - revision_number: Option>, - - /// router:external query parameter for /v2.0/networks API - #[builder(default)] - router_external: Option, - - /// shared query parameter for /v2.0/networks API - #[builder(default)] - shared: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// status query parameter for /v2.0/networks API - #[builder(default, setter(into))] - status: Option>, - - /// tags query parameter for /v2.0/networks API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/networks API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/networks API - #[builder(default, setter(into))] - tenant_id: Option>, - - /// vlan_transparent query parameter for /v2.0/networks API - #[builder(default)] - vlan_transparent: 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> { - /// not-tags query parameter for /v2.0/networks API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/networks API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/networks API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/networks API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "networks".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("is_default", self.is_default); - params.push_opt("mtu", self.mtu); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("provider:network_type", self.provider_network_type.as_ref()); - params.push_opt( - "provider:physical_network", - self.provider_physical_network.as_ref(), - ); - params.push_opt("provider:segmentation_id", self.provider_segmentation_id); - params.push_opt("qinq", self.qinq); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("router:external", self.router_external); - params.push_opt("shared", self.shared); - params.push_opt("status", self.status.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - params.push_opt("vlan_transparent", self.vlan_transparent); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("networks".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "networks" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/networks".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "networks": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/networks".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "networks": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/set.rs b/openstack_sdk/src/api/network/v2/network/set.rs deleted file mode 100644 index dc7af37f4..000000000 --- a/openstack_sdk/src/api/network/v2/network/set.rs +++ /dev/null @@ -1,338 +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`. - -//! Updates a network. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Segments<'a> { - #[serde( - rename = "provider:network_type", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_network_type: Option>, - - #[serde( - rename = "provider:physical_network", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_physical_network: Option>, - - #[serde( - rename = "provider:segmentation_id", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_segmentation_id: Option, -} - -/// A `network` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Network<'a> { - /// The administrative state of the network, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// A valid DNS domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_domain: Option>, - - /// The network is default or not. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_default: Option, - - /// The maximum transmission unit (MTU) value to address fragmentation. - /// Minimum value is 68 for IPv4, and 1280 for IPv6. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) mtu: Option, - - /// Human-readable name of the network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The port security status of the network. Valid values are enabled - /// (`true`) and disabled (`false`). This value is used as the default - /// value of `port_security_enabled` field of a newly created port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_security_enabled: Option, - - /// The type of physical network that this network is mapped to. For - /// example, `flat`, `vlan`, `vxlan`, or `gre`. Valid values depend on a - /// networking back-end. - #[serde( - rename = "provider:network_type", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_network_type: Option>, - - /// The physical network where this network/segment is implemented. - #[serde( - rename = "provider:physical_network", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_physical_network: Option>, - - /// The ID of the isolated segment on the physical network. The - /// `network_type` attribute defines the segmentation model. For example, - /// if the `network_type` value is vlan, this ID is a vlan identifier. If - /// the `network_type` value is gre, this ID is a gre key. `Note` that only - /// the segmentation-id of VLAN type networks can be changed! - #[serde( - rename = "provider:segmentation_id", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) provider_segmentation_id: Option>, - - /// The ID of the QoS policy associated with the network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, - - /// Indicates whether the network has an external routing facility that’s - /// not managed by the networking service. - #[serde(rename = "router:external", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) router_external: Option, - - /// A list of provider `segment` objects. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) segments: Option>>, - - /// Indicates whether this resource is shared across all projects. By - /// default, only administrative users can change this value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `network` object. - #[builder(setter(into))] - pub(crate) network: Network<'a>, - - /// network_id parameter for /v2.0/networks/{network_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<'a> RequestBuilder<'a> { - /// Add a single header to the Network. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("networks/{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("network", serde_json::to_value(&self.network)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .network(NetworkBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .network(NetworkBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "network" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/networks/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network(NetworkBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/networks/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network(NetworkBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/tag/delete.rs b/openstack_sdk/src/api/network/v2/network/tag/delete.rs deleted file mode 100644 index b080028b3..000000000 --- a/openstack_sdk/src/api/network/v2/network/tag/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - network_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "networks/{network_id}/tags/{id}", - id = self.id.as_ref(), - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/networks/{network_id}/tags/{id}", - id = "id", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_id("network_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/networks/{network_id}/tags/{id}", - id = "id", - network_id = "network_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") - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/network/tag/delete_all.rs deleted file mode 100644 index 8a5edfd07..000000000 --- a/openstack_sdk/src/api/network/v2/network/tag/delete_all.rs +++ /dev/null @@ -1,188 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - network_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "networks/{network_id}/tags", - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/networks/{network_id}/tags", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().network_id("network_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/networks/{network_id}/tags", - network_id = "network_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() - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/tag/get.rs b/openstack_sdk/src/api/network/v2/network/tag/get.rs deleted file mode 100644 index 4d122f7ec..000000000 --- a/openstack_sdk/src/api/network/v2/network/tag/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - network_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "networks/{network_id}/tags/{id}", - id = self.id.as_ref(), - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/networks/{network_id}/tags/{id}", - id = "id", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_id("network_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/networks/{network_id}/tags/{id}", - id = "id", - network_id = "network_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") - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/tag/list.rs b/openstack_sdk/src/api/network/v2/network/tag/list.rs deleted file mode 100644 index 7e57bb5da..000000000 --- a/openstack_sdk/src/api/network/v2/network/tag/list.rs +++ /dev/null @@ -1,259 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - network_id: Cow<'a, str>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "networks/{network_id}/tags", - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/networks/{network_id}/tags", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().network_id("network_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/networks/{network_id}/tags", - network_id = "network_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/tag/replace.rs b/openstack_sdk/src/api/network/v2/network/tag/replace.rs deleted file mode 100644 index 2298b2b82..000000000 --- a/openstack_sdk/src/api/network/v2/network/tag/replace.rs +++ /dev/null @@ -1,216 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - network_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "networks/{network_id}/tags", - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/networks/{network_id}/tags", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .network_id("network_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/networks/{network_id}/tags", - network_id = "network_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .network_id("network_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network/tag/set.rs b/openstack_sdk/src/api/network/v2/network/tag/set.rs deleted file mode 100644 index 38b8a12c9..000000000 --- a/openstack_sdk/src/api/network/v2/network/tag/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API - #[builder(default, setter(into))] - network_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "networks/{network_id}/tags/{id}", - id = self.id.as_ref(), - network_id = self.network_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/networks/{network_id}/tags/{id}", - id = "id", - network_id = "network_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_id("network_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/networks/{network_id}/tags/{id}", - id = "id", - network_id = "network_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") - .network_id("network_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_ip_availability/create.rs b/openstack_sdk/src/api/network/v2/network_ip_availability/create.rs deleted file mode 100644 index 82b850aa4..000000000 --- a/openstack_sdk/src/api/network/v2/network_ip_availability/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_network_ip_availability"))] - pub(crate) network_ip_availability: BTreeMap, Value>, - - #[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 network_ip_availability(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.network_ip_availability - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Network_Ip_Availability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "network-ip-availabilities".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "network_ip_availability", - serde_json::to_value(&self.network_ip_availability)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_ip_availability".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .network_ip_availability(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .network_ip_availability(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "network_ip_availability" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/network-ip-availabilities".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availability": {} })); - }); - - let endpoint = Request::builder() - .network_ip_availability(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/network-ip-availabilities".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availability": {} })); - }); - - let endpoint = Request::builder() - .network_ip_availability(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_ip_availability/delete.rs b/openstack_sdk/src/api/network/v2/network_ip_availability/delete.rs deleted file mode 100644 index b344305b0..000000000 --- a/openstack_sdk/src/api/network/v2/network_ip_availability/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/network-ip-availabilities/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Network_Ip_Availability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("network-ip-availabilities/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/network-ip-availabilities/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/network-ip-availabilities/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_ip_availability/get.rs b/openstack_sdk/src/api/network/v2/network_ip_availability/get.rs deleted file mode 100644 index a880bd2e2..000000000 --- a/openstack_sdk/src/api/network/v2/network_ip_availability/get.rs +++ /dev/null @@ -1,194 +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`. - -//! Shows network IP availability details for a network. -//! -//! By default policy configuration, only administrative users can retrieve IP -//! availability. Otherwise, `Not Found (404)` will be returned. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/network-ip-availabilities/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Network_Ip_Availability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("network-ip-availabilities/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_ip_availability".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "network_ip_availability" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/network-ip-availabilities/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availability": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/network-ip-availabilities/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availability": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_ip_availability/list.rs b/openstack_sdk/src/api/network/v2/network_ip_availability/list.rs deleted file mode 100644 index 833e9d9ef..000000000 --- a/openstack_sdk/src/api/network/v2/network_ip_availability/list.rs +++ /dev/null @@ -1,287 +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`. - -//! Lists network IP availability of all networks. -//! -//! By default policy configuration, only administrative users can retrieve IP -//! availabilities. Otherwise, an empty list will be returned. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// ip_version query parameter for /v2.0/network-ip-availabilities API - #[builder(default, setter(into))] - ip_version: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// network_id query parameter for /v2.0/network-ip-availabilities API - #[builder(default, setter(into))] - network_id: Option>, - - /// network_name query parameter for /v2.0/network-ip-availabilities API - #[builder(default, setter(into))] - network_name: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tenant_id query parameter for /v2.0/network-ip-availabilities API - #[builder(default, setter(into))] - tenant_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Network_Ip_Availability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "network-ip-availabilities".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("ip_version", self.ip_version.as_ref()); - params.push_opt("network_id", self.network_id.as_ref()); - params.push_opt("network_name", self.network_name.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_ip_availabilities".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "network_ip_availabilities" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/network-ip-availabilities".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availabilities": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/network-ip-availabilities".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availabilities": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_ip_availability/set.rs b/openstack_sdk/src/api/network/v2/network_ip_availability/set.rs deleted file mode 100644 index 47ca5dbda..000000000 --- a/openstack_sdk/src/api/network/v2/network_ip_availability/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_network_ip_availability"))] - pub(crate) network_ip_availability: BTreeMap, Value>, - - /// id parameter for /v2.0/network-ip-availabilities/{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<'a> RequestBuilder<'a> { - pub fn network_ip_availability(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.network_ip_availability - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Network_Ip_Availability. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("network-ip-availabilities/{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( - "network_ip_availability", - serde_json::to_value(&self.network_ip_availability)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_ip_availability".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .network_ip_availability(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .network_ip_availability(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "network_ip_availability" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/network-ip-availabilities/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availability": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_ip_availability(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/network-ip-availabilities/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_ip_availability": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_ip_availability(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/create.rs b/openstack_sdk/src/api/network/v2/network_segment_range/create.rs deleted file mode 100644 index 73b089ccd..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/create.rs +++ /dev/null @@ -1,254 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum NetworkType { - #[serde(rename = "geneve")] - Geneve, - #[serde(rename = "gre")] - Gre, - #[serde(rename = "vlan")] - Vlan, - #[serde(rename = "vxlan")] - Vxlan, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct NetworkSegmentRange<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) network_type: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) physical_network: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) network_segment_range: NetworkSegmentRange<'a>, - - #[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 Network_Segment_Range. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "network-segment-ranges".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "network_segment_range", - serde_json::to_value(&self.network_segment_range)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_segment_range".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "network_segment_range" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/network-segment-ranges".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_range": {} })); - }); - - let endpoint = Request::builder() - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/network-segment-ranges".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_range": {} })); - }); - - let endpoint = Request::builder() - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/delete.rs b/openstack_sdk/src/api/network/v2/network_segment_range/delete.rs deleted file mode 100644 index f17d279da..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/network-segment-ranges/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Network_Segment_Range. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("network-segment-ranges/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/network-segment-ranges/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/network-segment-ranges/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/find.rs b/openstack_sdk/src/api/network/v2/network_segment_range/find.rs deleted file mode 100644 index 8cfbacb69..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::network_segment_range::{get as Get, list as List}; - -/// Find for network_segment_range 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/get.rs b/openstack_sdk/src/api/network/v2/network_segment_range/get.rs deleted file mode 100644 index 8d711084c..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/network-segment-ranges/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Network_Segment_Range. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("network-segment-ranges/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_segment_range".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "network_segment_range" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/network-segment-ranges/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_range": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/network-segment-ranges/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_range": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/list.rs b/openstack_sdk/src/api/network/v2/network_segment_range/list.rs deleted file mode 100644 index 6f1cf8de7..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/list.rs +++ /dev/null @@ -1,353 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/network-segment-ranges API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/network-segment-ranges API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/network-segment-ranges API - #[builder(default, setter(into))] - name: Option>, - - /// network_type query parameter for /v2.0/network-segment-ranges API - #[builder(default, setter(into))] - network_type: Option>, - - /// not-tags query parameter for /v2.0/network-segment-ranges API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/network-segment-ranges API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// physical_network query parameter for /v2.0/network-segment-ranges API - #[builder(default, setter(into))] - physical_network: Option>, - - /// project_id query parameter for /v2.0/network-segment-ranges API - #[builder(default, setter(into))] - project_id: Option>, - - /// revision_number query parameter for /v2.0/network-segment-ranges API - #[builder(default, setter(into))] - revision_number: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tags query parameter for /v2.0/network-segment-ranges API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/network-segment-ranges API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: 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> { - /// not-tags query parameter for /v2.0/network-segment-ranges API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/network-segment-ranges API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/network-segment-ranges API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/network-segment-ranges API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Network_Segment_Range. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "network-segment-ranges".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("network_type", self.network_type.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("physical_network", self.physical_network.as_ref()); - params.push_opt("project_id", self.project_id.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_segment_ranges".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "network_segment_ranges" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/network-segment-ranges".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_ranges": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/network-segment-ranges".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_ranges": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/set.rs b/openstack_sdk/src/api/network/v2/network_segment_range/set.rs deleted file mode 100644 index 72a1bd606..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/set.rs +++ /dev/null @@ -1,232 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct NetworkSegmentRange<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) maximum: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) minimum: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) network_segment_range: NetworkSegmentRange<'a>, - - /// id parameter for /v2.0/network-segment-ranges/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Network_Segment_Range. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("network-segment-ranges/{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( - "network_segment_range", - serde_json::to_value(&self.network_segment_range)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("network_segment_range".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "network_segment_range" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/network-segment-ranges/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_range": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/network-segment-ranges/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "network_segment_range": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/tag/delete.rs b/openstack_sdk/src/api/network/v2/network_segment_range/tag/delete.rs deleted file mode 100644 index 458041cfb..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/tag/delete.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_segment_range_id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - network_segment_range_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = self.id.as_ref(), - network_segment_range_id = self.network_segment_range_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = "id", - network_segment_range_id = "network_segment_range_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_segment_range_id("network_segment_range_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = "id", - network_segment_range_id = "network_segment_range_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") - .network_segment_range_id("network_segment_range_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/network_segment_range/tag/delete_all.rs deleted file mode 100644 index cb69a61d1..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/tag/delete_all.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// network_segment_range_id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - network_segment_range_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = self.network_segment_range_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = "network_segment_range_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .network_segment_range_id("network_segment_range_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = "network_segment_range_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() - .network_segment_range_id("network_segment_range_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/tag/get.rs b/openstack_sdk/src/api/network/v2/network_segment_range/tag/get.rs deleted file mode 100644 index 2eece9a82..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/tag/get.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_segment_range_id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - network_segment_range_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = self.id.as_ref(), - network_segment_range_id = self.network_segment_range_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = "id", - network_segment_range_id = "network_segment_range_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_segment_range_id("network_segment_range_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = "id", - network_segment_range_id = "network_segment_range_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") - .network_segment_range_id("network_segment_range_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/tag/list.rs b/openstack_sdk/src/api/network/v2/network_segment_range/tag/list.rs deleted file mode 100644 index 8930ee0bb..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/tag/list.rs +++ /dev/null @@ -1,263 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// network_segment_range_id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - network_segment_range_id: Cow<'a, str>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = self.network_segment_range_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = "network_segment_range_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .network_segment_range_id("network_segment_range_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = "network_segment_range_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .network_segment_range_id("network_segment_range_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/tag/replace.rs b/openstack_sdk/src/api/network/v2/network_segment_range/tag/replace.rs deleted file mode 100644 index 1068ed996..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/tag/replace.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// network_segment_range_id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - network_segment_range_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = self.network_segment_range_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = "network_segment_range_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .network_segment_range_id("network_segment_range_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags", - network_segment_range_id = "network_segment_range_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .network_segment_range_id("network_segment_range_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/tag/set.rs b/openstack_sdk/src/api/network/v2/network_segment_range/tag/set.rs deleted file mode 100644 index e871f27d4..000000000 --- a/openstack_sdk/src/api/network/v2/network_segment_range/tag/set.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// network_segment_range_id parameter for - /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API - #[builder(default, setter(into))] - network_segment_range_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = self.id.as_ref(), - network_segment_range_id = self.network_segment_range_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = "id", - network_segment_range_id = "network_segment_range_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .network_segment_range_id("network_segment_range_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/network_segment_ranges/{network_segment_range_id}/tags/{id}", - id = "id", - network_segment_range_id = "network_segment_range_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") - .network_segment_range_id("network_segment_range_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/create.rs b/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/create.rs deleted file mode 100644 index fb0df3171..000000000 --- a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/create.rs +++ /dev/null @@ -1,246 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PacketRateLimitRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_burst_kpps: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_kpps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) packet_rate_limit_rule: PacketRateLimitRule, - - /// policy_id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Packet_Rate_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "policies/{policy_id}/packet_rate_limit_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "packet_rate_limit_rule", - serde_json::to_value(&self.packet_rate_limit_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("packet_rate_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "packet_rate_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/policies/{policy_id}/packet_rate_limit_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/policies/{policy_id}/packet_rate_limit_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/delete.rs b/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/delete.rs deleted file mode 100644 index 79a319141..000000000 --- a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/delete.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Packet_Rate_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/packet_rate_limit_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/policies/{policy_id}/packet_rate_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/policies/{policy_id}/packet_rate_limit_rules/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/get.rs b/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/get.rs deleted file mode 100644 index 0ae7659e5..000000000 --- a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/get.rs +++ /dev/null @@ -1,205 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Packet_Rate_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/packet_rate_limit_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("packet_rate_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "packet_rate_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/packet_rate_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/packet_rate_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/list.rs b/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/list.rs deleted file mode 100644 index e3bed8b02..000000000 --- a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/list.rs +++ /dev/null @@ -1,284 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// direction query parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API - #[builder(default, setter(into))] - direction: Option>, - - /// id query parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// max_burst_kpps query parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API - #[builder(default)] - max_burst_kpps: Option, - - /// max_kpps query parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API - #[builder(default)] - max_kpps: Option, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// policy_id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Packet_Rate_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/packet_rate_limit_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("max_burst_kpps", self.max_burst_kpps); - params.push_opt("max_kpps", self.max_kpps); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("packet_rate_limit_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "packet_rate_limit_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/packet_rate_limit_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rules": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/packet_rate_limit_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rules": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/set.rs b/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/set.rs deleted file mode 100644 index e21e91cd9..000000000 --- a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule/set.rs +++ /dev/null @@ -1,256 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct PacketRateLimitRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_burst_kpps: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_kpps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) packet_rate_limit_rule: PacketRateLimitRule, - - /// id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Packet_Rate_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/packet_rate_limit_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "packet_rate_limit_rule", - serde_json::to_value(&self.packet_rate_limit_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("packet_rate_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "packet_rate_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/policies/{policy_id}/packet_rate_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/policies/{policy_id}/packet_rate_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "packet_rate_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/tag/delete.rs b/openstack_sdk/src/api/network/v2/policy/tag/delete.rs deleted file mode 100644 index a7db35957..000000000 --- a/openstack_sdk/src/api/network/v2/policy/tag/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - policy_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/tags/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/policies/{policy_id}/tags/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/policies/{policy_id}/tags/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/policy/tag/delete_all.rs deleted file mode 100644 index 175cb7f00..000000000 --- a/openstack_sdk/src/api/network/v2/policy/tag/delete_all.rs +++ /dev/null @@ -1,188 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - policy_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/tags", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/policies/{policy_id}/tags", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/policies/{policy_id}/tags", - policy_id = "policy_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() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/tag/get.rs b/openstack_sdk/src/api/network/v2/policy/tag/get.rs deleted file mode 100644 index b94cb5221..000000000 --- a/openstack_sdk/src/api/network/v2/policy/tag/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - policy_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/tags/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/tags/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/tags/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/tag/list.rs b/openstack_sdk/src/api/network/v2/policy/tag/list.rs deleted file mode 100644 index a9fe2b469..000000000 --- a/openstack_sdk/src/api/network/v2/policy/tag/list.rs +++ /dev/null @@ -1,259 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "policies/{policy_id}/tags", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/policies/{policy_id}/tags", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/policies/{policy_id}/tags", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/tag/replace.rs b/openstack_sdk/src/api/network/v2/policy/tag/replace.rs deleted file mode 100644 index 51a667037..000000000 --- a/openstack_sdk/src/api/network/v2/policy/tag/replace.rs +++ /dev/null @@ -1,216 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - policy_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/tags", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/policies/{policy_id}/tags", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/policies/{policy_id}/tags", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/policy/tag/set.rs b/openstack_sdk/src/api/network/v2/policy/tag/set.rs deleted file mode 100644 index bff51964a..000000000 --- a/openstack_sdk/src/api/network/v2/policy/tag/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API - #[builder(default, setter(into))] - policy_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "policies/{policy_id}/tags/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/policies/{policy_id}/tags/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/policies/{policy_id}/tags/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/binding/create.rs b/openstack_sdk/src/api/network/v2/port/binding/create.rs deleted file mode 100644 index da55092a4..000000000 --- a/openstack_sdk/src/api/network/v2/port/binding/create.rs +++ /dev/null @@ -1,273 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum VnicType { - #[serde(rename = "accelerator-direct")] - AcceleratorDirect, - #[serde(rename = "accelerator-direct-physical")] - AcceleratorDirectPhysical, - #[serde(rename = "baremetal")] - Baremetal, - #[serde(rename = "direct")] - Direct, - #[serde(rename = "direct-physical")] - DirectPhysical, - #[serde(rename = "macvtap")] - Macvtap, - #[serde(rename = "normal")] - Normal, - #[serde(rename = "remote-managed")] - RemoteManaged, - #[serde(rename = "smart-nic")] - SmartNic, - #[serde(rename = "vdpa")] - Vdpa, - #[serde(rename = "virtio-forwarder")] - VirtioForwarder, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Binding<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_profile"))] - pub(crate) profile: Option, Value>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) vnic_type: Option, -} - -impl<'a> BindingBuilder<'a> { - pub fn profile(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.profile - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) binding: Binding<'a>, - - /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - port_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 Binding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!("ports/{port_id}/bindings", port_id = self.port_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("binding", serde_json::to_value(&self.binding)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("binding".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .binding(BindingBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .binding(BindingBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "binding" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "binding": {} })); - }); - - let endpoint = Request::builder() - .port_id("port_id") - .binding(BindingBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "binding": {} })); - }); - - let endpoint = Request::builder() - .port_id("port_id") - .binding(BindingBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/binding/delete.rs b/openstack_sdk/src/api/network/v2/port/binding/delete.rs deleted file mode 100644 index b1ca3426b..000000000 --- a/openstack_sdk/src/api/network/v2/port/binding/delete.rs +++ /dev/null @@ -1,204 +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`. - -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - port_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 Binding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "ports/{port_id}/bindings/{id}", - id = self.id.as_ref(), - port_id = self.port_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/ports/{port_id}/bindings/{id}", - id = "id", - port_id = "port_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/ports/{port_id}/bindings/{id}", - id = "id", - port_id = "port_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") - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/binding/get.rs b/openstack_sdk/src/api/network/v2/port/binding/get.rs deleted file mode 100644 index 57450c36e..000000000 --- a/openstack_sdk/src/api/network/v2/port/binding/get.rs +++ /dev/null @@ -1,203 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - port_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 Binding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "ports/{port_id}/bindings/{id}", - id = self.id.as_ref(), - port_id = self.port_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("binding".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "binding" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/ports/{port_id}/bindings/{id}", - id = "id", - port_id = "port_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "binding": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/ports/{port_id}/bindings/{id}", - id = "id", - port_id = "port_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "binding": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/binding/list.rs b/openstack_sdk/src/api/network/v2/port/binding/list.rs deleted file mode 100644 index b1ef273f8..000000000 --- a/openstack_sdk/src/api/network/v2/port/binding/list.rs +++ /dev/null @@ -1,277 +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`. - -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// host query parameter for /v2.0/ports/{port_id}/bindings API - #[builder(default, setter(into))] - host: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - port_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// status query parameter for /v2.0/ports/{port_id}/bindings API - #[builder(default, setter(into))] - status: Option>, - - /// vif_type query parameter for /v2.0/ports/{port_id}/bindings API - #[builder(default, setter(into))] - vif_type: Option>, - - /// vnic_type query parameter for /v2.0/ports/{port_id}/bindings API - #[builder(default, setter(into))] - vnic_type: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Binding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("ports/{port_id}/bindings", port_id = self.port_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("host", self.host.as_ref()); - params.push_opt("status", self.status.as_ref()); - params.push_opt("vif_type", self.vif_type.as_ref()); - params.push_opt("vnic_type", self.vnic_type.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("bindings".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "bindings" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bindings": {} })); - }); - - let endpoint = Request::builder().port_id("port_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bindings": {} })); - }); - - let endpoint = Request::builder() - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/binding/set.rs b/openstack_sdk/src/api/network/v2/port/binding/set.rs deleted file mode 100644 index 193b92e54..000000000 --- a/openstack_sdk/src/api/network/v2/port/binding/set.rs +++ /dev/null @@ -1,287 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum VnicType { - #[serde(rename = "accelerator-direct")] - AcceleratorDirect, - #[serde(rename = "accelerator-direct-physical")] - AcceleratorDirectPhysical, - #[serde(rename = "baremetal")] - Baremetal, - #[serde(rename = "direct")] - Direct, - #[serde(rename = "direct-physical")] - DirectPhysical, - #[serde(rename = "macvtap")] - Macvtap, - #[serde(rename = "normal")] - Normal, - #[serde(rename = "remote-managed")] - RemoteManaged, - #[serde(rename = "smart-nic")] - SmartNic, - #[serde(rename = "vdpa")] - Vdpa, - #[serde(rename = "virtio-forwarder")] - VirtioForwarder, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Binding<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_profile"))] - pub(crate) profile: Option, Value>>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) vnic_type: Option, -} - -impl<'a> BindingBuilder<'a> { - pub fn profile(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.profile - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) binding: Binding<'a>, - - /// id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API - #[builder(default, setter(into))] - port_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 Binding. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "ports/{port_id}/bindings/{id}", - id = self.id.as_ref(), - port_id = self.port_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("binding", serde_json::to_value(&self.binding)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("binding".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .binding(BindingBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .binding(BindingBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "binding" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/ports/{port_id}/bindings/{id}", - id = "id", - port_id = "port_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "binding": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .binding(BindingBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/ports/{port_id}/bindings/{id}", - id = "id", - port_id = "port_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "binding": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .binding(BindingBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/create.rs b/openstack_sdk/src/api/network/v2/port/create.rs deleted file mode 100644 index 38f750a96..000000000 --- a/openstack_sdk/src/api/network/v2/port/create.rs +++ /dev/null @@ -1,518 +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`. - -//! Creates a port on a network. -//! -//! To define the network in which to create the port, specify the `network_id` -//! attribute in the request body. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllowedAddressPairs<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_address: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum BindingVnicType { - #[serde(rename = "accelerator-direct")] - AcceleratorDirect, - #[serde(rename = "accelerator-direct-physical")] - AcceleratorDirectPhysical, - #[serde(rename = "baremetal")] - Baremetal, - #[serde(rename = "direct")] - Direct, - #[serde(rename = "direct-physical")] - DirectPhysical, - #[serde(rename = "macvtap")] - Macvtap, - #[serde(rename = "normal")] - Normal, - #[serde(rename = "remote-managed")] - RemoteManaged, - #[serde(rename = "smart-nic")] - SmartNic, - #[serde(rename = "vdpa")] - Vdpa, - #[serde(rename = "virtio-forwarder")] - VirtioForwarder, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct FixedIps<'a> { - /// IP Address - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>, - - /// The subnet ID from which the IP address is assigned - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum NumaAffinityPolicy { - #[serde(rename = "legacy")] - Legacy, - #[serde(rename = "preferred")] - Preferred, - #[serde(rename = "required")] - Required, - #[serde(rename = "socket")] - Socket, -} - -/// A `port` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Port<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A set of zero or more allowed address pair objects each where address - /// pair object contains an `ip_address` and `mac_address`. While the - /// `ip_address` is required, the `mac_address` will be taken from the port - /// if not specified. The value of `ip_address` can be an IP Address or a - /// CIDR (if supported by the underlying extension plugin). A server - /// connected to the port can send a packet with source address which - /// matches one of the specified allowed address pairs. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allowed_address_pairs: Option>>, - - /// The ID of the host where the port resides. The default is an empty - /// string. - #[serde(rename = "binding:host_id", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) binding_host_id: Option>, - - /// A dictionary that enables the application running on the specific host - /// to pass and receive vif port information specific to the networking - /// back-end. This field is only meant for machine-machine communication - /// for compute services like Nova, Ironic or Zun to pass information to a - /// Neutron back-end. It should not be used by multiple services - /// concurrently or by cloud end users. The existing counterexamples - /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and - /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. - /// The networking API does not define a specific format of this field. The - /// default is an empty dictionary. If you update it with null then it is - /// treated like {} in the response. Since the port-mac-address-override - /// extension the `device_mac_address` field of the binding:profile can be - /// used to provide the MAC address of the physical device a - /// direct-physical port is being bound to. If provided, then the - /// `mac_address` field of the port resource will be updated to the MAC - /// from the active binding. - #[serde(rename = "binding:profile", skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_binding_profile"))] - pub(crate) binding_profile: Option, Value>>>, - - /// The type of vNIC which this port should be attached to. This is used to - /// determine which mechanism driver(s) to be used to bind the port. The - /// valid values are `normal`, `macvtap`, `direct`, `baremetal`, - /// `direct-physical`, `virtio-forwarder`, `smart-nic` and - /// `remote-managed`. What type of vNIC is actually available depends on - /// deployments. The default is `normal`. - #[serde(rename = "binding:vnic_type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) binding_vnic_type: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The ID of the device that uses this port. For example, a server - /// instance or a logical router. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_id: Option>, - - /// The entity type that uses this port. For example, `compute:nova` - /// (server instance), `network:dhcp` (DHCP agent) or - /// `network:router_interface` (router interface). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_owner: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_profile: Option>>, - - /// A valid DNS domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_domain: Option>, - - /// A valid DNS name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_name: Option>, - - /// A set of zero or more extra DHCP option pairs. An option pair consists - /// of an option value and name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) extra_dhcp_opts: Option, Value>>>, - - /// The IP addresses for the port. If you would like to assign multiple IP - /// addresses for the port, specify multiple entries in this field. Each - /// entry consists of IP address (`ip_address`) and the subnet ID from - /// which the IP address is assigned (`subnet_id`). - /// - /// - If you specify both a subnet ID and an IP address, OpenStack - /// Networking tries to allocate the IP address on that subnet to the - /// port. - /// - If you specify only a subnet ID, OpenStack Networking allocates an - /// available IP from that subnet to the port. - /// - If you specify only an IP address, OpenStack Networking tries to - /// allocate the IP address if the address is a valid IP for any of the - /// subnets on the specified network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ips: Option>>, - - /// Admin-only. A dict, at the top level keyed by mechanism driver aliases - /// (as defined in setup.cfg). To following values can be used to control - /// Open vSwitch’s Userspace Tx packet steering feature: - /// - /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` - /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` - /// - /// If omitted the default is defined by Open vSwitch. The field cannot be - /// longer than 4095 characters. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_hints"))] - pub(crate) hints: Option, Value>>>, - - /// The MAC address of the port. If unspecified, a MAC address is - /// automatically generated. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) mac_address: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the attached network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) network_id: Option>, - - /// The port NUMA affinity policy requested during the virtual machine - /// scheduling. Values: `None`, `required`, `preferred` or `legacy`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) numa_affinity_policy: Option, - - /// The port security status. A valid value is enabled (`true`) or disabled - /// (`false`). If port security is enabled for the port, security group - /// rules and anti-spoofing rules are applied to the traffic on the port. - /// If disabled, no such rules are applied. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_security_enabled: Option, - - /// The uplink status propagation of the port. Valid values are enabled - /// (`true`) and disabled (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) propagate_uplink_status: Option, - - /// QoS policy associated with the port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, - - /// The IDs of security groups applied to the port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_groups: Option>>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tags: Option>>, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -impl<'a> PortBuilder<'a> { - /// A dictionary that enables the application running on the specific host - /// to pass and receive vif port information specific to the networking - /// back-end. This field is only meant for machine-machine communication - /// for compute services like Nova, Ironic or Zun to pass information to a - /// Neutron back-end. It should not be used by multiple services - /// concurrently or by cloud end users. The existing counterexamples - /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and - /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. - /// The networking API does not define a specific format of this field. The - /// default is an empty dictionary. If you update it with null then it is - /// treated like {} in the response. Since the port-mac-address-override - /// extension the `device_mac_address` field of the binding:profile can be - /// used to provide the MAC address of the physical device a - /// direct-physical port is being bound to. If provided, then the - /// `mac_address` field of the port resource will be updated to the MAC - /// from the active binding. - pub fn binding_profile(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.binding_profile - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Admin-only. A dict, at the top level keyed by mechanism driver aliases - /// (as defined in setup.cfg). To following values can be used to control - /// Open vSwitch’s Userspace Tx packet steering feature: - /// - /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` - /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` - /// - /// If omitted the default is defined by Open vSwitch. The field cannot be - /// longer than 4095 characters. - pub fn hints(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.hints - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `port` object. - #[builder(setter(into))] - pub(crate) port: Port<'a>, - - #[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 Port. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "ports".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("port", serde_json::to_value(&self.port)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .port(PortBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .port(PortBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "port" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/ports".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port": {} })); - }); - - let endpoint = Request::builder() - .port(PortBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/ports".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port": {} })); - }); - - let endpoint = Request::builder() - .port(PortBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/delete.rs b/openstack_sdk/src/api/network/v2/port/delete.rs deleted file mode 100644 index a946b7759..000000000 --- a/openstack_sdk/src/api/network/v2/port/delete.rs +++ /dev/null @@ -1,189 +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`. - -//! Deletes a port. -//! -//! Any IP addresses that are associated with the port are returned to the -//! respective subnets allocation pools. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// port_id parameter for /v2.0/ports/{port_id}/add_allowed_address_pairs - /// 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<'a> RequestBuilder<'a> { - /// Add a single header to the Port. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("ports/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/ports/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/ports/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/find.rs b/openstack_sdk/src/api/network/v2/port/find.rs deleted file mode 100644 index 6b78b6e80..000000000 --- a/openstack_sdk/src/api/network/v2/port/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::port::{get as Get, list as List}; - -/// Find for port 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/port/get.rs b/openstack_sdk/src/api/network/v2/port/get.rs deleted file mode 100644 index 5d221444a..000000000 --- a/openstack_sdk/src/api/network/v2/port/get.rs +++ /dev/null @@ -1,192 +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`. - -//! Shows details for a port. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// port_id parameter for /v2.0/ports/{port_id}/add_allowed_address_pairs - /// 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<'a> RequestBuilder<'a> { - /// Add a single header to the Port. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("ports/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "port" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ports/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ports/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/list.rs b/openstack_sdk/src/api/network/v2/port/list.rs deleted file mode 100644 index b81a96517..000000000 --- a/openstack_sdk/src/api/network/v2/port/list.rs +++ /dev/null @@ -1,450 +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`. - -//! Lists ports to which the user has access. -//! -//! Default policy settings return only those ports that are owned by the -//! project of the user who submits the request, unless the request is -//! submitted by a user with administrative rights. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! If the `ip-substring-filtering` extension is enabled, the Neutron API -//! supports IP address substring filtering on the `fixed_ips` attribute. If -//! you specify an IP address substring (`ip_address_substr`) in an entry of -//! the `fixed_ips` attribute, the Neutron API will list all ports that have an -//! IP address matching the substring. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// admin_state_up query parameter for /v2.0/ports API - #[builder(default)] - admin_state_up: Option, - - /// binding:host_id query parameter for /v2.0/ports API - #[builder(default, setter(into))] - binding_host_id: Option>, - - /// description query parameter for /v2.0/ports API - #[builder(default, setter(into))] - description: Option>, - - /// device_id query parameter for /v2.0/ports API - #[builder(default, setter(into))] - device_id: Option>, - - /// device_owner query parameter for /v2.0/ports API - #[builder(default, setter(into))] - device_owner: Option>, - - /// fixed_ips query parameter for /v2.0/ports API - #[builder(default, private, setter(name = "_fixed_ips"))] - fixed_ips: Option>>, - - /// id query parameter for /v2.0/ports API - #[builder(default, setter(into))] - id: Option>, - - /// ip_allocation query parameter for /v2.0/ports API - #[builder(default, setter(into))] - ip_allocation: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// mac_address query parameter for /v2.0/ports API - #[builder(default, setter(into))] - mac_address: Option>, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/ports API - #[builder(default, setter(into))] - name: Option>, - - /// network_id query parameter for /v2.0/ports API - #[builder(default, setter(into))] - network_id: Option>, - - /// not-tags query parameter for /v2.0/ports API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/ports API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// revision_number query parameter for /v2.0/ports API - #[builder(default, setter(into))] - revision_number: Option>, - - /// security_groups query parameter for /v2.0/ports API - #[builder(default, private, setter(name = "_security_groups"))] - security_groups: Option>>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// status query parameter for /v2.0/ports API - #[builder(default, setter(into))] - status: Option>, - - /// tags query parameter for /v2.0/ports API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/ports API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/ports API - #[builder(default, setter(into))] - tenant_id: 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> { - /// fixed_ips query parameter for /v2.0/ports API - pub fn fixed_ips(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.fixed_ips - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags query parameter for /v2.0/ports API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/ports API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// security_groups query parameter for /v2.0/ports API - pub fn security_groups(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.security_groups - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/ports API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/ports API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Port. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "ports".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("binding:host_id", self.binding_host_id.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("device_id", self.device_id.as_ref()); - params.push_opt("device_owner", self.device_owner.as_ref()); - params.push_opt("fixed_ips", self.fixed_ips.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("ip_allocation", self.ip_allocation.as_ref()); - params.push_opt("mac_address", self.mac_address.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("network_id", self.network_id.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - if let Some(val) = &self.security_groups { - params.extend(val.iter().map(|value| ("security_groups", value))); - } - params.push_opt("status", self.status.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ports".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ports" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/ports".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ports": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/ports".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ports": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/set.rs b/openstack_sdk/src/api/network/v2/port/set.rs deleted file mode 100644 index 82cf6a7ac..000000000 --- a/openstack_sdk/src/api/network/v2/port/set.rs +++ /dev/null @@ -1,534 +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`. - -//! Updates a port. -//! -//! You can update information for a port, such as its symbolic name and -//! associated IPs. When you update IPs for a port, any previously associated -//! IPs are removed, returned to the respective subnet allocation pools, and -//! replaced by the IPs in the request body. Therefore, this operation replaces -//! the `fixed_ip` attribute when you specify it in the request body. If the -//! updated IP addresses are not valid or are already in use, the operation -//! fails and the existing IP addresses are not removed from the port. -//! -//! When you update security groups for a port and the operation succeeds, any -//! associated security groups are removed and replaced by the security groups -//! in the request body. Therefore, this operation replaces the -//! `security_groups` attribute when you specify it in the request body. If the -//! security groups are not valid, the operation fails and the existing -//! security groups are not removed from the port. -//! -//! When you update `binding:profile` of a port with null it is treated as {} -//! in the response. -//! -//! The `binding:vnic_type` attribute can be updated on unbound ports only. If -//! the port is already bound, the update operation of the attribute returns -//! the `Conflict (409)` response code. -//! -//! Only admins and users with a specific role can update the data plane status -//! (default role: `data_plane_integrator`). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 409, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllowedAddressPairs<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_address: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum BindingVnicType { - #[serde(rename = "accelerator-direct")] - AcceleratorDirect, - #[serde(rename = "accelerator-direct-physical")] - AcceleratorDirectPhysical, - #[serde(rename = "baremetal")] - Baremetal, - #[serde(rename = "direct")] - Direct, - #[serde(rename = "direct-physical")] - DirectPhysical, - #[serde(rename = "macvtap")] - Macvtap, - #[serde(rename = "normal")] - Normal, - #[serde(rename = "remote-managed")] - RemoteManaged, - #[serde(rename = "smart-nic")] - SmartNic, - #[serde(rename = "vdpa")] - Vdpa, - #[serde(rename = "virtio-forwarder")] - VirtioForwarder, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum DataPlaneStatus { - #[serde(rename = "ACTIVE")] - Active, - #[serde(rename = "DOWN")] - Down, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct FixedIps<'a> { - /// IP Address - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>, - - /// The subnet ID from which the IP address is assigned - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum NumaAffinityPolicy { - #[serde(rename = "legacy")] - Legacy, - #[serde(rename = "preferred")] - Preferred, - #[serde(rename = "required")] - Required, - #[serde(rename = "socket")] - Socket, -} - -/// A `port` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Port<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A set of zero or more allowed address pair objects each where address - /// pair object contains an `ip_address` and `mac_address`. While the - /// `ip_address` is required, the `mac_address` will be taken from the port - /// if not specified. The value of `ip_address` can be an IP Address or a - /// CIDR (if supported by the underlying extension plugin). A server - /// connected to the port can send a packet with source address which - /// matches one of the specified allowed address pairs. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allowed_address_pairs: Option>>, - - /// The ID of the host where the port resides. The default is an empty - /// string. - #[serde(rename = "binding:host_id", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) binding_host_id: Option>, - - /// A dictionary that enables the application running on the specific host - /// to pass and receive vif port information specific to the networking - /// back-end. This field is only meant for machine-machine communication - /// for compute services like Nova, Ironic or Zun to pass information to a - /// Neutron back-end. It should not be used by multiple services - /// concurrently or by cloud end users. The existing counterexamples - /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and - /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. - /// The networking API does not define a specific format of this field. The - /// default is an empty dictionary. If you update it with null then it is - /// treated like {} in the response. Since the port-mac-address-override - /// extension the `device_mac_address` field of the binding:profile can be - /// used to provide the MAC address of the physical device a - /// direct-physical port is being bound to. If provided, then the - /// `mac_address` field of the port resource will be updated to the MAC - /// from the active binding. - #[serde(rename = "binding:profile", skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_binding_profile"))] - pub(crate) binding_profile: Option, Value>>>, - - /// The type of vNIC which this port should be attached to. This is used to - /// determine which mechanism driver(s) to be used to bind the port. The - /// valid values are `normal`, `macvtap`, `direct`, `baremetal`, - /// `direct-physical`, `virtio-forwarder`, `smart-nic` and - /// `remote-managed`. What type of vNIC is actually available depends on - /// deployments. The default is `normal`. - #[serde(rename = "binding:vnic_type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) binding_vnic_type: Option, - - /// Status of the underlying data plane of a port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) data_plane_status: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The ID of the device that uses this port. For example, a server - /// instance or a logical router. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_id: Option>, - - /// The entity type that uses this port. For example, `compute:nova` - /// (server instance), `network:dhcp` (DHCP agent) or - /// `network:router_interface` (router interface). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) device_owner: Option>, - - /// A valid DNS domain. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_domain: Option>, - - /// A valid DNS name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_name: Option>, - - /// A set of zero or more extra DHCP option pairs. An option pair consists - /// of an option value and name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) extra_dhcp_opts: Option, Value>>>, - - /// The IP addresses for the port. If you would like to assign multiple IP - /// addresses for the port, specify multiple entries in this field. Each - /// entry consists of IP address (`ip_address`) and the subnet ID from - /// which the IP address is assigned (`subnet_id`). - /// - /// - If you specify both a subnet ID and an IP address, OpenStack - /// Networking tries to allocate the IP address on that subnet to the - /// port. - /// - If you specify only a subnet ID, OpenStack Networking allocates an - /// available IP from that subnet to the port. - /// - If you specify only an IP address, OpenStack Networking tries to - /// allocate the IP address if the address is a valid IP for any of the - /// subnets on the specified network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) fixed_ips: Option>>, - - /// Admin-only. A dict, at the top level keyed by mechanism driver aliases - /// (as defined in setup.cfg). To following values can be used to control - /// Open vSwitch’s Userspace Tx packet steering feature: - /// - /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` - /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` - /// - /// If omitted the default is defined by Open vSwitch. The field cannot be - /// longer than 4095 characters. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_hints"))] - pub(crate) hints: Option, Value>>>, - - /// The MAC address of the port. By default, only administrative users and - /// users with advsvc role can change this value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) mac_address: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The port NUMA affinity policy requested during the virtual machine - /// scheduling. Values: `None`, `required`, `preferred` or `legacy`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) numa_affinity_policy: Option, - - /// The port security status. A valid value is enabled (`true`) or disabled - /// (`false`). If port security is enabled for the port, security group - /// rules and anti-spoofing rules are applied to the traffic on the port. - /// If disabled, no such rules are applied. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_security_enabled: Option, - - /// QoS policy associated with the port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, - - /// The IDs of security groups applied to the port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_groups: Option>>, -} - -impl<'a> PortBuilder<'a> { - /// A dictionary that enables the application running on the specific host - /// to pass and receive vif port information specific to the networking - /// back-end. This field is only meant for machine-machine communication - /// for compute services like Nova, Ironic or Zun to pass information to a - /// Neutron back-end. It should not be used by multiple services - /// concurrently or by cloud end users. The existing counterexamples - /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and - /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. - /// The networking API does not define a specific format of this field. The - /// default is an empty dictionary. If you update it with null then it is - /// treated like {} in the response. Since the port-mac-address-override - /// extension the `device_mac_address` field of the binding:profile can be - /// used to provide the MAC address of the physical device a - /// direct-physical port is being bound to. If provided, then the - /// `mac_address` field of the port resource will be updated to the MAC - /// from the active binding. - pub fn binding_profile(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.binding_profile - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Admin-only. A dict, at the top level keyed by mechanism driver aliases - /// (as defined in setup.cfg). To following values can be used to control - /// Open vSwitch’s Userspace Tx packet steering feature: - /// - /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` - /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` - /// - /// If omitted the default is defined by Open vSwitch. The field cannot be - /// longer than 4095 characters. - pub fn hints(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.hints - .get_or_insert(None) - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `port` object. - #[builder(setter(into))] - pub(crate) port: Port<'a>, - - /// port_id parameter for /v2.0/ports/{port_id}/add_allowed_address_pairs - /// 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<'a> RequestBuilder<'a> { - /// Add a single header to the Port. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("ports/{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("port", serde_json::to_value(&self.port)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("port".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .port(PortBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .port(PortBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "port" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/ports/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port(PortBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/ports/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "port": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port(PortBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/tag/delete.rs b/openstack_sdk/src/api/network/v2/port/tag/delete.rs deleted file mode 100644 index 14f8c9587..000000000 --- a/openstack_sdk/src/api/network/v2/port/tag/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - port_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "ports/{port_id}/tags/{id}", - id = self.id.as_ref(), - port_id = self.port_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/ports/{port_id}/tags/{id}", - id = "id", - port_id = "port_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/ports/{port_id}/tags/{id}", - id = "id", - port_id = "port_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") - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/port/tag/delete_all.rs deleted file mode 100644 index c46307263..000000000 --- a/openstack_sdk/src/api/network/v2/port/tag/delete_all.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - port_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("ports/{port_id}/tags", port_id = self.port_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/ports/{port_id}/tags", port_id = "port_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().port_id("port_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/ports/{port_id}/tags", port_id = "port_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() - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/tag/get.rs b/openstack_sdk/src/api/network/v2/port/tag/get.rs deleted file mode 100644 index 26beec6df..000000000 --- a/openstack_sdk/src/api/network/v2/port/tag/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - port_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "ports/{port_id}/tags/{id}", - id = self.id.as_ref(), - port_id = self.port_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/ports/{port_id}/tags/{id}", - id = "id", - port_id = "port_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/ports/{port_id}/tags/{id}", - id = "id", - port_id = "port_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") - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/tag/list.rs b/openstack_sdk/src/api/network/v2/port/tag/list.rs deleted file mode 100644 index dbc0de72a..000000000 --- a/openstack_sdk/src/api/network/v2/port/tag/list.rs +++ /dev/null @@ -1,250 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - port_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("ports/{port_id}/tags", port_id = self.port_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ports/{port_id}/tags", port_id = "port_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().port_id("port_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/ports/{port_id}/tags", port_id = "port_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/tag/replace.rs b/openstack_sdk/src/api/network/v2/port/tag/replace.rs deleted file mode 100644 index eac1546a1..000000000 --- a/openstack_sdk/src/api/network/v2/port/tag/replace.rs +++ /dev/null @@ -1,207 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - port_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("ports/{port_id}/tags", port_id = self.port_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/ports/{port_id}/tags", port_id = "port_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .port_id("port_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/ports/{port_id}/tags", port_id = "port_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .port_id("port_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/port/tag/set.rs b/openstack_sdk/src/api/network/v2/port/tag/set.rs deleted file mode 100644 index 6364a6d37..000000000 --- a/openstack_sdk/src/api/network/v2/port/tag/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API - #[builder(default, setter(into))] - port_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "ports/{port_id}/tags/{id}", - id = self.id.as_ref(), - port_id = self.port_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/ports/{port_id}/tags/{id}", - id = "id", - port_id = "port_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .port_id("port_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/ports/{port_id}/tags/{id}", - id = "id", - port_id = "port_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") - .port_id("port_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/create.rs deleted file mode 100644 index 378b100dc..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_alias_bandwidth_limit_rule"))] - pub(crate) alias_bandwidth_limit_rule: BTreeMap, Value>, - - #[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 alias_bandwidth_limit_rule(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.alias_bandwidth_limit_rule - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Alias_Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-bandwidth-limit-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "alias_bandwidth_limit_rule", - serde_json::to_value(&self.alias_bandwidth_limit_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_bandwidth_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_bandwidth_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-bandwidth-limit-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-bandwidth-limit-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/delete.rs deleted file mode 100644 index f0f9acd77..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/delete.rs +++ /dev/null @@ -1,183 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-bandwidth-limit-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/alias-bandwidth-limit-rules/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/alias-bandwidth-limit-rules/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/alias-bandwidth-limit-rules/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/get.rs deleted file mode 100644 index dc8e98303..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/get.rs +++ /dev/null @@ -1,186 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-bandwidth-limit-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/alias-bandwidth-limit-rules/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_bandwidth_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_bandwidth_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rule": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/list.rs deleted file mode 100644 index 1059f47aa..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/list.rs +++ /dev/null @@ -1,266 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// direction query parameter for /v2.0/qos/alias-bandwidth-limit-rules API - #[builder(default, setter(into))] - direction: Option>, - - /// id query parameter for /v2.0/qos/alias-bandwidth-limit-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// max_burst_kbps query parameter for - /// /v2.0/qos/alias-bandwidth-limit-rules API - #[builder(default)] - max_burst_kbps: Option, - - /// max_kbps query parameter for /v2.0/qos/alias-bandwidth-limit-rules API - #[builder(default)] - max_kbps: Option, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Alias_Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-bandwidth-limit-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("max_burst_kbps", self.max_burst_kbps); - params.push_opt("max_kbps", self.max_kbps); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_bandwidth_limit_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_bandwidth_limit_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-bandwidth-limit-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rules": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-bandwidth-limit-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rules": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/set.rs deleted file mode 100644 index cb534d832..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule/set.rs +++ /dev/null @@ -1,244 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AliasBandwidthLimitRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_burst_kbps: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_kbps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) alias_bandwidth_limit_rule: AliasBandwidthLimitRule, - - /// id parameter for /v2.0/qos/alias-bandwidth-limit-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "qos/alias-bandwidth-limit-rules/{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( - "alias_bandwidth_limit_rule", - serde_json::to_value(&self.alias_bandwidth_limit_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_bandwidth_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_bandwidth_limit_rule( - AliasBandwidthLimitRuleBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_bandwidth_limit_rule( - AliasBandwidthLimitRuleBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_bandwidth_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_bandwidth_limit_rule(AliasBandwidthLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_bandwidth_limit_rule(AliasBandwidthLimitRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/create.rs deleted file mode 100644 index a1383a351..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_alias_dscp_marking_rule"))] - pub(crate) alias_dscp_marking_rule: BTreeMap, Value>, - - #[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 alias_dscp_marking_rule(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.alias_dscp_marking_rule - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Alias_Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-dscp-marking-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "alias_dscp_marking_rule", - serde_json::to_value(&self.alias_dscp_marking_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_dscp_marking_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_dscp_marking_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-dscp-marking-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-dscp-marking-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/delete.rs deleted file mode 100644 index e29c0dfdb..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-dscp-marking-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos/alias-dscp-marking-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/alias-dscp-marking-rules/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/alias-dscp-marking-rules/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/get.rs deleted file mode 100644 index 67cbdf755..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-dscp-marking-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos/alias-dscp-marking-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_dscp_marking_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_dscp_marking_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rule": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/list.rs deleted file mode 100644 index 29a69ec2e..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/list.rs +++ /dev/null @@ -1,255 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// dscp_mark query parameter for /v2.0/qos/alias-dscp-marking-rules API - #[builder(default)] - dscp_mark: Option, - - /// id query parameter for /v2.0/qos/alias-dscp-marking-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Alias_Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-dscp-marking-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("dscp_mark", self.dscp_mark); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_dscp_marking_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_dscp_marking_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-dscp-marking-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rules": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-dscp-marking-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rules": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/set.rs deleted file mode 100644 index 4642fad14..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule/set.rs +++ /dev/null @@ -1,220 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AliasDscpMarkingRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dscp_mark: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) alias_dscp_marking_rule: AliasDscpMarkingRule, - - /// id parameter for /v2.0/qos/alias-dscp-marking-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("qos/alias-dscp-marking-rules/{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( - "alias_dscp_marking_rule", - serde_json::to_value(&self.alias_dscp_marking_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_dscp_marking_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_dscp_marking_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/create.rs deleted file mode 100644 index 2fe1b0de9..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_alias_minimum_bandwidth_rule"))] - pub(crate) alias_minimum_bandwidth_rule: BTreeMap, Value>, - - #[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 alias_minimum_bandwidth_rule(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.alias_minimum_bandwidth_rule - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Alias_Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-minimum-bandwidth-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "alias_minimum_bandwidth_rule", - serde_json::to_value(&self.alias_minimum_bandwidth_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_bandwidth_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_minimum_bandwidth_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-minimum-bandwidth-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-minimum-bandwidth-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/delete.rs deleted file mode 100644 index e33e725e3..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/delete.rs +++ /dev/null @@ -1,188 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-minimum-bandwidth-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/alias-minimum-bandwidth-rules/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/qos/alias-minimum-bandwidth-rules/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/qos/alias-minimum-bandwidth-rules/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/get.rs deleted file mode 100644 index 1250b6c31..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/get.rs +++ /dev/null @@ -1,191 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-minimum-bandwidth-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/alias-minimum-bandwidth-rules/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_bandwidth_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_minimum_bandwidth_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/alias-minimum-bandwidth-rules/{id}", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/alias-minimum-bandwidth-rules/{id}", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/list.rs deleted file mode 100644 index 6a218e085..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/list.rs +++ /dev/null @@ -1,262 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// direction query parameter for /v2.0/qos/alias-minimum-bandwidth-rules - /// API - #[builder(default, setter(into))] - direction: Option>, - - /// id query parameter for /v2.0/qos/alias-minimum-bandwidth-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// min_kbps query parameter for /v2.0/qos/alias-minimum-bandwidth-rules - /// API - #[builder(default)] - min_kbps: Option, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Alias_Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-minimum-bandwidth-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("min_kbps", self.min_kbps); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_bandwidth_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_minimum_bandwidth_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-minimum-bandwidth-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rules": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-minimum-bandwidth-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rules": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/set.rs deleted file mode 100644 index 282d40062..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule/set.rs +++ /dev/null @@ -1,249 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AliasMinimumBandwidthRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_kbps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) alias_minimum_bandwidth_rule: AliasMinimumBandwidthRule, - - /// id parameter for /v2.0/qos/alias-minimum-bandwidth-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "qos/alias-minimum-bandwidth-rules/{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( - "alias_minimum_bandwidth_rule", - serde_json::to_value(&self.alias_minimum_bandwidth_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_bandwidth_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_minimum_bandwidth_rule( - AliasMinimumBandwidthRuleBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_minimum_bandwidth_rule( - AliasMinimumBandwidthRuleBuilder::default().build().unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_minimum_bandwidth_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/qos/alias-minimum-bandwidth-rules/{id}", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_minimum_bandwidth_rule( - AliasMinimumBandwidthRuleBuilder::default().build().unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/qos/alias-minimum-bandwidth-rules/{id}", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_minimum_bandwidth_rule( - AliasMinimumBandwidthRuleBuilder::default().build().unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/create.rs deleted file mode 100644 index 6df87f20d..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_alias_minimum_packet_rate_rule"))] - pub(crate) alias_minimum_packet_rate_rule: BTreeMap, Value>, - - #[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 alias_minimum_packet_rate_rule(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.alias_minimum_packet_rate_rule - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-minimum-packet-rate-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "alias_minimum_packet_rate_rule", - serde_json::to_value(&self.alias_minimum_packet_rate_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_packet_rate_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_minimum_packet_rate_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-minimum-packet-rate-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/alias-minimum-packet-rate-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/delete.rs deleted file mode 100644 index 2ad7c4d67..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/delete.rs +++ /dev/null @@ -1,188 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-minimum-packet-rate-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/alias-minimum-packet-rate-rules/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/qos/alias-minimum-packet-rate-rules/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/qos/alias-minimum-packet-rate-rules/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/get.rs deleted file mode 100644 index e2250ef21..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/get.rs +++ /dev/null @@ -1,191 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/alias-minimum-packet-rate-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/alias-minimum-packet-rate-rules/{id}", - id = self.id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_packet_rate_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_minimum_packet_rate_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/alias-minimum-packet-rate-rules/{id}", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/alias-minimum-packet-rate-rules/{id}", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/list.rs deleted file mode 100644 index c10d6b4ff..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/list.rs +++ /dev/null @@ -1,262 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// direction query parameter for /v2.0/qos/alias-minimum-packet-rate-rules - /// API - #[builder(default, setter(into))] - direction: Option>, - - /// id query parameter for /v2.0/qos/alias-minimum-packet-rate-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// min_kpps query parameter for /v2.0/qos/alias-minimum-packet-rate-rules - /// API - #[builder(default)] - min_kpps: Option, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/alias-minimum-packet-rate-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("min_kpps", self.min_kpps); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_packet_rate_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "alias_minimum_packet_rate_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-minimum-packet-rate-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rules": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/alias-minimum-packet-rate-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rules": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/set.rs deleted file mode 100644 index 70b1c6884..000000000 --- a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule/set.rs +++ /dev/null @@ -1,259 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "any")] - Any, - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AliasMinimumPacketRateRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_kpps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) alias_minimum_packet_rate_rule: AliasMinimumPacketRateRule, - - /// id parameter for /v2.0/qos/alias-minimum-packet-rate-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "qos/alias-minimum-packet-rate-rules/{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( - "alias_minimum_packet_rate_rule", - serde_json::to_value(&self.alias_minimum_packet_rate_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("alias_minimum_packet_rate_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .alias_minimum_packet_rate_rule( - AliasMinimumPacketRateRuleBuilder::default() - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .alias_minimum_packet_rate_rule( - AliasMinimumPacketRateRuleBuilder::default() - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "alias_minimum_packet_rate_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/qos/alias-minimum-packet-rate-rules/{id}", - id = "id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_minimum_packet_rate_rule( - AliasMinimumPacketRateRuleBuilder::default() - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/qos/alias-minimum-packet-rate-rules/{id}", - id = "id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .alias_minimum_packet_rate_rule( - AliasMinimumPacketRateRuleBuilder::default() - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/create.rs deleted file mode 100644 index ca3bea13e..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/create.rs +++ /dev/null @@ -1,260 +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`. - -//! Creates a bandwidth limit rule for a QoS policy. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -/// A `bandwidth_limit_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct BandwidthLimitRule { - /// The direction of the traffic to which the QoS rule is applied, as seen - /// from the point of view of the `port`. Valid values are `egress` and - /// `ingress`. Default value is `egress`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - /// The maximum burst size (in kilobits). Default is `0`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_burst_kbps: Option, - - /// The maximum KBPS (kilobits per second) value. If you specify this - /// value, must be greater than 0 otherwise max_kbps will have no value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_kbps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `bandwidth_limit_rule` object. - #[builder(setter(into))] - pub(crate) bandwidth_limit_rule: BandwidthLimitRule, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "qos/policies/{policy_id}/bandwidth_limit_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "bandwidth_limit_rule", - serde_json::to_value(&self.bandwidth_limit_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("bandwidth_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "bandwidth_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/delete.rs deleted file mode 100644 index e8434c76b..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/delete.rs +++ /dev/null @@ -1,208 +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`. - -//! Deletes a bandwidth limit rule for a QoS policy. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/get.rs deleted file mode 100644 index ee24be459..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/get.rs +++ /dev/null @@ -1,211 +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`. - -//! Shows details for a bandwidth limit rule for a QoS policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("bandwidth_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "bandwidth_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/list.rs deleted file mode 100644 index 1dae621b7..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/list.rs +++ /dev/null @@ -1,299 +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`. - -//! Lists all bandwidth limit rules for a QoS policy. -//! -//! The list might be empty. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id query parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// max_burst_kbps query parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules API - #[builder(default)] - max_burst_kbps: Option, - - /// max_kbps query parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules API - #[builder(default)] - max_kbps: Option, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/bandwidth_limit_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("id", self.id.as_ref()); - params.push_opt("max_burst_kbps", self.max_burst_kbps); - params.push_opt("max_kbps", self.max_kbps); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("bandwidth_limit_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "bandwidth_limit_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rules": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rules": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/set.rs deleted file mode 100644 index b6f37f924..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule/set.rs +++ /dev/null @@ -1,270 +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`. - -//! Updates a bandwidth limit rule for a QoS policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -/// A `bandwidth_limit_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct BandwidthLimitRule { - /// The direction of the traffic to which the QoS rule is applied, as seen - /// from the point of view of the `port`. Valid values are `egress` and - /// `ingress`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - /// The maximum burst size (in kilobits). Default is `0`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_burst_kbps: Option, - - /// The maximum KBPS (kilobits per second) value. If you specify this - /// value, must be greater than 0 otherwise max_kbps will have no value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_kbps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `bandwidth_limit_rule` object. - #[builder(setter(into))] - pub(crate) bandwidth_limit_rule: BandwidthLimitRule, - - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API - #[builder(default, setter(into))] - policy_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 Bandwidth_Limit_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "bandwidth_limit_rule", - serde_json::to_value(&self.bandwidth_limit_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("bandwidth_limit_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "bandwidth_limit_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "bandwidth_limit_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/create.rs b/openstack_sdk/src/api/network/v2/qos/policy/create.rs deleted file mode 100644 index c748fea0a..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/create.rs +++ /dev/null @@ -1,254 +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`. - -//! Creates a QoS policy. -//! -//! Creates a QoS policy by using the configuration that you define in the -//! request object. A response object is returned. The object contains a unique -//! ID. -//! -//! By the default policy configuration, if the caller is not an administrative -//! user, this call returns the HTTP `Forbidden (403)` response code. -//! -//! Users with an administrative role can create policies on behalf of other -//! projects by specifying a project ID that is different than their own. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A QoS `policy` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Policy<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// If `true`, the QoS `policy` is the default policy. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_default: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Set to `true` to share this policy with other projects. Default is - /// `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A QoS `policy` object. - #[builder(setter(into))] - pub(crate) policy: Policy<'a>, - - #[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 Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("policy", serde_json::to_value(&self.policy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .policy(PolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .policy(PolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/policies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policy": {} })); - }); - - let endpoint = Request::builder() - .policy(PolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/policies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policy": {} })); - }); - - let endpoint = Request::builder() - .policy(PolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/delete.rs b/openstack_sdk/src/api/network/v2/qos/policy/delete.rs deleted file mode 100644 index 7f78fa78d..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a QoS policy. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/policies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos/policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/policies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/policies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/create.rs deleted file mode 100644 index e0113e3eb..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/create.rs +++ /dev/null @@ -1,239 +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`. - -//! Creates a DSCP marking rule for a QoS policy. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `dscp_marking_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct DscpMarkingRule { - /// The DSCP mark value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dscp_mark: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `dscp_marking_rule` object. - #[builder(setter(into))] - pub(crate) dscp_marking_rule: DscpMarkingRule, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API - #[builder(default, setter(into))] - policy_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 Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "qos/policies/{policy_id}/dscp_marking_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "dscp_marking_rule", - serde_json::to_value(&self.dscp_marking_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("dscp_marking_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "dscp_marking_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/delete.rs deleted file mode 100644 index 9fd71f0f6..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/delete.rs +++ /dev/null @@ -1,208 +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`. - -//! Deletes a DSCP marking rule for a QoS policy. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API - #[builder(default, setter(into))] - policy_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 Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/get.rs deleted file mode 100644 index d55d4b0b3..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/get.rs +++ /dev/null @@ -1,211 +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`. - -//! Shows details for a DSCP marking rule for a QoS policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API - #[builder(default, setter(into))] - policy_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 Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("dscp_marking_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "dscp_marking_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/list.rs deleted file mode 100644 index c77dbaf3c..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/list.rs +++ /dev/null @@ -1,293 +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`. - -//! Lists all DSCP marking rules for a QoS policy. -//! -//! The list may be empty. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// dscp_mark query parameter for - /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules API - #[builder(default)] - dscp_mark: Option, - - /// id query parameter for - /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/dscp_marking_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("dscp_mark", self.dscp_mark); - params.push_opt("id", self.id.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("dscp_marking_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "dscp_marking_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rules": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rules": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/set.rs deleted file mode 100644 index a30ceacbe..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule/set.rs +++ /dev/null @@ -1,249 +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`. - -//! Updates a DSCP marking rule for a QoS policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `dscp_marking_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct DscpMarkingRule { - /// The DSCP mark value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dscp_mark: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `dscp_marking_rule` object. - #[builder(setter(into))] - pub(crate) dscp_marking_rule: DscpMarkingRule, - - /// id parameter for /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API - #[builder(default, setter(into))] - policy_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 Dscp_Marking_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "dscp_marking_rule", - serde_json::to_value(&self.dscp_marking_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("dscp_marking_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "dscp_marking_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/qos/policies/{policy_id}/dscp_marking_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dscp_marking_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/find.rs b/openstack_sdk/src/api/network/v2/qos/policy/find.rs deleted file mode 100644 index 28e601ac6..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::qos::policy::{get as Get, list as List}; - -/// Find for qos/policy 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/get.rs b/openstack_sdk/src/api/network/v2/qos/policy/get.rs deleted file mode 100644 index 1bee3c423..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/get.rs +++ /dev/null @@ -1,189 +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`. - -//! Shows details for a QoS policy. One policy can contain more than one rule -//! type. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/policies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos/policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/policies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policy": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/policies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/list.rs b/openstack_sdk/src/api/network/v2/qos/policy/list.rs deleted file mode 100644 index d2a0eb87e..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/list.rs +++ /dev/null @@ -1,375 +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`. - -//! Lists all QoS policies associated with your project. One policy can contain -//! more than one rule type. -//! -//! The list might be empty. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/qos/policies API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/qos/policies API - #[builder(default, setter(into))] - id: Option>, - - /// is_default query parameter for /v2.0/qos/policies API - #[builder(default)] - is_default: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/qos/policies API - #[builder(default, setter(into))] - name: Option>, - - /// not-tags query parameter for /v2.0/qos/policies API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/qos/policies API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// revision_number query parameter for /v2.0/qos/policies API - #[builder(default, setter(into))] - revision_number: Option>, - - /// shared query parameter for /v2.0/qos/policies API - #[builder(default)] - shared: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tags query parameter for /v2.0/qos/policies API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/qos/policies API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/qos/policies API - #[builder(default, setter(into))] - tenant_id: 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> { - /// not-tags query parameter for /v2.0/qos/policies API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/qos/policies API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/qos/policies API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/qos/policies API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("is_default", self.is_default); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("shared", self.shared); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("policies".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "policies" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/policies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policies": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/policies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policies": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/create.rs deleted file mode 100644 index 3aaf967c7..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/create.rs +++ /dev/null @@ -1,255 +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`. - -//! Creates a minimum bandwidth rule for a QoS policy. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -/// A `minimum_bandwidth_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct MinimumBandwidthRule { - /// The direction of the traffic to which the QoS rule is applied, as seen - /// from the point of view of the `port`. Valid values are `egress` and - /// `ingress`. Default value is `egress`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - /// The minimum KBPS (kilobits per second) value which should be available - /// for port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_kbps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `minimum_bandwidth_rule` object. - #[builder(setter(into))] - pub(crate) minimum_bandwidth_rule: MinimumBandwidthRule, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "qos/policies/{policy_id}/minimum_bandwidth_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "minimum_bandwidth_rule", - serde_json::to_value(&self.minimum_bandwidth_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_bandwidth_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "minimum_bandwidth_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/delete.rs deleted file mode 100644 index 49fa98d3e..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/delete.rs +++ /dev/null @@ -1,208 +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`. - -//! Deletes a minimum bandwidth rule for a QoS policy. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/get.rs deleted file mode 100644 index 3d240459d..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/get.rs +++ /dev/null @@ -1,211 +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`. - -//! Shows details for a minimum bandwidth rule for a QoS policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_bandwidth_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "minimum_bandwidth_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/list.rs deleted file mode 100644 index c8b9a472c..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/list.rs +++ /dev/null @@ -1,299 +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`. - -//! Lists all minimum bandwidth rules for a QoS policy. -//! -//! The list might be empty. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// direction query parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules API - #[builder(default, setter(into))] - direction: Option>, - - /// id query parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// min_kbps query parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules API - #[builder(default)] - min_kbps: Option, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/minimum_bandwidth_rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("min_kbps", self.min_kbps); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_bandwidth_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "minimum_bandwidth_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rules": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rules": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/set.rs deleted file mode 100644 index 166ad28b2..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule/set.rs +++ /dev/null @@ -1,269 +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`. - -//! Updates a minimum bandwidth rule for a QoS policy. -//! -//! Note that the rule cannot be updated, and the update is rejected with error -//! code 501, if there is any bound port referring to the rule via the qos -//! policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404, 501 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -/// A `minimum_bandwidth_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct MinimumBandwidthRule { - /// The direction of the traffic to which the QoS rule is applied, as seen - /// from the point of view of the `port`. Valid values are `egress` and - /// `ingress`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - /// The minimum KBPS (kilobits per second) value which should be available - /// for port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_kbps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `minimum_bandwidth_rule` object. - #[builder(setter(into))] - pub(crate) minimum_bandwidth_rule: MinimumBandwidthRule, - - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Bandwidth_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "minimum_bandwidth_rule", - serde_json::to_value(&self.minimum_bandwidth_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_bandwidth_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "minimum_bandwidth_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_bandwidth_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/create.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/create.rs deleted file mode 100644 index 9318514f7..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/create.rs +++ /dev/null @@ -1,244 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "any")] - Any, - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct MinimumPacketRateRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_kpps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) minimum_packet_rate_rule: MinimumPacketRateRule, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "qos/policies/{policy_id}/minimum-packet-rate-rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "minimum_packet_rate_rule", - serde_json::to_value(&self.minimum_packet_rate_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_packet_rate_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "minimum_packet_rate_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/delete.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/delete.rs deleted file mode 100644 index 817d64812..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/delete.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = "id", - policy_id = "policy_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") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/get.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/get.rs deleted file mode 100644 index fb3ae720b..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/get.rs +++ /dev/null @@ -1,205 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_packet_rate_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "minimum_packet_rate_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/list.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/list.rs deleted file mode 100644 index 04e8d5647..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/list.rs +++ /dev/null @@ -1,278 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// direction query parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules API - #[builder(default, setter(into))] - direction: Option>, - - /// id query parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// min_kpps query parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules API - #[builder(default)] - min_kpps: Option, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - policy_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "qos/policies/{policy_id}/minimum-packet-rate-rules", - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("min_kpps", self.min_kpps); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_packet_rate_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "minimum_packet_rate_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rules": {} })); - }); - - let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rules": {} })); - }); - - let endpoint = Request::builder() - .policy_id("policy_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/set.rs b/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/set.rs deleted file mode 100644 index 0422a5fd0..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule/set.rs +++ /dev/null @@ -1,254 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "any")] - Any, - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct MinimumPacketRateRule { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_kpps: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) minimum_packet_rate_rule: MinimumPacketRateRule, - - /// id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// policy_id parameter for - /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API - #[builder(default, setter(into))] - policy_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 Minimum_Packet_Rate_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = self.id.as_ref(), - policy_id = self.policy_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "minimum_packet_rate_rule", - serde_json::to_value(&self.minimum_packet_rate_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("minimum_packet_rate_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "minimum_packet_rate_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = "id", - policy_id = "policy_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", - id = "id", - policy_id = "policy_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "minimum_packet_rate_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy_id("policy_id") - .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/set.rs b/openstack_sdk/src/api/network/v2/qos/policy/set.rs deleted file mode 100644 index 3e8b17e69..000000000 --- a/openstack_sdk/src/api/network/v2/qos/policy/set.rs +++ /dev/null @@ -1,243 +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`. - -//! Updates a QoS policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A QoS `policy` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Policy<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// If `true`, the QoS `policy` is the default policy. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_default: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Set to `true` to share this policy with other projects. Default is - /// `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A QoS `policy` object. - #[builder(setter(into))] - pub(crate) policy: Policy<'a>, - - /// id parameter for /v2.0/qos/policies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("qos/policies/{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("policy", serde_json::to_value(&self.policy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .policy(PolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .policy(PolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/policies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy(PolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/policies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .policy(PolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/rule_type/create.rs b/openstack_sdk/src/api/network/v2/qos/rule_type/create.rs deleted file mode 100644 index 24a45a9cb..000000000 --- a/openstack_sdk/src/api/network/v2/qos/rule_type/create.rs +++ /dev/null @@ -1,214 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RuleType { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all_rules: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all_supported: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request { - #[builder(setter(into))] - pub(crate) rule_type: RuleType, - - #[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 Rule_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/rule-types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("rule_type", serde_json::to_value(&self.rule_type)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rule_type".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "rule_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/rule-types".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_type": {} })); - }); - - let endpoint = Request::builder() - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/qos/rule-types".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_type": {} })); - }); - - let endpoint = Request::builder() - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/rule_type/delete.rs b/openstack_sdk/src/api/network/v2/qos/rule_type/delete.rs deleted file mode 100644 index 8cbcbda39..000000000 --- a/openstack_sdk/src/api/network/v2/qos/rule_type/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/rule-types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Rule_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos/rule-types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/rule-types/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/qos/rule-types/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/rule_type/get.rs b/openstack_sdk/src/api/network/v2/qos/rule_type/get.rs deleted file mode 100644 index 6d9f96895..000000000 --- a/openstack_sdk/src/api/network/v2/qos/rule_type/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for an available QoS rule type. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/qos/rule-types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Rule_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("qos/rule-types/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rule_type".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "rule_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/rule-types/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_type": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/qos/rule-types/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/rule_type/list.rs b/openstack_sdk/src/api/network/v2/qos/rule_type/list.rs deleted file mode 100644 index b28a4707f..000000000 --- a/openstack_sdk/src/api/network/v2/qos/rule_type/list.rs +++ /dev/null @@ -1,274 +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`. - -//! Lists available qos rule types. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// all_rules query parameter for /v2.0/qos/rule-types API - #[builder(default)] - all_rules: Option, - - /// all_supported query parameter for /v2.0/qos/rule-types API - #[builder(default)] - all_supported: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Rule_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "qos/rule-types".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("all_rules", self.all_rules); - params.push_opt("all_supported", self.all_supported); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rule_types".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "rule_types" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/rule-types".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_types": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/qos/rule-types".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_types": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/qos/rule_type/set.rs b/openstack_sdk/src/api/network/v2/qos/rule_type/set.rs deleted file mode 100644 index 8a4eb004d..000000000 --- a/openstack_sdk/src/api/network/v2/qos/rule_type/set.rs +++ /dev/null @@ -1,221 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RuleType { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all_rules: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all_supported: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) rule_type: RuleType, - - /// id parameter for /v2.0/qos/rule-types/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Rule_Type. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("qos/rule-types/{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("rule_type", serde_json::to_value(&self.rule_type)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rule_type".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "rule_type" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/rule-types/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/qos/rule-types/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rule_type": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .rule_type(RuleTypeBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/quota/defaults.rs b/openstack_sdk/src/api/network/v2/quota/defaults.rs deleted file mode 100644 index 500850738..000000000 --- a/openstack_sdk/src/api/network/v2/quota/defaults.rs +++ /dev/null @@ -1,201 +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`. - -//! Lists default quotas for a project. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/quotas/{id}/default 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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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}/default", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("quota".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/quotas/{id}/default", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/quotas/{id}/default", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/quota/delete.rs b/openstack_sdk/src/api/network/v2/quota/delete.rs deleted file mode 100644 index bba8ea7b7..000000000 --- a/openstack_sdk/src/api/network/v2/quota/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Resets quotas to default values for a project. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/quotas/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/quota/details.rs b/openstack_sdk/src/api/network/v2/quota/details.rs deleted file mode 100644 index f33fc7d35..000000000 --- a/openstack_sdk/src/api/network/v2/quota/details.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/quotas/{id}/details 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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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}/details", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("quota".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/quotas/{id}/details", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/quotas/{id}/details", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/quota/get.rs b/openstack_sdk/src/api/network/v2/quota/get.rs deleted file mode 100644 index aa08d52a4..000000000 --- a/openstack_sdk/src/api/network/v2/quota/get.rs +++ /dev/null @@ -1,201 +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`. - -//! Lists quotas for a project. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/quotas/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::Network - } - - fn response_key(&self) -> Option> { - Some("quota".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quota" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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!({ "quota": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/quota/list.rs b/openstack_sdk/src/api/network/v2/quota/list.rs deleted file mode 100644 index 0b5852808..000000000 --- a/openstack_sdk/src/api/network/v2/quota/list.rs +++ /dev/null @@ -1,264 +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`. - -//! Lists quotas for projects with non-default quota values. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "quotas" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/quota/set.rs b/openstack_sdk/src/api/network/v2/quota/set.rs deleted file mode 100644 index 4a922110d..000000000 --- a/openstack_sdk/src/api/network/v2/quota/set.rs +++ /dev/null @@ -1,280 +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`. - -//! Updates quotas for a project. Use when non-default quotas are desired. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `quota` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Quota<'a> { - /// The number of floating IP addresses allowed for each project. A value - /// of `-1` means no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) floatingip: Option, - - /// The number of networks allowed for each project. A value of `-1` means - /// no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) network: Option, - - /// The number of ports allowed for each project. A value of `-1` means no - /// limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port: Option, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The number of role-based access control (RBAC) policies for each - /// project. A value of `-1` means no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) rbac_policy: Option, - - /// The number of routers allowed for each project. A value of `-1` means - /// no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) router: Option, - - /// The number of security groups allowed for each project. A value of `-1` - /// means no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_group: Option, - - /// The number of security group rules allowed for each project. A value of - /// `-1` means no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_group_rule: Option, - - /// The number of subnets allowed for each project. A value of `-1` means - /// no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet: Option, - - /// The number of subnet pools allowed for each project. A value of `-1` - /// means no limit. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnetpool: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `quota` object. - #[builder(setter(into))] - pub(crate) quota: Quota<'a>, - - /// id parameter for /v2.0/quotas/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Quota. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("quotas/{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("quota", serde_json::to_value(&self.quota)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("quota".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .quota(QuotaBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .quota(QuotaBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "quota" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/quotas/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota(QuotaBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .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!({ "quota": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .quota(QuotaBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/rbac_policy/create.rs b/openstack_sdk/src/api/network/v2/rbac_policy/create.rs deleted file mode 100644 index 398f084df..000000000 --- a/openstack_sdk/src/api/network/v2/rbac_policy/create.rs +++ /dev/null @@ -1,250 +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`. - -//! Create RBAC policy for given tenant. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RbacPolicy<'a> { - /// Action for the RBAC policy which is `access_as_external` or - /// `access_as_shared`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) action: Option>, - - /// The ID of the `object_type` resource. An `object_type` of `network` - /// returns a network ID, an `object_type` of `qos-policy` returns a QoS - /// policy ID, an `object_type` of `security-group` returns a security - /// group ID, an `object_type` of `address-scope` returns a address scope - /// ID, an `object_type` of `subnetpool` returns a subnetpool ID and an - /// `object_type` of `address-group` returns an address group ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) object_id: Option>, - - /// The type of the object that the RBAC policy affects. Types include - /// `qos-policy`, `network`, `security-group`, `address-scope`, - /// `subnetpool` or `address-group`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) object_type: Option>, - - /// The ID of the tenant to which the RBAC policy will be enforced. Please - /// note that Neutron does not perform any type of validation that the - /// value provided is actually the ID of the existing project. If, for - /// example, the name of the project is provided here, it will be accepted - /// by the Neutron API, but the RBAC rule created will not work as - /// expected. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) target_tenant: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) rbac_policy: RbacPolicy<'a>, - - #[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 Rbac_Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "rbac-policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("rbac_policy", serde_json::to_value(&self.rbac_policy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rbac_policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "rbac_policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/rbac-policies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policy": {} })); - }); - - let endpoint = Request::builder() - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/rbac-policies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policy": {} })); - }); - - let endpoint = Request::builder() - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/rbac_policy/delete.rs b/openstack_sdk/src/api/network/v2/rbac_policy/delete.rs deleted file mode 100644 index bbeebca58..000000000 --- a/openstack_sdk/src/api/network/v2/rbac_policy/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Delete an RBAC policy. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/rbac-policies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Rbac_Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("rbac-policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/rbac-policies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/rbac-policies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/rbac_policy/get.rs b/openstack_sdk/src/api/network/v2/rbac_policy/get.rs deleted file mode 100644 index d515671e1..000000000 --- a/openstack_sdk/src/api/network/v2/rbac_policy/get.rs +++ /dev/null @@ -1,191 +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 details for a given RBAC policy. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/rbac-policies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Rbac_Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("rbac-policies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rbac_policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "rbac_policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/rbac-policies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policy": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/rbac-policies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/rbac_policy/list.rs b/openstack_sdk/src/api/network/v2/rbac_policy/list.rs deleted file mode 100644 index 602b4faaf..000000000 --- a/openstack_sdk/src/api/network/v2/rbac_policy/list.rs +++ /dev/null @@ -1,294 +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`. - -//! List RBAC policies that belong to a given tenant. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// action query parameter for /v2.0/rbac-policies API - #[builder(default, setter(into))] - action: Option>, - - /// id query parameter for /v2.0/rbac-policies API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// object_id query parameter for /v2.0/rbac-policies API - #[builder(default, setter(into))] - object_id: Option>, - - /// object_type query parameter for /v2.0/rbac-policies API - #[builder(default, setter(into))] - object_type: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// target_tenant query parameter for /v2.0/rbac-policies API - #[builder(default, setter(into))] - target_tenant: Option>, - - /// tenant_id query parameter for /v2.0/rbac-policies API - #[builder(default, setter(into))] - tenant_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Rbac_Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "rbac-policies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("action", self.action.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("object_id", self.object_id.as_ref()); - params.push_opt("object_type", self.object_type.as_ref()); - params.push_opt("target_tenant", self.target_tenant.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rbac_policies".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "rbac_policies" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/rbac-policies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policies": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/rbac-policies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policies": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/rbac_policy/set.rs b/openstack_sdk/src/api/network/v2/rbac_policy/set.rs deleted file mode 100644 index 4242a8fc5..000000000 --- a/openstack_sdk/src/api/network/v2/rbac_policy/set.rs +++ /dev/null @@ -1,229 +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`. - -//! Update RBAC policy for given tenant. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct RbacPolicy<'a> { - /// The ID of the tenant to which the RBAC policy will be enforced. Please - /// note that Neutron does not perform any type of validation that the - /// value provided is actually the ID of the existing project. If, for - /// example, the name of the project is provided here, it will be accepted - /// by the Neutron API, but the RBAC rule created will not work as - /// expected. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) target_tenant: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) rbac_policy: RbacPolicy<'a>, - - /// id parameter for /v2.0/rbac-policies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Rbac_Policy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("rbac-policies/{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("rbac_policy", serde_json::to_value(&self.rbac_policy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("rbac_policy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "rbac_policy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/rbac-policies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/rbac-policies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "rbac_policy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/conntrack_helper/create.rs b/openstack_sdk/src/api/network/v2/router/conntrack_helper/create.rs deleted file mode 100644 index 75229afe8..000000000 --- a/openstack_sdk/src/api/network/v2/router/conntrack_helper/create.rs +++ /dev/null @@ -1,269 +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`. - -//! Creates a router conntrack helper. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Protocol { - #[serde(rename = "dccp")] - Dccp, - #[serde(rename = "icmp")] - Icmp, - #[serde(rename = "ipv6-icmp")] - Ipv6Icmp, - #[serde(rename = "sctp")] - Sctp, - #[serde(rename = "tcp")] - Tcp, - #[serde(rename = "udp")] - Udp, -} - -/// A router `conntrack helper` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ConntrackHelper<'a> { - /// The netfilter conntrack helper module. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) helper: Option>, - - /// The network port for the netfilter conntrack target rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project_id: Option>, - - /// The network protocol for the netfilter conntrack target rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A router `conntrack helper` object. - #[builder(setter(into))] - pub(crate) conntrack_helper: ConntrackHelper<'a>, - - /// router_id parameter for - /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - router_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 Conntrack_Helper. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "routers/{router_id}/conntrack_helpers", - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "conntrack_helper", - serde_json::to_value(&self.conntrack_helper)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("conntrack_helper".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "conntrack_helper" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/routers/{router_id}/conntrack_helpers", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helper": {} })); - }); - - let endpoint = Request::builder() - .router_id("router_id") - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/routers/{router_id}/conntrack_helpers", - router_id = "router_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helper": {} })); - }); - - let endpoint = Request::builder() - .router_id("router_id") - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/conntrack_helper/delete.rs b/openstack_sdk/src/api/network/v2/router/conntrack_helper/delete.rs deleted file mode 100644 index ad19de3bc..000000000 --- a/openstack_sdk/src/api/network/v2/router/conntrack_helper/delete.rs +++ /dev/null @@ -1,207 +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`. - -//! Deletes a router conntrack helper. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for - /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - router_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 Conntrack_Helper. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/conntrack_helpers/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/routers/{router_id}/conntrack_helpers/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/routers/{router_id}/conntrack_helpers/{id}", - id = "id", - router_id = "router_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") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/conntrack_helper/find.rs b/openstack_sdk/src/api/network/v2/router/conntrack_helper/find.rs deleted file mode 100644 index 62cc868b3..000000000 --- a/openstack_sdk/src/api/network/v2/router/conntrack_helper/find.rs +++ /dev/null @@ -1,118 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use tracing::trace; - -use crate::api::find::Findable; -use crate::api::rest_endpoint_prelude::*; - -use crate::api::{ApiError, RestClient}; - -use crate::api::network::v2::router::conntrack_helper::{get as Get, list as List}; - -/// Find for router/conntrack_helper by nameOrId. -#[derive(Debug, Builder, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into), default)] - id: Cow<'a, str>, - #[builder(default, setter(into))] - router_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 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<'a>; - fn get_ep(&self) -> Get::Request<'a> { - let mut ep = Get::Request::builder(); - ep.id(self.id.clone()); - ep.router_id(self.router_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<'a> { - let mut ep = List::Request::builder(); - ep.router_id(self.router_id.clone()); - if let Some(headers) = &self._headers { - ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); - } - ep.build().unwrap() - } - /// Locate router/conntrack_helper in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // router/conntrack_helper 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/network/v2/router/conntrack_helper/get.rs b/openstack_sdk/src/api/network/v2/router/conntrack_helper/get.rs deleted file mode 100644 index 67c08ccad..000000000 --- a/openstack_sdk/src/api/network/v2/router/conntrack_helper/get.rs +++ /dev/null @@ -1,213 +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`. - -//! Shows information for a router conntrack helper. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for - /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - router_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 Conntrack_Helper. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/conntrack_helpers/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("conntrack_helper".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "conntrack_helper" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/routers/{router_id}/conntrack_helpers/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helper": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/routers/{router_id}/conntrack_helpers/{id}", - id = "id", - router_id = "router_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helper": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/conntrack_helper/list.rs b/openstack_sdk/src/api/network/v2/router/conntrack_helper/list.rs deleted file mode 100644 index c17ac965a..000000000 --- a/openstack_sdk/src/api/network/v2/router/conntrack_helper/list.rs +++ /dev/null @@ -1,302 +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`. - -//! Lists router conntrack helpers associated with a router. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// helper query parameter for /v2.0/routers/{router_id}/conntrack_helpers - /// API - #[builder(default, setter(into))] - helper: Option>, - - /// id query parameter for /v2.0/routers/{router_id}/conntrack_helpers API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// port query parameter for /v2.0/routers/{router_id}/conntrack_helpers - /// API - #[builder(default)] - port: Option, - - /// protocol query parameter for - /// /v2.0/routers/{router_id}/conntrack_helpers API - #[builder(default, setter(into))] - protocol: Option>, - - /// router_id parameter for - /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - router_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Conntrack_Helper. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/conntrack_helpers", - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("helper", self.helper.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("port", self.port); - params.push_opt("protocol", self.protocol.as_ref()); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("conntrack_helpers".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "conntrack_helpers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/routers/{router_id}/conntrack_helpers", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helpers": {} })); - }); - - let endpoint = Request::builder().router_id("router_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/routers/{router_id}/conntrack_helpers", - router_id = "router_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helpers": {} })); - }); - - let endpoint = Request::builder() - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/conntrack_helper/set.rs b/openstack_sdk/src/api/network/v2/router/conntrack_helper/set.rs deleted file mode 100644 index 7a87abfcf..000000000 --- a/openstack_sdk/src/api/network/v2/router/conntrack_helper/set.rs +++ /dev/null @@ -1,272 +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`. - -//! Updates a router conntrack helper. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Protocol { - #[serde(rename = "dccp")] - Dccp, - #[serde(rename = "icmp")] - Icmp, - #[serde(rename = "ipv6-icmp")] - Ipv6Icmp, - #[serde(rename = "sctp")] - Sctp, - #[serde(rename = "tcp")] - Tcp, - #[serde(rename = "udp")] - Udp, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ConntrackHelper<'a> { - /// The netfilter conntrack helper module. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) helper: Option>, - - /// The network port for the netfilter conntrack target rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port: Option, - - /// The network protocol for the netfilter conntrack target rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) protocol: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) conntrack_helper: ConntrackHelper<'a>, - - /// id parameter for /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for - /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API - #[builder(default, setter(into))] - router_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 Conntrack_Helper. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "routers/{router_id}/conntrack_helpers/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "conntrack_helper", - serde_json::to_value(&self.conntrack_helper)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("conntrack_helper".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "conntrack_helper" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/routers/{router_id}/conntrack_helpers/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helper": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/routers/{router_id}/conntrack_helpers/{id}", - id = "id", - router_id = "router_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "conntrack_helper": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/create.rs b/openstack_sdk/src/api/network/v2/router/create.rs deleted file mode 100644 index 78074609c..000000000 --- a/openstack_sdk/src/api/network/v2/router/create.rs +++ /dev/null @@ -1,324 +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`. - -//! Creates a logical router. -//! -//! This operation creates a logical router. The logical router does not have -//! any internal interface and it is not associated with any subnet. You can -//! optionally specify an external gateway for a router at create time. The -//! external gateway for the router must be plugged into an external network. -//! An external network has its `router:external` extended field set to `true`. -//! To specify an external gateway, the ID of the external network must be -//! passed in the `network_id` parameter of the `external_gateway_info` -//! attribute in the request body. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ExternalFixedIps<'a> { - /// IP Address - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>, - - /// The subnet ID from which the IP address is assigned - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, -} - -/// The external gateway information of the router. If the router has an -/// external gateway, this would be a dict with `network_id`, `enable_snat`, -/// `external_fixed_ips` and `qos_policy_id`. Otherwise, this would be `null`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ExternalGatewayInfo<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enable_snat: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_fixed_ips: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) network_id: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, -} - -/// A `router` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Router<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). Default is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// The availability zone candidates for the router. It is available when - /// `router_availability_zone` extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) availability_zone_hints: Option>>, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// `true` indicates a distributed router. It is available when `dvr` - /// extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) distributed: Option>, - - /// Enable NDP proxy attribute. Default is `false`, To persist this - /// attribute value, set the `enable_ndp_proxy_by_default` option in the - /// `neutron.conf` file. It is available when `router-extend-ndp-proxy` - /// extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enable_ndp_proxy: Option>, - - /// The external gateway information of the router. If the router has an - /// external gateway, this would be a dict with `network_id`, - /// `enable_snat`, `external_fixed_ips` and `qos_policy_id`. Otherwise, - /// this would be `null`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_gateway_info: Option>>, - - /// The ID of the flavor associated with the router. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) flavor_id: Option>, - - /// `true` indicates a highly-available router. It is available when - /// `l3-ha` extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ha: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `router` object. - #[builder(setter(into))] - pub(crate) router: Router<'a>, - - #[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 Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "routers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("router", serde_json::to_value(&self.router)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("router".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .router(RouterBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .router(RouterBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "router" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/routers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "router": {} })); - }); - - let endpoint = Request::builder() - .router(RouterBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/routers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "router": {} })); - }); - - let endpoint = Request::builder() - .router(RouterBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/delete.rs b/openstack_sdk/src/api/network/v2/router/delete.rs deleted file mode 100644 index 96aab26d4..000000000 --- a/openstack_sdk/src/api/network/v2/router/delete.rs +++ /dev/null @@ -1,189 +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`. - -//! Deletes a logical router and, if present, its external gateway interface. -//! -//! This operation fails if the router has attached interfaces. Use the remove -//! router interface operation to remove all router interfaces before you -//! delete the router. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("routers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/routers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/routers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/find.rs b/openstack_sdk/src/api/network/v2/router/find.rs deleted file mode 100644 index d848bc655..000000000 --- a/openstack_sdk/src/api/network/v2/router/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::router::{get as Get, list as List}; - -/// Find for router 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/router/get.rs b/openstack_sdk/src/api/network/v2/router/get.rs deleted file mode 100644 index ed8d71a80..000000000 --- a/openstack_sdk/src/api/network/v2/router/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for a router. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("routers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("router".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "router" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/routers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "router": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/routers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "router": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/l3_agent/create.rs b/openstack_sdk/src/api/network/v2/router/l3_agent/create.rs deleted file mode 100644 index ba4eef26b..000000000 --- a/openstack_sdk/src/api/network/v2/router/l3_agent/create.rs +++ /dev/null @@ -1,215 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - router_id: Cow<'a, str>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Value>, -} -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 L3_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "routers/{router_id}/l3-agents", - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), val.clone()); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/routers/{router_id}/l3-agents", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().router_id("router_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/routers/{router_id}/l3-agents", - router_id = "router_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() - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/l3_agent/delete.rs b/openstack_sdk/src/api/network/v2/router/l3_agent/delete.rs deleted file mode 100644 index 9967054f0..000000000 --- a/openstack_sdk/src/api/network/v2/router/l3_agent/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - router_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 L3_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/l3-agents/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/routers/{router_id}/l3-agents/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/routers/{router_id}/l3-agents/{id}", - id = "id", - router_id = "router_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") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/l3_agent/get.rs b/openstack_sdk/src/api/network/v2/router/l3_agent/get.rs deleted file mode 100644 index 96adf40d4..000000000 --- a/openstack_sdk/src/api/network/v2/router/l3_agent/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - router_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 L3_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/l3-agents/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/routers/{router_id}/l3-agents/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/routers/{router_id}/l3-agents/{id}", - id = "id", - router_id = "router_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") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/l3_agent/list.rs b/openstack_sdk/src/api/network/v2/router/l3_agent/list.rs deleted file mode 100644 index f1a9feeda..000000000 --- a/openstack_sdk/src/api/network/v2/router/l3_agent/list.rs +++ /dev/null @@ -1,275 +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`. - -//! Lists l3 agents hosting a specific router. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - router_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the L3_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/l3-agents", - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/routers/{router_id}/l3-agents", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().router_id("router_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/routers/{router_id}/l3-agents", - router_id = "router_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() - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/l3_agent/set.rs b/openstack_sdk/src/api/network/v2/router/l3_agent/set.rs deleted file mode 100644 index 1a6e49bcc..000000000 --- a/openstack_sdk/src/api/network/v2/router/l3_agent/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API - #[builder(default, setter(into))] - router_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 L3_Agent. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "routers/{router_id}/l3-agents/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/routers/{router_id}/l3-agents/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/routers/{router_id}/l3-agents/{id}", - id = "id", - router_id = "router_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") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/list.rs b/openstack_sdk/src/api/network/v2/router/list.rs deleted file mode 100644 index 85278039a..000000000 --- a/openstack_sdk/src/api/network/v2/router/list.rs +++ /dev/null @@ -1,376 +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`. - -//! Lists logical routers that the project who submits the request can access. -//! -//! Default policy settings return only those routers that the project who -//! submits the request owns, unless an administrative user submits the -//! request. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// admin_state_up query parameter for /v2.0/routers API - #[builder(default)] - admin_state_up: Option, - - /// description query parameter for /v2.0/routers API - #[builder(default, setter(into))] - description: Option>, - - /// enable_ndp_proxy query parameter for /v2.0/routers API - #[builder(default)] - enable_ndp_proxy: Option, - - /// id query parameter for /v2.0/routers API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/routers API - #[builder(default, setter(into))] - name: Option>, - - /// not-tags query parameter for /v2.0/routers API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/routers API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// revision_number query parameter for /v2.0/routers API - #[builder(default, setter(into))] - revision_number: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tags query parameter for /v2.0/routers API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/routers API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/routers API - #[builder(default, setter(into))] - tenant_id: 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> { - /// not-tags query parameter for /v2.0/routers API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/routers API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/routers API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/routers API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "routers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("admin_state_up", self.admin_state_up); - params.push_opt("description", self.description.as_ref()); - params.push_opt("enable_ndp_proxy", self.enable_ndp_proxy); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("routers".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "routers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/routers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "routers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/routers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "routers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/set.rs b/openstack_sdk/src/api/network/v2/router/set.rs deleted file mode 100644 index a19c08630..000000000 --- a/openstack_sdk/src/api/network/v2/router/set.rs +++ /dev/null @@ -1,326 +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`. - -//! Updates a logical router. -//! -//! This operation does not enable the update of router interfaces. To update a -//! router interface, use the add router interface and remove router interface -//! operations. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ExternalFixedIps<'a> { - /// IP Address - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ip_address: Option>, - - /// The subnet ID from which the IP address is assigned - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>, -} - -/// The external gateway information of the router. If the router has an -/// external gateway, this would be a dict with `network_id`, `enable_snat`, -/// `external_fixed_ips` and `qos_policy_id`. Otherwise, this would be `null`. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ExternalGatewayInfo<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enable_snat: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_fixed_ips: Option>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) network_id: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) qos_policy_id: Option>>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Routes<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) destination: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) nexthop: Option>, -} - -/// A `router` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Router<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// `true` indicates a distributed router. It is available when `dvr` - /// extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) distributed: Option>, - - /// Enable NDP proxy attribute. Default is `false`, To persist this - /// attribute value, set the `enable_ndp_proxy_by_default` option in the - /// `neutron.conf` file. It is available when `router-extend-ndp-proxy` - /// extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enable_ndp_proxy: Option>, - - /// The external gateway information of the router. If the router has an - /// external gateway, this would be a dict with `network_id`, - /// `enable_snat`, `external_fixed_ips` and `qos_policy_id`. Otherwise, - /// this would be `null`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) external_gateway_info: Option>>, - - /// `true` indicates a highly-available router. It is available when - /// `l3-ha` extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ha: Option>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The extra routes configuration for L3 router. A list of dictionaries - /// with `destination` and `nexthop` parameters. It is available when - /// `extraroute` extension is enabled. Default is an empty list (`[]`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) routes: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `router` object. - #[builder(setter(into))] - pub(crate) router: Router<'a>, - - /// id parameter for /v2.0/routers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Router. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("routers/{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("router", serde_json::to_value(&self.router)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("router".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .router(RouterBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .router(RouterBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "router" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/routers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "router": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router(RouterBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/routers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "router": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router(RouterBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/tag/delete.rs b/openstack_sdk/src/api/network/v2/router/tag/delete.rs deleted file mode 100644 index 020b2d524..000000000 --- a/openstack_sdk/src/api/network/v2/router/tag/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - router_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/tags/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/routers/{router_id}/tags/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/routers/{router_id}/tags/{id}", - id = "id", - router_id = "router_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") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/router/tag/delete_all.rs deleted file mode 100644 index a8514fbf6..000000000 --- a/openstack_sdk/src/api/network/v2/router/tag/delete_all.rs +++ /dev/null @@ -1,188 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - router_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/tags", - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/routers/{router_id}/tags", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().router_id("router_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/routers/{router_id}/tags", - router_id = "router_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() - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/tag/get.rs b/openstack_sdk/src/api/network/v2/router/tag/get.rs deleted file mode 100644 index d7ef4e11b..000000000 --- a/openstack_sdk/src/api/network/v2/router/tag/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - router_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/tags/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/routers/{router_id}/tags/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/routers/{router_id}/tags/{id}", - id = "id", - router_id = "router_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") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/tag/list.rs b/openstack_sdk/src/api/network/v2/router/tag/list.rs deleted file mode 100644 index e664ae93e..000000000 --- a/openstack_sdk/src/api/network/v2/router/tag/list.rs +++ /dev/null @@ -1,259 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - router_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "routers/{router_id}/tags", - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/routers/{router_id}/tags", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().router_id("router_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/routers/{router_id}/tags", - router_id = "router_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/tag/replace.rs b/openstack_sdk/src/api/network/v2/router/tag/replace.rs deleted file mode 100644 index fcf7a807c..000000000 --- a/openstack_sdk/src/api/network/v2/router/tag/replace.rs +++ /dev/null @@ -1,216 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - router_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "routers/{router_id}/tags", - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/routers/{router_id}/tags", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .router_id("router_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/routers/{router_id}/tags", - router_id = "router_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .router_id("router_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/router/tag/set.rs b/openstack_sdk/src/api/network/v2/router/tag/set.rs deleted file mode 100644 index cf87606ac..000000000 --- a/openstack_sdk/src/api/network/v2/router/tag/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API - #[builder(default, setter(into))] - router_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "routers/{router_id}/tags/{id}", - id = self.id.as_ref(), - router_id = self.router_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/routers/{router_id}/tags/{id}", - id = "id", - router_id = "router_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .router_id("router_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/routers/{router_id}/tags/{id}", - id = "id", - router_id = "router_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") - .router_id("router_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/create.rs b/openstack_sdk/src/api/network/v2/security_group/create.rs deleted file mode 100644 index 844640ce7..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/create.rs +++ /dev/null @@ -1,242 +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`. - -//! Creates an OpenStack Networking security group. -//! -//! This operation creates a security group with default security group rules -//! for the IPv4 and IPv6 ether types. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `security_group` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SecurityGroup<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Indicates if the security group is stateful or stateless. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) stateful: Option, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `security_group` object. - #[builder(setter(into))] - pub(crate) security_group: SecurityGroup<'a>, - - #[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 Security_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "security-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "security_group", - serde_json::to_value(&self.security_group)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "security_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/security-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group": {} })); - }); - - let endpoint = Request::builder() - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/security-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group": {} })); - }); - - let endpoint = Request::builder() - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/delete.rs b/openstack_sdk/src/api/network/v2/security_group/delete.rs deleted file mode 100644 index 5e10a2a13..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/delete.rs +++ /dev/null @@ -1,193 +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`. - -//! Deletes an OpenStack Networking security group. -//! -//! This operation deletes an OpenStack Networking security group and its -//! associated security group rules, provided that a port is not associated -//! with the security group. If a port is associated with the security group -//! 409 (Conflict) is returned. -//! -//! This operation does not require a request body. This operation does not -//! return a response body. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/security-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Security_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("security-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/security-groups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/security-groups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/find.rs b/openstack_sdk/src/api/network/v2/security_group/find.rs deleted file mode 100644 index cfca88b82..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::security_group::{get as Get, list as List}; - -/// Find for security_group 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/get.rs b/openstack_sdk/src/api/network/v2/security_group/get.rs deleted file mode 100644 index a5c6a87eb..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/get.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows details for a security group. -//! -//! The associated security group rules are contained in the response. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/security-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Security_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("security-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "security_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/security-groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/security-groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/list.rs b/openstack_sdk/src/api/network/v2/security_group/list.rs deleted file mode 100644 index e90a81058..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/list.rs +++ /dev/null @@ -1,370 +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`. - -//! Lists OpenStack Networking security groups to which the project has access. -//! -//! The response is an array of `security_group` objects which contains a list -//! of `security_group_rules` objects. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/security-groups API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/security-groups API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/security-groups API - #[builder(default, setter(into))] - name: Option>, - - /// not-tags query parameter for /v2.0/security-groups API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/security-groups API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// revision_number query parameter for /v2.0/security-groups API - #[builder(default, setter(into))] - revision_number: Option>, - - /// shared query parameter for /v2.0/security-groups API - #[builder(default)] - shared: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tags query parameter for /v2.0/security-groups API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/security-groups API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/security-groups API - #[builder(default, setter(into))] - tenant_id: 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> { - /// not-tags query parameter for /v2.0/security-groups API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/security-groups API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/security-groups API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/security-groups API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Security_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "security-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("shared", self.shared); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_groups".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "security_groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/security-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/security-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/set.rs b/openstack_sdk/src/api/network/v2/security_group/set.rs deleted file mode 100644 index e34e11efe..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/set.rs +++ /dev/null @@ -1,239 +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`. - -//! Updates a security group. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `security_group` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SecurityGroup<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) stateful: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `security_group` object. - #[builder(setter(into))] - pub(crate) security_group: SecurityGroup<'a>, - - /// id parameter for /v2.0/security-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Security_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("security-groups/{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( - "security_group", - serde_json::to_value(&self.security_group)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "security_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/security-groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/security-groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .security_group(SecurityGroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/tag/delete.rs b/openstack_sdk/src/api/network/v2/security_group/tag/delete.rs deleted file mode 100644 index badc4b397..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/tag/delete.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/security-groups/{security_group_id}/tags/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// security_group_id parameter for - /// /v2.0/security-groups/{security_group_id}/tags/{id} API - #[builder(default, setter(into))] - security_group_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "security-groups/{security_group_id}/tags/{id}", - id = self.id.as_ref(), - security_group_id = self.security_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/security-groups/{security_group_id}/tags/{id}", - id = "id", - security_group_id = "security_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .security_group_id("security_group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/security-groups/{security_group_id}/tags/{id}", - id = "id", - security_group_id = "security_group_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") - .security_group_id("security_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/security_group/tag/delete_all.rs deleted file mode 100644 index 9a5b453bc..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/tag/delete_all.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// security_group_id parameter for - /// /v2.0/security-groups/{security_group_id}/tags/{id} API - #[builder(default, setter(into))] - security_group_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "security-groups/{security_group_id}/tags", - security_group_id = self.security_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/security-groups/{security_group_id}/tags", - security_group_id = "security_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .security_group_id("security_group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/security-groups/{security_group_id}/tags", - security_group_id = "security_group_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() - .security_group_id("security_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/tag/get.rs b/openstack_sdk/src/api/network/v2/security_group/tag/get.rs deleted file mode 100644 index 2b595d484..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/tag/get.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/security-groups/{security_group_id}/tags/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// security_group_id parameter for - /// /v2.0/security-groups/{security_group_id}/tags/{id} API - #[builder(default, setter(into))] - security_group_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "security-groups/{security_group_id}/tags/{id}", - id = self.id.as_ref(), - security_group_id = self.security_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/security-groups/{security_group_id}/tags/{id}", - id = "id", - security_group_id = "security_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .security_group_id("security_group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/security-groups/{security_group_id}/tags/{id}", - id = "id", - security_group_id = "security_group_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") - .security_group_id("security_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/tag/list.rs b/openstack_sdk/src/api/network/v2/security_group/tag/list.rs deleted file mode 100644 index 5d100f3e7..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/tag/list.rs +++ /dev/null @@ -1,263 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// security_group_id parameter for - /// /v2.0/security-groups/{security_group_id}/tags/{id} API - #[builder(default, setter(into))] - security_group_id: Cow<'a, str>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "security-groups/{security_group_id}/tags", - security_group_id = self.security_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/security-groups/{security_group_id}/tags", - security_group_id = "security_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .security_group_id("security_group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/security-groups/{security_group_id}/tags", - security_group_id = "security_group_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .security_group_id("security_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/tag/replace.rs b/openstack_sdk/src/api/network/v2/security_group/tag/replace.rs deleted file mode 100644 index f4a9d0597..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/tag/replace.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// security_group_id parameter for - /// /v2.0/security-groups/{security_group_id}/tags/{id} API - #[builder(default, setter(into))] - security_group_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "security-groups/{security_group_id}/tags", - security_group_id = self.security_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/security-groups/{security_group_id}/tags", - security_group_id = "security_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .security_group_id("security_group_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/security-groups/{security_group_id}/tags", - security_group_id = "security_group_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .security_group_id("security_group_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group/tag/set.rs b/openstack_sdk/src/api/network/v2/security_group/tag/set.rs deleted file mode 100644 index af3498ebd..000000000 --- a/openstack_sdk/src/api/network/v2/security_group/tag/set.rs +++ /dev/null @@ -1,202 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/security-groups/{security_group_id}/tags/{id} - /// API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// security_group_id parameter for - /// /v2.0/security-groups/{security_group_id}/tags/{id} API - #[builder(default, setter(into))] - security_group_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "security-groups/{security_group_id}/tags/{id}", - id = self.id.as_ref(), - security_group_id = self.security_group_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/security-groups/{security_group_id}/tags/{id}", - id = "id", - security_group_id = "security_group_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .security_group_id("security_group_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/security-groups/{security_group_id}/tags/{id}", - id = "id", - security_group_id = "security_group_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") - .security_group_id("security_group_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group_rule/create.rs b/openstack_sdk/src/api/network/v2/security_group_rule/create.rs deleted file mode 100644 index 54986fe2d..000000000 --- a/openstack_sdk/src/api/network/v2/security_group_rule/create.rs +++ /dev/null @@ -1,308 +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`. - -//! Creates an OpenStack Networking security group rule. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Direction { - #[serde(rename = "egress")] - Egress, - #[serde(rename = "ingress")] - Ingress, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Ethertype { - #[serde(rename = "IPv4")] - Ipv4, - #[serde(rename = "IPv6")] - Ipv6, -} - -/// A `security_group_rule` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SecurityGroupRule<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Ingress or egress, which is the direction in which the security group - /// rule is applied. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) direction: Option, - - /// Must be IPv4 or IPv6, and addresses represented in CIDR must match the - /// ingress or egress rules. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) ethertype: Option, - - /// The maximum port number in the range that is matched by the security - /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this - /// value must be greater than or equal to the `port_range_min` attribute - /// value. If the protocol is ICMP, this value must be an ICMP code. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_range_max: Option>, - - /// The minimum port number in the range that is matched by the security - /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this - /// value must be less than or equal to the `port_range_max` attribute - /// value. If the protocol is ICMP, this value must be an ICMP type. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) port_range_min: Option>, - - /// The IP protocol can be represented by a string, an integer, or `null`. - /// Valid string or integer values are `any` or `0`, `ah` or `51`, `dccp` - /// or `33`, `egp` or `8`, `esp` or `50`, `gre` or `47`, `icmp` or `1`, - /// `icmpv6` or `58`, `igmp` or `2`, `ipip` or `4`, `ipv6-encap` or `41`, - /// `ipv6-frag` or `44`, `ipv6-icmp` or `58`, `ipv6-nonxt` or `59`, - /// `ipv6-opts` or `60`, `ipv6-route` or `43`, `ospf` or `89`, `pgm` or - /// `113`, `rsvp` or `46`, `sctp` or `132`, `tcp` or `6`, `udp` or `17`, - /// `udplite` or `136`, `vrrp` or `112`. Additionally, any integer value - /// between [0-255] is also valid. The string `any` (or integer `0`) means - /// `all` IP protocols. See the constants in `neutron_lib.constants` for - /// the most up-to-date list of supported strings. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) protocol: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_address_group_id: Option>, - - /// The remote group UUID to associate with this security group rule. You - /// can specify either the `remote_group_id` or `remote_ip_prefix` - /// attribute in the request body. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_group_id: Option>, - - /// The remote IP prefix that is matched by this security group rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) remote_ip_prefix: Option>, - - /// The security group ID to associate with this security group rule. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) security_group_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `security_group_rule` object. - #[builder(setter(into))] - pub(crate) security_group_rule: SecurityGroupRule<'a>, - - #[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 Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "security-group-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "security_group_rule", - serde_json::to_value(&self.security_group_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_group_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "security_group_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/security-group-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/security-group-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group_rule/delete.rs b/openstack_sdk/src/api/network/v2/security_group_rule/delete.rs deleted file mode 100644 index 73372f468..000000000 --- a/openstack_sdk/src/api/network/v2/security_group_rule/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a rule from an OpenStack Networking security group. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/security-group-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("security-group-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/security-group-rules/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/security-group-rules/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group_rule/get.rs b/openstack_sdk/src/api/network/v2/security_group_rule/get.rs deleted file mode 100644 index 0c9f71b51..000000000 --- a/openstack_sdk/src/api/network/v2/security_group_rule/get.rs +++ /dev/null @@ -1,194 +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`. - -//! Shows detailed information for a security group rule. -//! -//! The response body contains the following information about the security -//! group rule: -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/security-group-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("security-group-rules/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_group_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "security_group_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/security-group-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rule": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/security-group-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group_rule/list.rs b/openstack_sdk/src/api/network/v2/security_group_rule/list.rs deleted file mode 100644 index 2ba884f4b..000000000 --- a/openstack_sdk/src/api/network/v2/security_group_rule/list.rs +++ /dev/null @@ -1,347 +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`. - -//! Lists a summary of all OpenStack Networking security group rules that the -//! project can access. -//! -//! The list provides the ID for each security group rule. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// belongs_to_default_sg query parameter for /v2.0/security-group-rules - /// API - #[builder(default)] - belongs_to_default_sg: Option, - - /// description query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - description: Option>, - - /// direction query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - direction: Option>, - - /// ethertype query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - ethertype: Option>, - - /// id query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// normalized_cidr query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - normalized_cidr: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// port_range_max query parameter for /v2.0/security-group-rules API - #[builder(default)] - port_range_max: Option, - - /// port_range_min query parameter for /v2.0/security-group-rules API - #[builder(default)] - port_range_min: Option, - - /// protocol query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - protocol: Option>, - - /// remote_address_group_id query parameter for /v2.0/security-group-rules - /// API - #[builder(default, setter(into))] - remote_address_group_id: Option>, - - /// remote_group_id query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - remote_group_id: Option>, - - /// remote_ip_prefix query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - remote_ip_prefix: Option>, - - /// revision_number query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - revision_number: Option>, - - /// security_group_id query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - security_group_id: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tenant_id query parameter for /v2.0/security-group-rules API - #[builder(default, setter(into))] - tenant_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "security-group-rules".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("belongs_to_default_sg", self.belongs_to_default_sg); - params.push_opt("description", self.description.as_ref()); - params.push_opt("direction", self.direction.as_ref()); - params.push_opt("ethertype", self.ethertype.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("normalized_cidr", self.normalized_cidr.as_ref()); - params.push_opt("port_range_max", self.port_range_max); - params.push_opt("port_range_min", self.port_range_min); - params.push_opt("protocol", self.protocol.as_ref()); - params.push_opt( - "remote_address_group_id", - self.remote_address_group_id.as_ref(), - ); - params.push_opt("remote_group_id", self.remote_group_id.as_ref()); - params.push_opt("remote_ip_prefix", self.remote_ip_prefix.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("security_group_id", self.security_group_id.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_group_rules".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "security_group_rules" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/security-group-rules".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rules": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/security-group-rules".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rules": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/security_group_rule/set.rs b/openstack_sdk/src/api/network/v2/security_group_rule/set.rs deleted file mode 100644 index 162ff3b56..000000000 --- a/openstack_sdk/src/api/network/v2/security_group_rule/set.rs +++ /dev/null @@ -1,220 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct SecurityGroupRule<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) security_group_rule: SecurityGroupRule<'a>, - - /// id parameter for /v2.0/security-group-rules/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Security_Group_Rule. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("security-group-rules/{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( - "security_group_rule", - serde_json::to_value(&self.security_group_rule)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("security_group_rule".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "security_group_rule" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/security-group-rules/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/security-group-rules/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "security_group_rule": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/segment/create.rs b/openstack_sdk/src/api/network/v2/segment/create.rs deleted file mode 100644 index 555a04845..000000000 --- a/openstack_sdk/src/api/network/v2/segment/create.rs +++ /dev/null @@ -1,253 +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`. - -//! Creates a segment. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Segment<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the segment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, - - /// The ID of the attached network. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) network_id: Option>, - - /// The type of physical network that maps to this network resource. For - /// example, `flat`, `vlan`, `vxlan`, or `gre`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) network_type: Option>, - - /// The physical network where this network/segment is implemented. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) physical_network: Option>, - - /// The ID of the isolated segment on the physical network. The - /// `network_type` attribute defines the segmentation model. For example, - /// if the `network_type` value is vlan, this ID is a vlan identifier. If - /// the `network_type` value is gre, this ID is a gre key. `Note` that only - /// the segmentation-id of VLAN type networks can be changed! - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) segmentation_id: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) segment: Segment<'a>, - - #[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 Segment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "segments".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("segment", serde_json::to_value(&self.segment)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("segment".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .segment(SegmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .segment(SegmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "segment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/segments".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segment": {} })); - }); - - let endpoint = Request::builder() - .segment(SegmentBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/segments".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segment": {} })); - }); - - let endpoint = Request::builder() - .segment(SegmentBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/segment/delete.rs b/openstack_sdk/src/api/network/v2/segment/delete.rs deleted file mode 100644 index 2fdff9cf7..000000000 --- a/openstack_sdk/src/api/network/v2/segment/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Deletes a segment and its associated resources. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/segments/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Segment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("segments/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/segments/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/segments/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/segment/find.rs b/openstack_sdk/src/api/network/v2/segment/find.rs deleted file mode 100644 index a9e1f898e..000000000 --- a/openstack_sdk/src/api/network/v2/segment/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::segment::{get as Get, list as List}; - -/// Find for segment 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/segment/get.rs b/openstack_sdk/src/api/network/v2/segment/get.rs deleted file mode 100644 index 90ae2a8a6..000000000 --- a/openstack_sdk/src/api/network/v2/segment/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for a segment. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/segments/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Segment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("segments/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("segment".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "segment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/segments/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segment": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/segments/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/segment/list.rs b/openstack_sdk/src/api/network/v2/segment/list.rs deleted file mode 100644 index ddbe723ca..000000000 --- a/openstack_sdk/src/api/network/v2/segment/list.rs +++ /dev/null @@ -1,299 +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`. - -//! Lists segments to which the project has access. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/segments API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/segments API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/segments API - #[builder(default, setter(into))] - name: Option>, - - /// network_id query parameter for /v2.0/segments API - #[builder(default, setter(into))] - network_id: Option>, - - /// network_type query parameter for /v2.0/segments API - #[builder(default, setter(into))] - network_type: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// physical_network query parameter for /v2.0/segments API - #[builder(default, setter(into))] - physical_network: Option>, - - /// revision_number query parameter for /v2.0/segments API - #[builder(default, setter(into))] - revision_number: Option>, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Segment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "segments".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("network_id", self.network_id.as_ref()); - params.push_opt("network_type", self.network_type.as_ref()); - params.push_opt("physical_network", self.physical_network.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("segments".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "segments" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/segments".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segments": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/segments".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segments": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/segment/set.rs b/openstack_sdk/src/api/network/v2/segment/set.rs deleted file mode 100644 index 5d1ce2c34..000000000 --- a/openstack_sdk/src/api/network/v2/segment/set.rs +++ /dev/null @@ -1,230 +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`. - -//! Updates a segment. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Segment<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the segment. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) segment: Segment<'a>, - - /// id parameter for /v2.0/segments/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Segment. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("segments/{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("segment", serde_json::to_value(&self.segment)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("segment".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .segment(SegmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .segment(SegmentBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "segment" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/segments/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .segment(SegmentBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/segments/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "segment": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .segment(SegmentBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_profile/create.rs b/openstack_sdk/src/api/network/v2/service_profile/create.rs deleted file mode 100644 index 5d6cd9967..000000000 --- a/openstack_sdk/src/api/network/v2/service_profile/create.rs +++ /dev/null @@ -1,257 +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`. - -//! Creates a service profile. -//! -//! This operation establishes a new service profile that can be associated -//! with one or more flavors. -//! -//! Either metadata or a driver is required. -//! -//! If a driver is specified but does not exist, call will return a -//! `Not found 404` error with the response body explaining that the driver -//! could not be found. -//! -//! Creation currently limited to administrators. Other users will receive a -//! `Forbidden 403` response code with a response body NeutronError message -//! expressing that creation is disallowed by policy. -//! -//! If the API cannot fulfill the request due to insufficient data or data that -//! is not valid, the service returns the HTTP `Bad Request (400)` response -//! code with information about the failure in the response body. Validation -//! errors require that you correct the error and submit the request again. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `service_profile` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ServiceProfile<'a> { - /// The human-readable description for the service profile. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Provider driver to use for this profile. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) driver: Option>, - - /// Indicates whether this service profile is enabled or not. Default is - /// `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option>, - - /// JSON-formatted meta information of the service profile. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) metainfo: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `service_profile` object. - #[builder(setter(into))] - pub(crate) service_profile: ServiceProfile<'a>, - - #[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 Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "service_profiles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "service_profile", - serde_json::to_value(&self.service_profile)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/service_profiles".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/service_profiles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_profile/delete.rs b/openstack_sdk/src/api/network/v2/service_profile/delete.rs deleted file mode 100644 index f5d08a0aa..000000000 --- a/openstack_sdk/src/api/network/v2/service_profile/delete.rs +++ /dev/null @@ -1,191 +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`. - -//! Deletes a service profile. -//! -//! Attempting to delete a service profile that is currently associated with a -//! flavor will return a `Conflict 409` with a response body containing an in -//! use message. -//! -//! Either metadata or a driver is required. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("service_profiles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/service_profiles/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/service_profiles/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_profile/get.rs b/openstack_sdk/src/api/network/v2/service_profile/get.rs deleted file mode 100644 index 4364bfc48..000000000 --- a/openstack_sdk/src/api/network/v2/service_profile/get.rs +++ /dev/null @@ -1,195 +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`. - -//! Shows details for a service profile. -//! -//! This operation returns a service profile object by ID. If you are not an -//! administrative user and the object is not visible to your tenant account, -//! the service returns the HTTP `Forbidden (403)` response code. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("service_profiles/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/service_profiles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/service_profiles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_profile/list.rs b/openstack_sdk/src/api/network/v2/service_profile/list.rs deleted file mode 100644 index 4e26bc134..000000000 --- a/openstack_sdk/src/api/network/v2/service_profile/list.rs +++ /dev/null @@ -1,286 +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`. - -//! Lists all service profiles visible for the tenant account. -//! -//! The list can be empty. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// description query parameter for /v2.0/service_profiles API - #[builder(default, setter(into))] - description: Option>, - - /// driver query parameter for /v2.0/service_profiles API - #[builder(default, setter(into))] - driver: Option>, - - /// enabled query parameter for /v2.0/service_profiles API - #[builder(default)] - enabled: Option, - - /// id query parameter for /v2.0/service_profiles API - #[builder(default, setter(into))] - id: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "service_profiles".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - params.push_opt("description", self.description.as_ref()); - params.push_opt("driver", self.driver.as_ref()); - params.push_opt("enabled", self.enabled); - params.push_opt("id", self.id.as_ref()); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profiles".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_profiles" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/service_profiles".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profiles": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/service_profiles".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profiles": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_profile/set.rs b/openstack_sdk/src/api/network/v2/service_profile/set.rs deleted file mode 100644 index 43bf5dee4..000000000 --- a/openstack_sdk/src/api/network/v2/service_profile/set.rs +++ /dev/null @@ -1,245 +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`. - -//! Updates a service profile. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `service_profile` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ServiceProfile<'a> { - /// The human-readable description for the service profile. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>>, - - /// Provider driver to use for this profile. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) driver: Option>, - - /// Indicates whether this service profile is enabled or not. Default is - /// `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enabled: Option>, - - /// JSON-formatted meta information of the service profile. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) metainfo: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `service_profile` object. - #[builder(setter(into))] - pub(crate) service_profile: ServiceProfile<'a>, - - /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Profile. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("service_profiles/{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( - "service_profile", - serde_json::to_value(&self.service_profile)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_profile".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_profile" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/service_profiles/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/service_profiles/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_profile": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_profile(ServiceProfileBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_provider/create.rs b/openstack_sdk/src/api/network/v2/service_provider/create.rs deleted file mode 100644 index 6ca56764a..000000000 --- a/openstack_sdk/src/api/network/v2/service_provider/create.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_service_provider"))] - pub(crate) service_provider: BTreeMap, Value>, - - #[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 service_provider(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.service_provider - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "service-providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "service_provider", - serde_json::to_value(&self.service_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_provider".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/service-providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .service_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/service-providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .service_provider(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_provider/delete.rs b/openstack_sdk/src/api/network/v2/service_provider/delete.rs deleted file mode 100644 index 4dffbc8f2..000000000 --- a/openstack_sdk/src/api/network/v2/service_provider/delete.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/service-providers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("service-providers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/service-providers/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/service-providers/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_provider/get.rs b/openstack_sdk/src/api/network/v2/service_provider/get.rs deleted file mode 100644 index d674ec09f..000000000 --- a/openstack_sdk/src/api/network/v2/service_provider/get.rs +++ /dev/null @@ -1,182 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/service-providers/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("service-providers/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_provider".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/service-providers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/service-providers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_provider/list.rs b/openstack_sdk/src/api/network/v2/service_provider/list.rs deleted file mode 100644 index 817c5ed3c..000000000 --- a/openstack_sdk/src/api/network/v2/service_provider/list.rs +++ /dev/null @@ -1,264 +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`. - -//! Lists service providers and their associated service types. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "service-providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_providers".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "service_providers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/service-providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_providers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/service-providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_providers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/service_provider/set.rs b/openstack_sdk/src/api/network/v2/service_provider/set.rs deleted file mode 100644 index 457e29399..000000000 --- a/openstack_sdk/src/api/network/v2/service_provider/set.rs +++ /dev/null @@ -1,224 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde_json::Value; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(private, setter(into, name = "_service_provider"))] - pub(crate) service_provider: BTreeMap, Value>, - - /// id parameter for /v2.0/service-providers/{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<'a> RequestBuilder<'a> { - pub fn service_provider(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.service_provider - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Service_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("service-providers/{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( - "service_provider", - serde_json::to_value(&self.service_provider)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("service_provider".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .service_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .service_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap() - .response_key() - .unwrap(), - "service_provider" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/service-providers/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_provider(BTreeMap::::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/service-providers/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "service_provider": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .service_provider(BTreeMap::::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/create.rs b/openstack_sdk/src/api/network/v2/subnet/create.rs deleted file mode 100644 index d30998802..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/create.rs +++ /dev/null @@ -1,429 +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`. - -//! Creates a subnet on a network. -//! -//! OpenStack Networking does not try to derive the correct IP version from the -//! CIDR. If you do not specify the `gateway_ip` attribute, OpenStack -//! Networking allocates an address from the CIDR for the gateway for the -//! subnet. -//! -//! To specify a subnet without a gateway, set the `gateway_ip` attribute to -//! `null` in the request body. If you do not specify the `allocation_pools` -//! attribute, OpenStack Networking automatically allocates pools for covering -//! all IP addresses in the CIDR, excluding the address reserved for the subnet -//! gateway. Otherwise, you can explicitly specify allocation pools as shown in -//! the following example. -//! -//! When you specify both the `allocation_pools` and `gateway_ip` attributes, -//! you must ensure that the gateway IP does not overlap with the allocation -//! pools; otherwise, the call returns the `Conflict (409)` response code. -//! -//! A subnet can have one or more name servers and host routes. Hosts in this -//! subnet use the name servers. Devices with IP addresses from this subnet, -//! not including the local subnet route, use the host routes. -//! -//! Specify the `ipv6_ra_mode` and `ipv6_address_mode` attributes to create -//! subnets that support IPv6 configurations, such as stateless address -//! autoconfiguration (SLAAC), DHCPv6 stateful, and DHCPv6 stateless -//! configurations. -//! -//! A subnet can optionally be associated with a network segment when it is -//! created by specifying the `segment_id` of a valid segment on the specified -//! network. A network with subnets associated in this way is called a routed -//! network. On any given network, all of the subnets must be associated with -//! segments or none of them can be. Neutron enforces this invariant. -//! Currently, routed networks are only supported for provider networks. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationPools<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) end: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) start: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct HostRoutes<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) destination: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) nexthop: Option>, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Ipv6AddressMode { - #[serde(rename = "dhcpv6-stateful")] - Dhcpv6Stateful, - #[serde(rename = "dhcpv6-stateless")] - Dhcpv6Stateless, - #[serde(rename = "slaac")] - Slaac, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Ipv6RaMode { - #[serde(rename = "dhcpv6-stateful")] - Dhcpv6Stateful, - #[serde(rename = "dhcpv6-stateless")] - Dhcpv6Stateless, - #[serde(rename = "slaac")] - Slaac, -} - -/// A `subnet` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Subnet<'a> { - /// Allocation pools with `start` and `end` IP addresses for this subnet. - /// If allocation_pools are not specified, OpenStack Networking - /// automatically allocates pools for covering all IP addresses in the - /// CIDR, excluding the address reserved for the subnet gateway by default. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allocation_pools: Option>>, - - /// The CIDR of the subnet. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) cidr: Option>>, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// List of dns name servers associated with the subnet. Default is an - /// empty list. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_nameservers: Option>>, - - /// Whether to publish DNS records for IPs from this subnet. Default is - /// `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_publish_fixed_ip: Option, - - /// Indicates whether dhcp is enabled or disabled for the subnet. Default - /// is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enable_dhcp: Option, - - /// Gateway IP of this subnet. If the value is `null` that implies no - /// gateway is associated with the subnet. If the gateway_ip is not - /// specified, OpenStack Networking allocates an address from the CIDR for - /// the gateway for the subnet by default. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) gateway_ip: Option>>, - - /// Additional routes for the subnet. A list of dictionaries with - /// `destination` and `nexthop` parameters. Default value is an empty list. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host_routes: Option>>, - - /// The IP protocol version. Value is `4` or `6`. - #[serde()] - #[builder(setter(into))] - pub(crate) ip_version: i32, - - /// The IPv6 address modes specifies mechanisms for assigning IP addresses. - /// Value is `slaac`, `dhcpv6-stateful`, `dhcpv6-stateless`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) ipv6_address_mode: Option, - - /// The IPv6 router advertisement specifies whether the networking service - /// should transmit ICMPv6 packets, for a subnet. Value is `slaac`, - /// `dhcpv6-stateful`, `dhcpv6-stateless`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) ipv6_ra_mode: Option, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the network to which the subnet belongs. - #[serde()] - #[builder(setter(into))] - pub(crate) network_id: Cow<'a, str>, - - /// The prefix length to use for subnet allocation from a subnet pool. If - /// not specified, the `default_prefixlen` value of the subnet pool will be - /// used. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) prefixlen: Option, - - /// The ID of a network segment the subnet is associated with. It is - /// available when `segment` extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) segment_id: Option>>, - - /// The service types associated with the subnet. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_types: Option>>, - - /// The ID of the subnet pool associated with the subnet. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnetpool_id: Option>>, - - /// The ID of the project that owns the resource. Only administrative and - /// users with advsvc role can specify a project ID other than their own. - /// You cannot change this value through authorization policies. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// Whether to allocate this subnet from the default subnet pool. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) use_default_subnetpool: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `subnet` object. - #[builder(setter(into))] - pub(crate) subnet: Subnet<'a>, - - #[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 Subnet. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "subnets".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("subnet", serde_json::to_value(&self.subnet)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnet".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .subnet( - SubnetBuilder::default() - .ip_version(123) - .network_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .subnet( - SubnetBuilder::default() - .ip_version(123) - .network_id("foo") - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "subnet" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/subnets".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnet": {} })); - }); - - let endpoint = Request::builder() - .subnet( - SubnetBuilder::default() - .ip_version(123) - .network_id("foo") - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/subnets".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnet": {} })); - }); - - let endpoint = Request::builder() - .subnet( - SubnetBuilder::default() - .ip_version(123) - .network_id("foo") - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/delete.rs b/openstack_sdk/src/api/network/v2/subnet/delete.rs deleted file mode 100644 index 35e47b306..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/delete.rs +++ /dev/null @@ -1,187 +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`. - -//! Deletes a subnet. -//! -//! The operation fails if subnet IP addresses are still allocated. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// subnet_id parameter for /v2.0/subnets/{subnet_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<'a> RequestBuilder<'a> { - /// Add a single header to the Subnet. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("subnets/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/subnets/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/subnets/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/find.rs b/openstack_sdk/src/api/network/v2/subnet/find.rs deleted file mode 100644 index 6e121fb28..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::subnet::{get as Get, list as List}; - -/// Find for subnet 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/get.rs b/openstack_sdk/src/api/network/v2/subnet/get.rs deleted file mode 100644 index e51d78dd3..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/get.rs +++ /dev/null @@ -1,193 +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`. - -//! Shows details for a subnet. -//! -//! Use the fields query parameter to filter the results. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// subnet_id parameter for /v2.0/subnets/{subnet_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<'a> RequestBuilder<'a> { - /// Add a single header to the Subnet. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("subnets/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnet".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "subnet" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/subnets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnet": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/subnets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnet": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/list.rs b/openstack_sdk/src/api/network/v2/subnet/list.rs deleted file mode 100644 index b50daa77e..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/list.rs +++ /dev/null @@ -1,422 +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`. - -//! Lists subnets that the project has access to. -//! -//! Default policy settings return only subnets owned by the project of the -//! user submitting the request, unless the user has administrative role. You -//! can control which attributes are returned by using the fields query -//! parameter. You can filter results by using query string parameters. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// cidr query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - cidr: Option>, - - /// description query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - description: Option>, - - /// enable_dhcp query parameter for /v2.0/subnets API - #[builder(default)] - enable_dhcp: Option, - - /// gateway_ip query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - gateway_ip: Option>, - - /// id query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - id: Option>, - - /// ip_version query parameter for /v2.0/subnets API - #[builder(default)] - ip_version: Option, - - /// ipv6_address_mode query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - ipv6_address_mode: Option>, - - /// ipv6_ra_mode query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - ipv6_ra_mode: Option>, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// name query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - name: Option>, - - /// network_id query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - network_id: Option>, - - /// not-tags query parameter for /v2.0/subnets API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/subnets API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// revision_number query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - revision_number: Option>, - - /// The membership of a subnet to an external network. - #[builder(default)] - router_external: Option, - - /// segment_id query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - segment_id: Option>, - - /// shared query parameter for /v2.0/subnets API - #[builder(default)] - shared: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// subnetpool_id query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - subnetpool_id: Option>, - - /// tags query parameter for /v2.0/subnets API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/subnets API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/subnets API - #[builder(default, setter(into))] - tenant_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags query parameter for /v2.0/subnets API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/subnets API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/subnets API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/subnets API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Subnet. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "subnets".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - params.push_opt("cidr", self.cidr.as_ref()); - params.push_opt("description", self.description.as_ref()); - params.push_opt("enable_dhcp", self.enable_dhcp); - params.push_opt("gateway_ip", self.gateway_ip.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("ip_version", self.ip_version); - params.push_opt("ipv6_address_mode", self.ipv6_address_mode.as_ref()); - params.push_opt("ipv6_ra_mode", self.ipv6_ra_mode.as_ref()); - params.push_opt("name", self.name.as_ref()); - params.push_opt("network_id", self.network_id.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("router:external", self.router_external); - params.push_opt("segment_id", self.segment_id.as_ref()); - params.push_opt("shared", self.shared); - params.push_opt("subnetpool_id", self.subnetpool_id.as_ref()); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnets".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "subnets" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/subnets".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnets": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/subnets".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnets": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/set.rs b/openstack_sdk/src/api/network/v2/subnet/set.rs deleted file mode 100644 index 9544caf29..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/set.rs +++ /dev/null @@ -1,307 +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`. - -//! Updates a subnet. -//! -//! Some attributes, such as IP version (ip_version), CIDR (cidr), and segment -//! (segment_id) cannot be updated. Attempting to update these attributes -//! results in a `400 Bad Request` error. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationPools<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) end: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) start: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct HostRoutes<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) destination: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) nexthop: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Subnet<'a> { - /// Allocation pools with `start` and `end` IP addresses for this subnet. - /// If allocation_pools are not specified, OpenStack Networking - /// automatically allocates pools for covering all IP addresses in the - /// CIDR, excluding the address reserved for the subnet gateway by default. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allocation_pools: Option>>, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// List of dns name servers associated with the subnet. Default is an - /// empty list. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_nameservers: Option>>, - - /// Whether to publish DNS records for IPs from this subnet. Default is - /// `false`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dns_publish_fixed_ip: Option, - - /// Indicates whether dhcp is enabled or disabled for the subnet. Default - /// is `true`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) enable_dhcp: Option, - - /// Gateway IP of this subnet. If the value is `null` that implies no - /// gateway is associated with the subnet. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) gateway_ip: Option>>, - - /// Additional routes for the subnet. A list of dictionaries with - /// `destination` and `nexthop` parameters. Default value is an empty list. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) host_routes: Option>>, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of a network segment the subnet is associated with. It is - /// available when `segment` extension is enabled. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) segment_id: Option>>, - - /// The service types associated with the subnet. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) service_types: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) subnet: Subnet<'a>, - - /// subnet_id parameter for /v2.0/subnets/{subnet_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<'a> RequestBuilder<'a> { - /// Add a single header to the Subnet. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("subnets/{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("subnet", serde_json::to_value(&self.subnet)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnet".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .subnet(SubnetBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .subnet(SubnetBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "subnet" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/subnets/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnet": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnet(SubnetBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/subnets/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnet": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnet(SubnetBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/tag/delete.rs b/openstack_sdk/src/api/network/v2/subnet/tag/delete.rs deleted file mode 100644 index 1ee6ad70e..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/tag/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - subnet_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnets/{subnet_id}/tags/{id}", - id = self.id.as_ref(), - subnet_id = self.subnet_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/subnets/{subnet_id}/tags/{id}", - id = "id", - subnet_id = "subnet_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnet_id("subnet_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/subnets/{subnet_id}/tags/{id}", - id = "id", - subnet_id = "subnet_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") - .subnet_id("subnet_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/subnet/tag/delete_all.rs deleted file mode 100644 index 574147cfd..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/tag/delete_all.rs +++ /dev/null @@ -1,188 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - subnet_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnets/{subnet_id}/tags", - subnet_id = self.subnet_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/subnets/{subnet_id}/tags", - subnet_id = "subnet_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().subnet_id("subnet_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/subnets/{subnet_id}/tags", - subnet_id = "subnet_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() - .subnet_id("subnet_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/tag/get.rs b/openstack_sdk/src/api/network/v2/subnet/tag/get.rs deleted file mode 100644 index 8fde69ab7..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/tag/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - subnet_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnets/{subnet_id}/tags/{id}", - id = self.id.as_ref(), - subnet_id = self.subnet_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/subnets/{subnet_id}/tags/{id}", - id = "id", - subnet_id = "subnet_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnet_id("subnet_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/subnets/{subnet_id}/tags/{id}", - id = "id", - subnet_id = "subnet_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") - .subnet_id("subnet_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/tag/list.rs b/openstack_sdk/src/api/network/v2/subnet/tag/list.rs deleted file mode 100644 index 53d10aa9d..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/tag/list.rs +++ /dev/null @@ -1,259 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - subnet_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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnets/{subnet_id}/tags", - subnet_id = self.subnet_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/subnets/{subnet_id}/tags", - subnet_id = "subnet_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().subnet_id("subnet_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/subnets/{subnet_id}/tags", - subnet_id = "subnet_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .subnet_id("subnet_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/tag/replace.rs b/openstack_sdk/src/api/network/v2/subnet/tag/replace.rs deleted file mode 100644 index 058a22564..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/tag/replace.rs +++ /dev/null @@ -1,216 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - subnet_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "subnets/{subnet_id}/tags", - subnet_id = self.subnet_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/subnets/{subnet_id}/tags", - subnet_id = "subnet_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .subnet_id("subnet_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/subnets/{subnet_id}/tags", - subnet_id = "subnet_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .subnet_id("subnet_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnet/tag/set.rs b/openstack_sdk/src/api/network/v2/subnet/tag/set.rs deleted file mode 100644 index d9081acf2..000000000 --- a/openstack_sdk/src/api/network/v2/subnet/tag/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API - #[builder(default, setter(into))] - subnet_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "subnets/{subnet_id}/tags/{id}", - id = self.id.as_ref(), - subnet_id = self.subnet_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/subnets/{subnet_id}/tags/{id}", - id = "id", - subnet_id = "subnet_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnet_id("subnet_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/subnets/{subnet_id}/tags/{id}", - id = "id", - subnet_id = "subnet_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") - .subnet_id("subnet_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/create.rs b/openstack_sdk/src/api/network/v2/subnetpool/create.rs deleted file mode 100644 index 2758435a8..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/create.rs +++ /dev/null @@ -1,285 +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`. - -//! Creates a subnet pool. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `subnetpool` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Subnetpool<'a> { - /// An address scope to assign to the subnet pool. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) address_scope_id: Option>>, - - /// The size of the prefix to allocate when the `cidr` or `prefixlen` - /// attributes are omitted when you create the subnet. Default is - /// `min_prefixlen`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_prefixlen: Option, - - /// A per-project quota on the prefix space that can be allocated from the - /// subnet pool for project subnets. Default is no quota is enforced on - /// allocations from the subnet pool. For IPv4 subnet pools, - /// `default_quota` is measured in units of /32. For IPv6 subnet pools, - /// `default_quota` is measured units of /64. All projects that use the - /// subnet pool have the same prefix quota applied. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_quota: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The subnetpool is default pool or not. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_default: Option, - - /// The maximum prefix size that can be allocated from the subnet pool. For - /// IPv4 subnet pools, default is `32`. For IPv6 subnet pools, default is - /// `128`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_prefixlen: Option, - - /// The smallest prefix that can be allocated from a subnet pool. For IPv4 - /// subnet pools, default is `8`. For IPv6 subnet pools, default is `64`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_prefixlen: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of subnet prefixes to assign to the subnet pool. The API merges - /// adjacent prefixes and treats them as a single prefix. Each subnet - /// prefix must be unique among all subnet prefixes in all subnet pools - /// that are associated with the address scope. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) prefixes: Option>>, - - /// Indicates whether this resource is shared across all projects. By - /// default, only administrative users can change this value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) shared: Option, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `subnetpool` object. - #[builder(setter(into))] - pub(crate) subnetpool: Subnetpool<'a>, - - #[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 Subnetpool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "subnetpools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("subnetpool", serde_json::to_value(&self.subnetpool)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnetpool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "subnetpool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/subnetpools".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpool": {} })); - }); - - let endpoint = Request::builder() - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/subnetpools".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpool": {} })); - }); - - let endpoint = Request::builder() - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/delete.rs b/openstack_sdk/src/api/network/v2/subnetpool/delete.rs deleted file mode 100644 index 166a19e7d..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/delete.rs +++ /dev/null @@ -1,188 +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`. - -//! Deletes a subnet pool. -//! -//! The operation fails if any subnets allocated from the subnet pool are still -//! in use. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnetpools/{id}/remove_prefixes 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<'a> RequestBuilder<'a> { - /// Add a single header to the Subnetpool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("subnetpools/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/subnetpools/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/subnetpools/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/find.rs b/openstack_sdk/src/api/network/v2/subnetpool/find.rs deleted file mode 100644 index 777c93045..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/find.rs +++ /dev/null @@ -1,92 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; - -use crate::api::network::v2::subnetpool::{get as Get, list as List}; - -/// Find for subnetpool 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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.name(self.id.clone()); - ep.build().map_err(ApiError::endpoint_builder) - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/get.rs b/openstack_sdk/src/api/network/v2/subnetpool/get.rs deleted file mode 100644 index fc3fc2d9e..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows information for a subnet pool. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnetpools/{id}/remove_prefixes 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<'a> RequestBuilder<'a> { - /// Add a single header to the Subnetpool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("subnetpools/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnetpool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "subnetpool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/subnetpools/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpool": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/subnetpools/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/list.rs b/openstack_sdk/src/api/network/v2/subnetpool/list.rs deleted file mode 100644 index 039df4e91..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/list.rs +++ /dev/null @@ -1,406 +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`. - -//! Lists subnet pools that the project has access to. -//! -//! Default policy settings return only the subnet pools owned by the project -//! of the user submitting the request, unless the user has administrative -//! role. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use openstack_sdk_core::api::common::CommaSeparatedList; -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// address_scope_id query parameter for /v2.0/subnetpools API - #[builder(default, setter(into))] - address_scope_id: Option>, - - /// default_prefixlen query parameter for /v2.0/subnetpools API - #[builder(default)] - default_prefixlen: Option, - - /// default_quota query parameter for /v2.0/subnetpools API - #[builder(default)] - default_quota: Option, - - /// description query parameter for /v2.0/subnetpools API - #[builder(default, setter(into))] - description: Option>, - - /// id query parameter for /v2.0/subnetpools API - #[builder(default, setter(into))] - id: Option>, - - /// ip_version query parameter for /v2.0/subnetpools API - #[builder(default, setter(into))] - ip_version: Option>, - - /// is_default query parameter for /v2.0/subnetpools API - #[builder(default)] - is_default: Option, - - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// max_prefixlen query parameter for /v2.0/subnetpools API - #[builder(default)] - max_prefixlen: Option, - - /// min_prefixlen query parameter for /v2.0/subnetpools API - #[builder(default)] - min_prefixlen: Option, - - /// name query parameter for /v2.0/subnetpools API - #[builder(default, setter(into))] - name: Option>, - - /// not-tags query parameter for /v2.0/subnetpools API - #[builder(default, private, setter(name = "_not_tags"))] - not_tags: Option>>, - - /// not-tags-any query parameter for /v2.0/subnetpools API - #[builder(default, private, setter(name = "_not_tags_any"))] - not_tags_any: Option>>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// revision_number query parameter for /v2.0/subnetpools API - #[builder(default, setter(into))] - revision_number: Option>, - - /// shared query parameter for /v2.0/subnetpools API - #[builder(default)] - shared: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// tags query parameter for /v2.0/subnetpools API - #[builder(default, private, setter(name = "_tags"))] - tags: Option>>, - - /// tags-any query parameter for /v2.0/subnetpools API - #[builder(default, private, setter(name = "_tags_any"))] - tags_any: Option>>, - - /// tenant_id query parameter for /v2.0/subnetpools API - #[builder(default, setter(into))] - tenant_id: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags query parameter for /v2.0/subnetpools API - pub fn not_tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// not-tags-any query parameter for /v2.0/subnetpools API - pub fn not_tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.not_tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags query parameter for /v2.0/subnetpools API - pub fn tags(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// tags-any query parameter for /v2.0/subnetpools API - pub fn tags_any(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.tags_any - .get_or_insert(None) - .get_or_insert_with(CommaSeparatedList::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Subnetpool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "subnetpools".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - params.push_opt("address_scope_id", self.address_scope_id.as_ref()); - params.push_opt("default_prefixlen", self.default_prefixlen); - params.push_opt("default_quota", self.default_quota); - params.push_opt("description", self.description.as_ref()); - params.push_opt("id", self.id.as_ref()); - params.push_opt("ip_version", self.ip_version.as_ref()); - params.push_opt("is_default", self.is_default); - params.push_opt("max_prefixlen", self.max_prefixlen); - params.push_opt("min_prefixlen", self.min_prefixlen); - params.push_opt("name", self.name.as_ref()); - params.push_opt("not-tags", self.not_tags.as_ref()); - params.push_opt("not-tags-any", self.not_tags_any.as_ref()); - params.push_opt("revision_number", self.revision_number.as_ref()); - params.push_opt("shared", self.shared); - params.push_opt("tags", self.tags.as_ref()); - params.push_opt("tags-any", self.tags_any.as_ref()); - params.push_opt("tenant_id", self.tenant_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnetpools".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "subnetpools" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/subnetpools".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpools": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/subnetpools".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpools": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/set.rs b/openstack_sdk/src/api/network/v2/subnetpool/set.rs deleted file mode 100644 index 2197858b7..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/set.rs +++ /dev/null @@ -1,280 +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`. - -//! Updates a subnet pool. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 403, 404, 412 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `subnetpool` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Subnetpool<'a> { - /// An address scope to assign to the subnet pool. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) address_scope_id: Option>>, - - /// The size of the prefix to allocate when the `cidr` or `prefixlen` - /// attributes are omitted when you create the subnet. Default is - /// `min_prefixlen`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_prefixlen: Option, - - /// A per-project quota on the prefix space that can be allocated from the - /// subnet pool for project subnets. Default is no quota is enforced on - /// allocations from the subnet pool. For IPv4 subnet pools, - /// `default_quota` is measured in units of /32. For IPv6 subnet pools, - /// `default_quota` is measured units of /64. All projects that use the - /// subnet pool have the same prefix quota applied. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) default_quota: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The subnetpool is default pool or not. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) is_default: Option, - - /// The maximum prefix size that can be allocated from the subnet pool. For - /// IPv4 subnet pools, default is `32`. For IPv6 subnet pools, default is - /// `128`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_prefixlen: Option, - - /// The smallest prefix that can be allocated from a subnet pool. For IPv4 - /// subnet pools, default is `8`. For IPv6 subnet pools, default is `64`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_prefixlen: Option, - - /// Human-readable name of the resource. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// A list of subnet prefixes to assign to the subnet pool. The API merges - /// adjacent prefixes and treats them as a single prefix. Each subnet - /// prefix must be unique among all subnet prefixes in all subnet pools - /// that are associated with the address scope. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) prefixes: Option>>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `subnetpool` object. - #[builder(setter(into))] - pub(crate) subnetpool: Subnetpool<'a>, - - /// id parameter for /v2.0/subnetpools/{id}/remove_prefixes 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<'a> RequestBuilder<'a> { - /// Add a single header to the Subnetpool. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("subnetpools/{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("subnetpool", serde_json::to_value(&self.subnetpool)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("subnetpool".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "subnetpool" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/subnetpools/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/subnetpools/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "subnetpool": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnetpool(SubnetpoolBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/tag/delete.rs b/openstack_sdk/src/api/network/v2/subnetpool/tag/delete.rs deleted file mode 100644 index 210e74025..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/tag/delete.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} - /// API - #[builder(default, setter(into))] - subnetpool_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnetpools/{subnetpool_id}/tags/{id}", - id = self.id.as_ref(), - subnetpool_id = self.subnetpool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/subnetpools/{subnetpool_id}/tags/{id}", - id = "id", - subnetpool_id = "subnetpool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnetpool_id("subnetpool_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/subnetpools/{subnetpool_id}/tags/{id}", - id = "id", - subnetpool_id = "subnetpool_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") - .subnetpool_id("subnetpool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/subnetpool/tag/delete_all.rs deleted file mode 100644 index 1443e2d83..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/tag/delete_all.rs +++ /dev/null @@ -1,192 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} - /// API - #[builder(default, setter(into))] - subnetpool_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnetpools/{subnetpool_id}/tags", - subnetpool_id = self.subnetpool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/subnetpools/{subnetpool_id}/tags", - subnetpool_id = "subnetpool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .subnetpool_id("subnetpool_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/subnetpools/{subnetpool_id}/tags", - subnetpool_id = "subnetpool_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() - .subnetpool_id("subnetpool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/tag/get.rs b/openstack_sdk/src/api/network/v2/subnetpool/tag/get.rs deleted file mode 100644 index d427881d4..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/tag/get.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} - /// API - #[builder(default, setter(into))] - subnetpool_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnetpools/{subnetpool_id}/tags/{id}", - id = self.id.as_ref(), - subnetpool_id = self.subnetpool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/subnetpools/{subnetpool_id}/tags/{id}", - id = "id", - subnetpool_id = "subnetpool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnetpool_id("subnetpool_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/subnetpools/{subnetpool_id}/tags/{id}", - id = "id", - subnetpool_id = "subnetpool_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") - .subnetpool_id("subnetpool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/tag/list.rs b/openstack_sdk/src/api/network/v2/subnetpool/tag/list.rs deleted file mode 100644 index 6de44fb40..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/tag/list.rs +++ /dev/null @@ -1,263 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} - /// API - #[builder(default, setter(into))] - subnetpool_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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "subnetpools/{subnetpool_id}/tags", - subnetpool_id = self.subnetpool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/subnetpools/{subnetpool_id}/tags", - subnetpool_id = "subnetpool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .subnetpool_id("subnetpool_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/subnetpools/{subnetpool_id}/tags", - subnetpool_id = "subnetpool_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .subnetpool_id("subnetpool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/tag/replace.rs b/openstack_sdk/src/api/network/v2/subnetpool/tag/replace.rs deleted file mode 100644 index b5c7dea83..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/tag/replace.rs +++ /dev/null @@ -1,217 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} - /// API - #[builder(default, setter(into))] - subnetpool_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "subnetpools/{subnetpool_id}/tags", - subnetpool_id = self.subnetpool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/subnetpools/{subnetpool_id}/tags", - subnetpool_id = "subnetpool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .subnetpool_id("subnetpool_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/subnetpools/{subnetpool_id}/tags", - subnetpool_id = "subnetpool_id", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .subnetpool_id("subnetpool_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/tag/set.rs b/openstack_sdk/src/api/network/v2/subnetpool/tag/set.rs deleted file mode 100644 index d349ba51e..000000000 --- a/openstack_sdk/src/api/network/v2/subnetpool/tag/set.rs +++ /dev/null @@ -1,201 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} - /// API - #[builder(default, setter(into))] - subnetpool_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "subnetpools/{subnetpool_id}/tags/{id}", - id = self.id.as_ref(), - subnetpool_id = self.subnetpool_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/subnetpools/{subnetpool_id}/tags/{id}", - id = "id", - subnetpool_id = "subnetpool_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .subnetpool_id("subnetpool_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/subnetpools/{subnetpool_id}/tags/{id}", - id = "id", - subnetpool_id = "subnetpool_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") - .subnetpool_id("subnetpool_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/trunk/tag/delete.rs b/openstack_sdk/src/api/network/v2/trunk/tag/delete.rs deleted file mode 100644 index 83475d7f1..000000000 --- a/openstack_sdk/src/api/network/v2/trunk/tag/delete.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - trunk_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "trunks/{trunk_id}/tags/{id}", - id = self.id.as_ref(), - trunk_id = self.trunk_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/trunks/{trunk_id}/tags/{id}", - id = "id", - trunk_id = "trunk_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .trunk_id("trunk_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/trunks/{trunk_id}/tags/{id}", - id = "id", - trunk_id = "trunk_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") - .trunk_id("trunk_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/trunk/tag/delete_all.rs b/openstack_sdk/src/api/network/v2/trunk/tag/delete_all.rs deleted file mode 100644 index b9bb1eddb..000000000 --- a/openstack_sdk/src/api/network/v2/trunk/tag/delete_all.rs +++ /dev/null @@ -1,179 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - trunk_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("trunks/{trunk_id}/tags", trunk_id = self.trunk_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().trunk_id("trunk_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_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() - .trunk_id("trunk_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/trunk/tag/get.rs b/openstack_sdk/src/api/network/v2/trunk/tag/get.rs deleted file mode 100644 index c6408a828..000000000 --- a/openstack_sdk/src/api/network/v2/trunk/tag/get.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - trunk_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "trunks/{trunk_id}/tags/{id}", - id = self.id.as_ref(), - trunk_id = self.trunk_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/trunks/{trunk_id}/tags/{id}", - id = "id", - trunk_id = "trunk_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .trunk_id("trunk_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/trunks/{trunk_id}/tags/{id}", - id = "id", - trunk_id = "trunk_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") - .trunk_id("trunk_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/trunk/tag/list.rs b/openstack_sdk/src/api/network/v2/trunk/tag/list.rs deleted file mode 100644 index 5853f5ea5..000000000 --- a/openstack_sdk/src/api/network/v2/trunk/tag/list.rs +++ /dev/null @@ -1,250 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: Option>>, - - /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - trunk_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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("trunks/{trunk_id}/tags", trunk_id = self.trunk_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder().trunk_id("trunk_id").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .trunk_id("trunk_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/trunk/tag/replace.rs b/openstack_sdk/src/api/network/v2/trunk/tag/replace.rs deleted file mode 100644 index 779a5eb8f..000000000 --- a/openstack_sdk/src/api/network/v2/trunk/tag/replace.rs +++ /dev/null @@ -1,207 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) tags: Vec>, - - /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - trunk_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("trunks/{trunk_id}/tags", trunk_id = self.trunk_id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("tags", serde_json::to_value(&self.tags)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("tags".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .tags(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "tags" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .trunk_id("trunk_id") - .tags(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "tags": {} })); - }); - - let endpoint = Request::builder() - .trunk_id("trunk_id") - .tags(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/trunk/tag/set.rs b/openstack_sdk/src/api/network/v2/trunk/tag/set.rs deleted file mode 100644 index f40b9a470..000000000 --- a/openstack_sdk/src/api/network/v2/trunk/tag/set.rs +++ /dev/null @@ -1,200 +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`. - -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - id: Cow<'a, str>, - - /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API - #[builder(default, setter(into))] - trunk_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 Tag. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "trunks/{trunk_id}/tags/{id}", - id = self.id.as_ref(), - trunk_id = self.trunk_id.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/trunks/{trunk_id}/tags/{id}", - id = "id", - trunk_id = "trunk_id", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .trunk_id("trunk_id") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/trunks/{trunk_id}/tags/{id}", - id = "id", - trunk_id = "trunk_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") - .trunk_id("trunk_id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/create.rs b/openstack_sdk/src/api/network/v2/vpn/endpoint_group/create.rs deleted file mode 100644 index cda8b47bf..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/create.rs +++ /dev/null @@ -1,262 +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`. - -//! Creates a VPN endpoint group. -//! -//! The endpoint group contains one or more endpoints of a specific type that -//! you can use to create a VPN connections. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Type { - #[serde(rename = "cidr")] - Cidr, - #[serde(rename = "network")] - Network, - #[serde(rename = "router")] - Router, - #[serde(rename = "subnet")] - Subnet, - #[serde(rename = "vlan")] - Vlan, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct EndpointGroup<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// List of endpoints of the same type, for the endpoint group. The values - /// will depend on type. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) endpoints: Option>>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The type of the endpoints in the group. A valid value is `subnet`, - /// `cidr`, `network`, `router`, or `vlan`. Only `subnet` and `cidr` are - /// supported at this moment. - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) _type: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) endpoint_group: EndpointGroup<'a>, - - #[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 Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/endpoint-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "endpoint_group", - serde_json::to_value(&self.endpoint_group)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("endpoint_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "endpoint_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/endpoint-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/endpoint-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/delete.rs b/openstack_sdk/src/api/network/v2/vpn/endpoint_group/delete.rs deleted file mode 100644 index 4d4a94525..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Removes a VPN endpoint group. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/endpoint-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/endpoint-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/endpoint-groups/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/endpoint-groups/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/find.rs b/openstack_sdk/src/api/network/v2/vpn/endpoint_group/find.rs deleted file mode 100644 index 86951a7b6..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::network::v2::vpn::endpoint_group::{get as Get, list as List}; - -/// Find for vpn/endpoint_group 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate vpn/endpoint_group in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // vpn/endpoint_group 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") - && let Some(name) = name_as_val.as_str() - && 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/network/v2/vpn/endpoint_group/get.rs b/openstack_sdk/src/api/network/v2/vpn/endpoint_group/get.rs deleted file mode 100644 index c130d774c..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for a VPN endpoint group. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/endpoint-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/endpoint-groups/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("endpoint_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "endpoint_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/endpoint-groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/endpoint-groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/list.rs b/openstack_sdk/src/api/network/v2/vpn/endpoint_group/list.rs deleted file mode 100644 index e87d6f89b..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/list.rs +++ /dev/null @@ -1,264 +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`. - -//! Lists VPN endpoint groups. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/endpoint-groups".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("endpoint_groups".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "endpoint_groups" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/endpoint-groups".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_groups": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/endpoint-groups".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_groups": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/set.rs b/openstack_sdk/src/api/network/v2/vpn/endpoint_group/set.rs deleted file mode 100644 index 2b3b0adf0..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/endpoint_group/set.rs +++ /dev/null @@ -1,233 +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`. - -//! Updates settings for a VPN endpoint group. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct EndpointGroup<'a> { - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) endpoint_group: EndpointGroup<'a>, - - /// id parameter for /v2.0/vpn/endpoint-groups/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Endpoint_Group. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("vpn/endpoint-groups/{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( - "endpoint_group", - serde_json::to_value(&self.endpoint_group)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("endpoint_group".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "endpoint_group" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/endpoint-groups/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/endpoint-groups/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "endpoint_group": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/create.rs b/openstack_sdk/src/api/network/v2/vpn/ikepolicy/create.rs deleted file mode 100644 index 5d30937ba..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/create.rs +++ /dev/null @@ -1,404 +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`. - -//! Creates an IKE policy. -//! -//! The IKE policy is used for phases one and two negotiation of the VPN -//! connection. You can specify both the authentication and encryption -//! algorithms for connections. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum AuthAlgorithm { - #[serde(rename = "aes-cmac")] - AesCmac, - #[serde(rename = "aes-xcbc")] - AesXcbc, - #[serde(rename = "sha1")] - Sha1, - #[serde(rename = "sha256")] - Sha256, - #[serde(rename = "sha384")] - Sha384, - #[serde(rename = "sha512")] - Sha512, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum EncryptionAlgorithm { - #[serde(rename = "3des")] - _3des, - #[serde(rename = "aes-128")] - Aes128, - #[serde(rename = "aes-128-ccm-12")] - Aes128Ccm12, - #[serde(rename = "aes-128-ccm-16")] - Aes128Ccm16, - #[serde(rename = "aes-128-ccm-8")] - Aes128Ccm8, - #[serde(rename = "aes-128-ctr")] - Aes128Ctr, - #[serde(rename = "aes-128-gcm-12")] - Aes128Gcm12, - #[serde(rename = "aes-128-gcm-16")] - Aes128Gcm16, - #[serde(rename = "aes-128-gcm-8")] - Aes128Gcm8, - #[serde(rename = "aes-192")] - Aes192, - #[serde(rename = "aes-192-ccm-12")] - Aes192Ccm12, - #[serde(rename = "aes-192-ccm-16")] - Aes192Ccm16, - #[serde(rename = "aes-192-ccm-8")] - Aes192Ccm8, - #[serde(rename = "aes-192-ctr")] - Aes192Ctr, - #[serde(rename = "aes-192-gcm-12")] - Aes192Gcm12, - #[serde(rename = "aes-192-gcm-16")] - Aes192Gcm16, - #[serde(rename = "aes-192-gcm-8")] - Aes192Gcm8, - #[serde(rename = "aes-256")] - Aes256, - #[serde(rename = "aes-256-ccm-12")] - Aes256Ccm12, - #[serde(rename = "aes-256-ccm-16")] - Aes256Ccm16, - #[serde(rename = "aes-256-ccm-8")] - Aes256Ccm8, - #[serde(rename = "aes-256-ctr")] - Aes256Ctr, - #[serde(rename = "aes-256-gcm-12")] - Aes256Gcm12, - #[serde(rename = "aes-256-gcm-16")] - Aes256Gcm16, - #[serde(rename = "aes-256-gcm-8")] - Aes256Gcm8, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum IkeVersion { - #[serde(rename = "v1")] - V1, - #[serde(rename = "v2")] - V2, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Pfs { - #[serde(rename = "group14")] - Group14, - #[serde(rename = "group15")] - Group15, - #[serde(rename = "group16")] - Group16, - #[serde(rename = "group17")] - Group17, - #[serde(rename = "group18")] - Group18, - #[serde(rename = "group19")] - Group19, - #[serde(rename = "group2")] - Group2, - #[serde(rename = "group20")] - Group20, - #[serde(rename = "group21")] - Group21, - #[serde(rename = "group22")] - Group22, - #[serde(rename = "group23")] - Group23, - #[serde(rename = "group24")] - Group24, - #[serde(rename = "group25")] - Group25, - #[serde(rename = "group26")] - Group26, - #[serde(rename = "group27")] - Group27, - #[serde(rename = "group28")] - Group28, - #[serde(rename = "group29")] - Group29, - #[serde(rename = "group30")] - Group30, - #[serde(rename = "group31")] - Group31, - #[serde(rename = "group5")] - Group5, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Phase1NegotiationMode { - #[serde(rename = "aggressive")] - Aggressive, - #[serde(rename = "main")] - Main, -} - -/// An `ikepolicy` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Ikepolicy<'a> { - /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, - /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) auth_algorithm: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The encryption algorithm. A valid value is `3des`, `aes-128`, - /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. - /// Additional values for AES CCM and GCM modes are defined (e.g. - /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length - /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is - /// `aes-128`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) encryption_algorithm: Option, - - /// The IKE version. A valid value is `v1` or `v2`. Default is `v1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) ike_version: Option, - - /// The lifetime of the security association. The lifetime consists of a - /// unit and integer value. You can omit either the unit or value portion - /// of the lifetime. Default unit is seconds and default value is 3600. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) lifetime: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, - /// `Group14` to `Group31`. Default is `Group5`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) pfs: Option, - - /// The IKE mode. A valid value is `main`, which is the default. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) phase1_negotiation_mode: Option, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `ikepolicy` object. - #[builder(setter(into))] - pub(crate) ikepolicy: Ikepolicy<'a>, - - #[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 Ikepolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/ikepolicies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("ikepolicy", serde_json::to_value(&self.ikepolicy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ikepolicy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ikepolicy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/ikepolicies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicy": {} })); - }); - - let endpoint = Request::builder() - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/ikepolicies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicy": {} })); - }); - - let endpoint = Request::builder() - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/delete.rs b/openstack_sdk/src/api/network/v2/vpn/ikepolicy/delete.rs deleted file mode 100644 index 9e9201ff9..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Removes an IKE policy. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/ikepolicies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ikepolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/ikepolicies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/ikepolicies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/ikepolicies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/find.rs b/openstack_sdk/src/api/network/v2/vpn/ikepolicy/find.rs deleted file mode 100644 index f6198dfc9..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::network::v2::vpn::ikepolicy::{get as Get, list as List}; - -/// Find for vpn/ikepolicy 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate vpn/ikepolicy in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // vpn/ikepolicy 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") - && let Some(name) = name_as_val.as_str() - && 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/network/v2/vpn/ikepolicy/get.rs b/openstack_sdk/src/api/network/v2/vpn/ikepolicy/get.rs deleted file mode 100644 index 59aee0d66..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for an IKE policy. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/ikepolicies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ikepolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/ikepolicies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ikepolicy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ikepolicy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/ikepolicies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicy": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/ikepolicies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/list.rs b/openstack_sdk/src/api/network/v2/vpn/ikepolicy/list.rs deleted file mode 100644 index dec47d7a9..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/list.rs +++ /dev/null @@ -1,264 +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`. - -//! Lists IKE policies. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Ikepolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/ikepolicies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ikepolicies".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ikepolicies" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/ikepolicies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicies": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/ikepolicies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicies": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/set.rs b/openstack_sdk/src/api/network/v2/vpn/ikepolicy/set.rs deleted file mode 100644 index 8540637ad..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ikepolicy/set.rs +++ /dev/null @@ -1,401 +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`. - -//! Updates policy settings in an IKE policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum AuthAlgorithm { - #[serde(rename = "aes-cmac")] - AesCmac, - #[serde(rename = "aes-xcbc")] - AesXcbc, - #[serde(rename = "sha1")] - Sha1, - #[serde(rename = "sha256")] - Sha256, - #[serde(rename = "sha384")] - Sha384, - #[serde(rename = "sha512")] - Sha512, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum EncryptionAlgorithm { - #[serde(rename = "3des")] - _3des, - #[serde(rename = "aes-128")] - Aes128, - #[serde(rename = "aes-128-ccm-12")] - Aes128Ccm12, - #[serde(rename = "aes-128-ccm-16")] - Aes128Ccm16, - #[serde(rename = "aes-128-ccm-8")] - Aes128Ccm8, - #[serde(rename = "aes-128-ctr")] - Aes128Ctr, - #[serde(rename = "aes-128-gcm-12")] - Aes128Gcm12, - #[serde(rename = "aes-128-gcm-16")] - Aes128Gcm16, - #[serde(rename = "aes-128-gcm-8")] - Aes128Gcm8, - #[serde(rename = "aes-192")] - Aes192, - #[serde(rename = "aes-192-ccm-12")] - Aes192Ccm12, - #[serde(rename = "aes-192-ccm-16")] - Aes192Ccm16, - #[serde(rename = "aes-192-ccm-8")] - Aes192Ccm8, - #[serde(rename = "aes-192-ctr")] - Aes192Ctr, - #[serde(rename = "aes-192-gcm-12")] - Aes192Gcm12, - #[serde(rename = "aes-192-gcm-16")] - Aes192Gcm16, - #[serde(rename = "aes-192-gcm-8")] - Aes192Gcm8, - #[serde(rename = "aes-256")] - Aes256, - #[serde(rename = "aes-256-ccm-12")] - Aes256Ccm12, - #[serde(rename = "aes-256-ccm-16")] - Aes256Ccm16, - #[serde(rename = "aes-256-ccm-8")] - Aes256Ccm8, - #[serde(rename = "aes-256-ctr")] - Aes256Ctr, - #[serde(rename = "aes-256-gcm-12")] - Aes256Gcm12, - #[serde(rename = "aes-256-gcm-16")] - Aes256Gcm16, - #[serde(rename = "aes-256-gcm-8")] - Aes256Gcm8, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum IkeVersion { - #[serde(rename = "v1")] - V1, - #[serde(rename = "v2")] - V2, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Pfs { - #[serde(rename = "group14")] - Group14, - #[serde(rename = "group15")] - Group15, - #[serde(rename = "group16")] - Group16, - #[serde(rename = "group17")] - Group17, - #[serde(rename = "group18")] - Group18, - #[serde(rename = "group19")] - Group19, - #[serde(rename = "group2")] - Group2, - #[serde(rename = "group20")] - Group20, - #[serde(rename = "group21")] - Group21, - #[serde(rename = "group22")] - Group22, - #[serde(rename = "group23")] - Group23, - #[serde(rename = "group24")] - Group24, - #[serde(rename = "group25")] - Group25, - #[serde(rename = "group26")] - Group26, - #[serde(rename = "group27")] - Group27, - #[serde(rename = "group28")] - Group28, - #[serde(rename = "group29")] - Group29, - #[serde(rename = "group30")] - Group30, - #[serde(rename = "group31")] - Group31, - #[serde(rename = "group5")] - Group5, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Phase1NegotiationMode { - #[serde(rename = "aggressive")] - Aggressive, - #[serde(rename = "main")] - Main, -} - -/// An `ikepolicy` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Ikepolicy<'a> { - /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, - /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) auth_algorithm: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The encryption algorithm. A valid value is `3des`, `aes-128`, - /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. - /// Additional values for AES CCM and GCM modes are defined (e.g. - /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length - /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is - /// `aes-128`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) encryption_algorithm: Option, - - /// The IKE version. A valid value is `v1` or `v2`. Default is `v1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) ike_version: Option, - - /// The lifetime of the security association. The lifetime consists of a - /// unit and integer value. You can omit either the unit or value portion - /// of the lifetime. Default unit is seconds and default value is 3600. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) lifetime: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, - /// `Group14` to `Group31`. Default is `Group5`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) pfs: Option, - - /// The IKE mode. A valid value is `main`, which is the default. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) phase1_negotiation_mode: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `ikepolicy` object. - #[builder(setter(into))] - pub(crate) ikepolicy: Ikepolicy<'a>, - - /// id parameter for /v2.0/vpn/ikepolicies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ikepolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("vpn/ikepolicies/{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("ikepolicy", serde_json::to_value(&self.ikepolicy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ikepolicy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ikepolicy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/ikepolicies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/ikepolicies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ikepolicy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ikepolicy(IkepolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/create.rs b/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/create.rs deleted file mode 100644 index c37d68c5d..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/create.rs +++ /dev/null @@ -1,330 +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`. - -//! Creates a site-to-site IPsec connection for a service. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Initiator { - #[serde(rename = "bi-directional")] - BiDirectional, - #[serde(rename = "response-only")] - ResponseOnly, -} - -/// An `ipsec_site_connection` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct IpsecSiteConnection<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// A dictionary with dead peer detection (DPD) protocol controls. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dpd: Option>, - - /// The ID of the IKE policy. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ikepolicy_id: Option>, - - /// Indicates whether this VPN can only respond to connections or both - /// respond to and initiate connections. A valid value is `response- only` - /// or `bi-directional`. Default is `bi-directional`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) initiator: Option, - - /// The ID of the IPsec policy. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) ipsecpolicy_id: Option>, - - /// The ID for the endpoint group that contains private subnets for the - /// local side of the connection. Yo must specify this parameter with the - /// `peer_ep_group_id` parameter unless in backward- compatible mode where - /// `peer_cidrs` is provided with a `subnet_id` for the VPN service. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) local_ep_group_id: Option>>, - - /// An ID to be used instead of the external IP address for a virtual - /// router used in traffic between instances on different networks in - /// east-west traffic. Most often, local ID would be domain name, email - /// address, etc. If this is not configured then the external IP address - /// will be used as the ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) local_id: Option>, - - /// The maximum transmission unit (MTU) value to address fragmentation. - /// Minimum value is 68 for IPv4, and 1280 for IPv6. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) mtu: Option, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The peer gateway public IPv4 or IPv6 address or FQDN. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_address: Option>, - - /// (Deprecated) Unique list of valid peer private CIDRs in the form \< - /// net_address > / < prefix > . - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_cidrs: Option>>, - - /// The ID for the endpoint group that contains private CIDRs in the form - /// \< net_address > / < prefix > for the peer side of the connection. You - /// must specify this parameter with the `local_ep_group_id` parameter - /// unless in backward-compatible mode where `peer_cidrs` is provided with - /// a `subnet_id` for the VPN service. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_ep_group_id: Option>>, - - /// The peer router identity for authentication. A valid value is an IPv4 - /// address, IPv6 address, e-mail address, key ID, or FQDN. Typically, this - /// value matches the `peer_address` value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_id: Option>, - - /// The pre-shared key. A valid value is any string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) psk: Option>, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The ID of the VPN service. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) vpnservice_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `ipsec_site_connection` object. - #[builder(setter(into))] - pub(crate) ipsec_site_connection: IpsecSiteConnection<'a>, - - #[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 Ipsec_Site_Connection. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/ipsec-site-connections".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push( - "ipsec_site_connection", - serde_json::to_value(&self.ipsec_site_connection)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsec_site_connection".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ipsec_site_connection" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/ipsec-site-connections".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connection": {} })); - }); - - let endpoint = Request::builder() - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/ipsec-site-connections".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connection": {} })); - }); - - let endpoint = Request::builder() - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/delete.rs b/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/delete.rs deleted file mode 100644 index 93ce832d0..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Removes an IPsec connection. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/ipsec-site-connections/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ipsec_Site_Connection. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/ipsec-site-connections/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/ipsec-site-connections/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/ipsec-site-connections/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/find.rs b/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/find.rs deleted file mode 100644 index 9b2498b7a..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::network::v2::vpn::ipsec_site_connection::{get as Get, list as List}; - -/// Find for vpn/ipsec_site_connection 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate vpn/ipsec_site_connection in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // vpn/ipsec_site_connection 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") - && let Some(name) = name_as_val.as_str() - && 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/network/v2/vpn/ipsec_site_connection/get.rs b/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/get.rs deleted file mode 100644 index 1a4d23cfe..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for an IPsec connection. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/ipsec-site-connections/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ipsec_Site_Connection. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/ipsec-site-connections/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsec_site_connection".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ipsec_site_connection" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connection": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connection": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/list.rs b/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/list.rs deleted file mode 100644 index e7ab53b19..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/list.rs +++ /dev/null @@ -1,264 +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`. - -//! Lists all IPsec connections. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Ipsec_Site_Connection. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/ipsec-site-connections".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsec_site_connections".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ipsec_site_connections" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/ipsec-site-connections".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connections": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/ipsec-site-connections".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connections": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/set.rs b/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/set.rs deleted file mode 100644 index d75de37be..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection/set.rs +++ /dev/null @@ -1,316 +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`. - -//! Updates connection settings for an IPsec connection. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Initiator { - #[serde(rename = "bi-directional")] - BiDirectional, - #[serde(rename = "response-only")] - ResponseOnly, -} - -/// An `ipsec_site_connection` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct IpsecSiteConnection<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// A dictionary with dead peer detection (DPD) protocol controls. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) dpd: Option>, - - /// Indicates whether this VPN can only respond to connections or both - /// respond to and initiate connections. A valid value is `response- only` - /// or `bi-directional`. Default is `bi-directional`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) initiator: Option, - - /// The ID for the endpoint group that contains private subnets for the - /// local side of the connection. Yo must specify this parameter with the - /// `peer_ep_group_id` parameter unless in backward- compatible mode where - /// `peer_cidrs` is provided with a `subnet_id` for the VPN service. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) local_ep_group_id: Option>>, - - /// An ID to be used instead of the external IP address for a virtual - /// router used in traffic between instances on different networks in - /// east-west traffic. Most often, local ID would be domain name, email - /// address, etc. If this is not configured then the external IP address - /// will be used as the ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) local_id: Option>, - - /// The maximum transmission unit (MTU) value to address fragmentation. - /// Minimum value is 68 for IPv4, and 1280 for IPv6. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) mtu: Option, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The peer gateway public IPv4 or IPv6 address or FQDN. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_address: Option>, - - /// (Deprecated) Unique list of valid peer private CIDRs in the form \< - /// net_address > / < prefix > . - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_cidrs: Option>>, - - /// The ID for the endpoint group that contains private CIDRs in the form - /// \< net_address > / < prefix > for the peer side of the connection. You - /// must specify this parameter with the `local_ep_group_id` parameter - /// unless in backward-compatible mode where `peer_cidrs` is provided with - /// a `subnet_id` for the VPN service. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_ep_group_id: Option>>, - - /// The peer router identity for authentication. A valid value is an IPv4 - /// address, IPv6 address, e-mail address, key ID, or FQDN. Typically, this - /// value matches the `peer_address` value. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) peer_id: Option>, - - /// The pre-shared key. A valid value is any string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) psk: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `ipsec_site_connection` object. - #[builder(setter(into))] - pub(crate) ipsec_site_connection: IpsecSiteConnection<'a>, - - /// id parameter for /v2.0/vpn/ipsec-site-connections/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ipsec_Site_Connection. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("vpn/ipsec-site-connections/{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( - "ipsec_site_connection", - serde_json::to_value(&self.ipsec_site_connection)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsec_site_connection".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ipsec_site_connection" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connection": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsec_site_connection": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/create.rs b/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/create.rs deleted file mode 100644 index 0069bbdb4..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/create.rs +++ /dev/null @@ -1,407 +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`. - -//! Creates an IP security (IPsec) policy. -//! -//! The IPsec policy specifies the authentication and encryption algorithms and -//! encapsulation mode to use for the established VPN connection. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum AuthAlgorithm { - #[serde(rename = "aes-cmac")] - AesCmac, - #[serde(rename = "aes-xcbc")] - AesXcbc, - #[serde(rename = "sha1")] - Sha1, - #[serde(rename = "sha256")] - Sha256, - #[serde(rename = "sha384")] - Sha384, - #[serde(rename = "sha512")] - Sha512, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum EncapsulationMode { - #[serde(rename = "transport")] - Transport, - #[serde(rename = "tunnel")] - Tunnel, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum EncryptionAlgorithm { - #[serde(rename = "3des")] - _3des, - #[serde(rename = "aes-128")] - Aes128, - #[serde(rename = "aes-128-ccm-12")] - Aes128Ccm12, - #[serde(rename = "aes-128-ccm-16")] - Aes128Ccm16, - #[serde(rename = "aes-128-ccm-8")] - Aes128Ccm8, - #[serde(rename = "aes-128-ctr")] - Aes128Ctr, - #[serde(rename = "aes-128-gcm-12")] - Aes128Gcm12, - #[serde(rename = "aes-128-gcm-16")] - Aes128Gcm16, - #[serde(rename = "aes-128-gcm-8")] - Aes128Gcm8, - #[serde(rename = "aes-192")] - Aes192, - #[serde(rename = "aes-192-ccm-12")] - Aes192Ccm12, - #[serde(rename = "aes-192-ccm-16")] - Aes192Ccm16, - #[serde(rename = "aes-192-ccm-8")] - Aes192Ccm8, - #[serde(rename = "aes-192-ctr")] - Aes192Ctr, - #[serde(rename = "aes-192-gcm-12")] - Aes192Gcm12, - #[serde(rename = "aes-192-gcm-16")] - Aes192Gcm16, - #[serde(rename = "aes-192-gcm-8")] - Aes192Gcm8, - #[serde(rename = "aes-256")] - Aes256, - #[serde(rename = "aes-256-ccm-12")] - Aes256Ccm12, - #[serde(rename = "aes-256-ccm-16")] - Aes256Ccm16, - #[serde(rename = "aes-256-ccm-8")] - Aes256Ccm8, - #[serde(rename = "aes-256-ctr")] - Aes256Ctr, - #[serde(rename = "aes-256-gcm-12")] - Aes256Gcm12, - #[serde(rename = "aes-256-gcm-16")] - Aes256Gcm16, - #[serde(rename = "aes-256-gcm-8")] - Aes256Gcm8, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Pfs { - #[serde(rename = "group14")] - Group14, - #[serde(rename = "group15")] - Group15, - #[serde(rename = "group16")] - Group16, - #[serde(rename = "group17")] - Group17, - #[serde(rename = "group18")] - Group18, - #[serde(rename = "group19")] - Group19, - #[serde(rename = "group2")] - Group2, - #[serde(rename = "group20")] - Group20, - #[serde(rename = "group21")] - Group21, - #[serde(rename = "group22")] - Group22, - #[serde(rename = "group23")] - Group23, - #[serde(rename = "group24")] - Group24, - #[serde(rename = "group25")] - Group25, - #[serde(rename = "group26")] - Group26, - #[serde(rename = "group27")] - Group27, - #[serde(rename = "group28")] - Group28, - #[serde(rename = "group29")] - Group29, - #[serde(rename = "group30")] - Group30, - #[serde(rename = "group31")] - Group31, - #[serde(rename = "group5")] - Group5, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum TransformProtocol { - #[serde(rename = "ah")] - Ah, - #[serde(rename = "ah-esp")] - AhEsp, - #[serde(rename = "esp")] - Esp, -} - -/// An `ipsecpolicy` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Ipsecpolicy<'a> { - /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, - /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) auth_algorithm: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The encapsulation mode. A valid value is `tunnel` or `transport`. - /// Default is `tunnel`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) encapsulation_mode: Option, - - /// The encryption algorithm. A valid value is `3des`, `aes-128`, - /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. - /// Additional values for AES CCM and GCM modes are defined (e.g. - /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length - /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is - /// `aes-128`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) encryption_algorithm: Option, - - /// The lifetime of the security association. The lifetime consists of a - /// unit and integer value. You can omit either the unit or value portion - /// of the lifetime. Default unit is seconds and default value is 3600. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) lifetime: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, - /// `Group14` to `Group31`. Default is `Group5`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) pfs: Option, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, - - /// The transform protocol. A valid value is `ESP`, `AH`, or `AH- ESP`. - /// Default is `ESP`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) transform_protocol: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `ipsecpolicy` object. - #[builder(setter(into))] - pub(crate) ipsecpolicy: Ipsecpolicy<'a>, - - #[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 Ipsecpolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/ipsecpolicies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("ipsecpolicy", serde_json::to_value(&self.ipsecpolicy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsecpolicy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ipsecpolicy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/ipsecpolicies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicy": {} })); - }); - - let endpoint = Request::builder() - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/ipsecpolicies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicy": {} })); - }); - - let endpoint = Request::builder() - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/delete.rs b/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/delete.rs deleted file mode 100644 index 17bea15c3..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/delete.rs +++ /dev/null @@ -1,185 +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`. - -//! Removes an IPsec policy. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/ipsecpolicies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ipsecpolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/ipsecpolicies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/ipsecpolicies/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/ipsecpolicies/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/find.rs b/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/find.rs deleted file mode 100644 index e50266fce..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::network::v2::vpn::ipsecpolicy::{get as Get, list as List}; - -/// Find for vpn/ipsecpolicy 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate vpn/ipsecpolicy in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // vpn/ipsecpolicy 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") - && let Some(name) = name_as_val.as_str() - && 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/network/v2/vpn/ipsecpolicy/get.rs b/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/get.rs deleted file mode 100644 index 1007b23c5..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/get.rs +++ /dev/null @@ -1,191 +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`. - -//! Shows details for an IPsec policy. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/ipsecpolicies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ipsecpolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/ipsecpolicies/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsecpolicy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ipsecpolicy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicy": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/list.rs b/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/list.rs deleted file mode 100644 index 72ef7fb4f..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/list.rs +++ /dev/null @@ -1,264 +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`. - -//! Lists all IPsec policies. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Ipsecpolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/ipsecpolicies".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsecpolicies".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "ipsecpolicies" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/ipsecpolicies".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicies": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/ipsecpolicies".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicies": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/set.rs b/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/set.rs deleted file mode 100644 index fe07ec925..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy/set.rs +++ /dev/null @@ -1,405 +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`. - -//! Updates policy settings in an IPsec policy. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum AuthAlgorithm { - #[serde(rename = "aes-cmac")] - AesCmac, - #[serde(rename = "aes-xcbc")] - AesXcbc, - #[serde(rename = "sha1")] - Sha1, - #[serde(rename = "sha256")] - Sha256, - #[serde(rename = "sha384")] - Sha384, - #[serde(rename = "sha512")] - Sha512, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum EncapsulationMode { - #[serde(rename = "transport")] - Transport, - #[serde(rename = "tunnel")] - Tunnel, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum EncryptionAlgorithm { - #[serde(rename = "3des")] - _3des, - #[serde(rename = "aes-128")] - Aes128, - #[serde(rename = "aes-128-ccm-12")] - Aes128Ccm12, - #[serde(rename = "aes-128-ccm-16")] - Aes128Ccm16, - #[serde(rename = "aes-128-ccm-8")] - Aes128Ccm8, - #[serde(rename = "aes-128-ctr")] - Aes128Ctr, - #[serde(rename = "aes-128-gcm-12")] - Aes128Gcm12, - #[serde(rename = "aes-128-gcm-16")] - Aes128Gcm16, - #[serde(rename = "aes-128-gcm-8")] - Aes128Gcm8, - #[serde(rename = "aes-192")] - Aes192, - #[serde(rename = "aes-192-ccm-12")] - Aes192Ccm12, - #[serde(rename = "aes-192-ccm-16")] - Aes192Ccm16, - #[serde(rename = "aes-192-ccm-8")] - Aes192Ccm8, - #[serde(rename = "aes-192-ctr")] - Aes192Ctr, - #[serde(rename = "aes-192-gcm-12")] - Aes192Gcm12, - #[serde(rename = "aes-192-gcm-16")] - Aes192Gcm16, - #[serde(rename = "aes-192-gcm-8")] - Aes192Gcm8, - #[serde(rename = "aes-256")] - Aes256, - #[serde(rename = "aes-256-ccm-12")] - Aes256Ccm12, - #[serde(rename = "aes-256-ccm-16")] - Aes256Ccm16, - #[serde(rename = "aes-256-ccm-8")] - Aes256Ccm8, - #[serde(rename = "aes-256-ctr")] - Aes256Ctr, - #[serde(rename = "aes-256-gcm-12")] - Aes256Gcm12, - #[serde(rename = "aes-256-gcm-16")] - Aes256Gcm16, - #[serde(rename = "aes-256-gcm-8")] - Aes256Gcm8, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Pfs { - #[serde(rename = "group14")] - Group14, - #[serde(rename = "group15")] - Group15, - #[serde(rename = "group16")] - Group16, - #[serde(rename = "group17")] - Group17, - #[serde(rename = "group18")] - Group18, - #[serde(rename = "group19")] - Group19, - #[serde(rename = "group2")] - Group2, - #[serde(rename = "group20")] - Group20, - #[serde(rename = "group21")] - Group21, - #[serde(rename = "group22")] - Group22, - #[serde(rename = "group23")] - Group23, - #[serde(rename = "group24")] - Group24, - #[serde(rename = "group25")] - Group25, - #[serde(rename = "group26")] - Group26, - #[serde(rename = "group27")] - Group27, - #[serde(rename = "group28")] - Group28, - #[serde(rename = "group29")] - Group29, - #[serde(rename = "group30")] - Group30, - #[serde(rename = "group31")] - Group31, - #[serde(rename = "group5")] - Group5, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum TransformProtocol { - #[serde(rename = "ah")] - Ah, - #[serde(rename = "ah-esp")] - AhEsp, - #[serde(rename = "esp")] - Esp, -} - -/// An `ipsecpolicy` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Ipsecpolicy<'a> { - /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, - /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) auth_algorithm: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The encapsulation mode. A valid value is `tunnel` or `transport`. - /// Default is `tunnel`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) encapsulation_mode: Option, - - /// The encryption algorithm. A valid value is `3des`, `aes-128`, - /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. - /// Additional values for AES CCM and GCM modes are defined (e.g. - /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length - /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is - /// `aes-128`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) encryption_algorithm: Option, - - /// The lifetime of the security association. The lifetime consists of a - /// unit and integer value. You can omit either the unit or value portion - /// of the lifetime. Default unit is seconds and default value is 3600. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) lifetime: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, - /// `Group14` to `Group31`. Default is `Group5`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) pfs: Option, - - /// The transform protocol. A valid value is `ESP`, `AH`, or `AH- ESP`. - /// Default is `ESP`. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default)] - pub(crate) transform_protocol: Option, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `ipsecpolicy` object. - #[builder(setter(into))] - pub(crate) ipsecpolicy: Ipsecpolicy<'a>, - - /// id parameter for /v2.0/vpn/ipsecpolicies/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Ipsecpolicy. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("vpn/ipsecpolicies/{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("ipsecpolicy", serde_json::to_value(&self.ipsecpolicy)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("ipsecpolicy".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "ipsecpolicy" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "ipsecpolicy": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/vpnservice/create.rs b/openstack_sdk/src/api/network/v2/vpn/vpnservice/create.rs deleted file mode 100644 index 09d6ecfcc..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/vpnservice/create.rs +++ /dev/null @@ -1,263 +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`. - -//! Creates a VPN service. -//! -//! The service is associated with a router. After you create the service, it -//! can contain multiple VPN connections. -//! -//! An optional `flavor_id` attribute can be passed to enable dynamic selection -//! of an appropriate provider if configured by the operator. It is only -//! available when `vpn-flavors` extension is enabled. The basic selection -//! algorithm chooses the provider in the first service profile currently -//! associated with flavor. This option can only be set in `POST` operation. -//! -//! Normal response codes: 201 -//! -//! Error response codes: 400, 401 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `vpnservice` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Vpnservice<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// The ID of the flavor. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) flavor_id: Option>>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) router_id: Option>, - - /// If you specify only a subnet UUID, OpenStack Networking allocates an - /// available IP from that subnet to the port. If you specify both a subnet - /// UUID and an IP address, OpenStack Networking tries to allocate the - /// address to the port. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) subnet_id: Option>>, - - /// The ID of the project. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) tenant_id: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `vpnservice` object. - #[builder(setter(into))] - pub(crate) vpnservice: Vpnservice<'a>, - - #[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 Vpnservice. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/vpnservices".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("vpnservice", serde_json::to_value(&self.vpnservice)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("vpnservice".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "vpnservice" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/vpnservices".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservice": {} })); - }); - - let endpoint = Request::builder() - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/vpn/vpnservices".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservice": {} })); - }); - - let endpoint = Request::builder() - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/vpnservice/delete.rs b/openstack_sdk/src/api/network/v2/vpn/vpnservice/delete.rs deleted file mode 100644 index d8e818f15..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/vpnservice/delete.rs +++ /dev/null @@ -1,187 +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`. - -//! Removes a VPN service. -//! -//! If the service has connections, the request is rejected. -//! -//! Normal response codes: 204 -//! -//! Error response codes: 401, 404, 409 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/vpnservices/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Vpnservice. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/vpnservices/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/vpnservices/{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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/vpn/vpnservices/{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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/vpnservice/find.rs b/openstack_sdk/src/api/network/v2/vpn/vpnservice/find.rs deleted file mode 100644 index e9a04d896..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/vpnservice/find.rs +++ /dev/null @@ -1,115 +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`. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::Findable; -use openstack_sdk_core::api::rest_endpoint_prelude::*; -use openstack_sdk_core::api::{ApiError, RestClient}; -use tracing::trace; - -use crate::api::network::v2::vpn::vpnservice::{get as Get, list as List}; - -/// Find for vpn/vpnservice 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<'a> RequestBuilder<'a> { - /// Add a single header to the Volume. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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<'a>; - fn get_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - - fn list_ep(&self) -> Result, ApiError> { - 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().map_err(ApiError::endpoint_builder) - } - /// Locate vpn/vpnservice in a list - fn locate_resource_in_list( - &self, - data: Vec, - ) -> Result> { - // vpn/vpnservice 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") - && let Some(name) = name_as_val.as_str() - && 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/network/v2/vpn/vpnservice/get.rs b/openstack_sdk/src/api/network/v2/vpn/vpnservice/get.rs deleted file mode 100644 index f3db7ba55..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/vpnservice/get.rs +++ /dev/null @@ -1,195 +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`. - -//! Shows details for a VPN service. -//! -//! If the user is not an administrative user and the VPN service object does -//! not belong to the tenant account for the user, the operation returns the -//! `Forbidden (403)` response code. -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// id parameter for /v2.0/vpn/vpnservices/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Vpnservice. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("vpn/vpnservices/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("vpnservice".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "vpnservice" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/vpnservices/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservice": {} })); - }); - - 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/vpn/vpnservices/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservice": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/vpnservice/list.rs b/openstack_sdk/src/api/network/v2/vpn/vpnservice/list.rs deleted file mode 100644 index d316ec0a9..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/vpnservice/list.rs +++ /dev/null @@ -1,266 +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`. - -//! Lists all VPN services. -//! -//! The list might be empty. -//! -//! Standard query parameters are supported on the URI. For more information, -//! see [Filtering and Column Selection](#filtering). -//! -//! Use the `fields` query parameter to control which fields are returned in -//! the response body. For more information, see [Fields](#fields). -//! -//! Pagination query parameters are supported if Neutron configuration supports -//! it by overriding `allow_pagination=false`. For more information, see -//! [Pagination](#pagination). -//! -//! Sorting query parameters are supported if Neutron configuration supports it -//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). -//! -//! Normal response codes: 200 -//! -//! Error response codes: 401, 403 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// Requests a page size of items. Returns a number of items up to a limit - /// value. Use the limit parameter to make an initial limited request and - /// use the ID of the last-seen item from the response as the marker - /// parameter value in a subsequent limited request. - #[builder(default)] - limit: Option, - - /// The ID of the last-seen item. Use the limit parameter to make an - /// initial limited request and use the ID of the last-seen item from the - /// response as the marker parameter value in a subsequent limited request. - #[builder(default, setter(into))] - marker: Option>, - - /// Reverse the page direction - #[builder(default)] - page_reverse: Option, - - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - #[builder(default, private, setter(name = "_sort_dir"))] - sort_dir: Option>>, - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - #[builder(default, private, setter(name = "_sort_key"))] - sort_key: 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> { - /// Sort direction. This is an optional feature and may be silently ignored - /// by the server. - pub fn sort_dir(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_dir - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Sort results by the attribute. This is an optional feature and may be - /// silently ignored by the server. - pub fn sort_key(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.sort_key - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Vpnservice. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "vpn/vpnservices".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("page_reverse", self.page_reverse); - if let Some(val) = &self.sort_dir { - params.extend(val.iter().map(|value| ("sort_dir", value))); - } - if let Some(val) = &self.sort_key { - params.extend(val.iter().map(|value| ("sort_key", value))); - } - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("vpnservices".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(2, 0)) - } -} -impl Pageable for Request<'_> {} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "vpnservices" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/vpnservices".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservices": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/vpn/vpnservices".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservices": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/network/v2/vpn/vpnservice/set.rs b/openstack_sdk/src/api/network/v2/vpn/vpnservice/set.rs deleted file mode 100644 index 8061c5acc..000000000 --- a/openstack_sdk/src/api/network/v2/vpn/vpnservice/set.rs +++ /dev/null @@ -1,241 +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`. - -//! Updates a VPN service. -//! -//! Updates the attributes of a VPN service. You cannot update a service with a -//! `PENDING_*` status. -//! -//! Normal response codes: 200 -//! -//! Error response codes: 400, 401, 404 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -/// A `vpnservice` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Vpnservice<'a> { - /// The administrative state of the resource, which is up (`true`) or down - /// (`false`). - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) admin_state_up: Option, - - /// A human-readable description for the resource. Default is an empty - /// string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) description: Option>, - - /// Human-readable name of the resource. Default is an empty string. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A `vpnservice` object. - #[builder(setter(into))] - pub(crate) vpnservice: Vpnservice<'a>, - - /// id parameter for /v2.0/vpn/vpnservices/{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<'a> RequestBuilder<'a> { - /// Add a single header to the Vpnservice. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("vpn/vpnservices/{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("vpnservice", serde_json::to_value(&self.vpnservice)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Network - } - - fn response_key(&self) -> Option> { - Some("vpnservice".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(2, 0)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .build() - .unwrap() - .service_type(), - ServiceType::Network - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .build() - .unwrap() - .response_key() - .unwrap(), - "vpnservice" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/vpnservices/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservice": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/vpn/vpnservices/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "vpnservice": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .vpnservice(VpnserviceBuilder::default().build().unwrap()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store.rs b/openstack_sdk/src/api/object_store.rs index acdb7342e..8609cb0f0 100644 --- a/openstack_sdk/src/api/object_store.rs +++ b/openstack_sdk/src/api/object_store.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Object-Store API (Swift) bindings -pub mod v1; +//! # Object-Store API (Swift) bindings +pub use openstack_sdk_object_store::*; diff --git a/openstack_sdk/src/api/object_store/v1/account/delete.rs b/openstack_sdk/src/api/object_store/v1/account/delete.rs deleted file mode 100644 index 677b7f524..000000000 --- a/openstack_sdk/src/api/object_store/v1/account/delete.rs +++ /dev/null @@ -1,192 +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`. - -//! Deletes the specified account when a reseller admin issues this request. -//! Accounts are only deleted by (1) having a reseller admin level auth token -//! (2) sending a DELETE to a proxy server for the account to be deleted and -//! (3) that proxy server having the allow_account_management” config option -//! set to true. Note that an issuing a DELETE request simply marks the account -//! for deletion later as outlined in the link: -//! https://docs.openstack.org/swift/latest/overview_reaper.html. Take care -//! when performing this operation because deleting an account is a one-way -//! operation that is not trivially recoverable. It''s crucial to note that in -//! an OpenStack context, you should delete an account after the project/tenant -//! has been deleted from Keystone. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: 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 Account. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - self.account.as_ref().to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/{account}", account = "account",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().account("account").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/{account}", account = "account",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/account/get.rs b/openstack_sdk/src/api/object_store/v1/account/get.rs deleted file mode 100644 index 9ce070536..000000000 --- a/openstack_sdk/src/api/object_store/v1/account/get.rs +++ /dev/null @@ -1,240 +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`. - -//! Shows details for an account and lists containers, sorted by name, in the -//! account. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The delimiter is a single character used to split object names to - /// present a pseudo-directory hierarchy of objects. When combined with a - /// prefix query, this enables API users to simulate and traverse the - /// objects in a container as if they were in a directory tree. - #[builder(default, setter(into))] - delimiter: Option>, - - /// For a string value, x, constrains the list to items whose names are - /// less than x. - #[builder(default, setter(into))] - end_marker: Option>, - - /// The response format. Valid values are json, xml, or plain. The default - /// is plain. If you append the format=xml or format=json query parameter - /// to the storage account URL, the response shows extended container - /// information serialized in that format. If you append the format=plain - /// query parameter, the response lists the container names separated by - /// newlines. - #[builder(default, setter(into))] - format: Option>, - - /// For an integer value n, limits the number of results to n. - #[builder(default)] - limit: Option, - - /// For a string value, x, constrains the list to items whose names are - /// greater than x. - #[builder(default, setter(into))] - marker: Option>, - - /// Only objects with this prefix will be returned. When combined with a - /// delimiter query, this enables API users to simulate and traverse the - /// objects in a container as if they were in a directory tree. - #[builder(default, setter(into))] - prefix: Option>, - - /// By default, listings are returned sorted by name, ascending. If you - /// include the reverse=true query parameter, the listing will be returned - /// sorted by name, descending. - #[builder(default)] - reverse: 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> { - /// Add a single header to the Account. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - self.account.as_ref().to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("end_marker", self.end_marker.as_ref()); - params.push_opt("format", self.format.as_ref()); - params.push_opt("prefix", self.prefix.as_ref()); - params.push_opt("delimiter", self.delimiter.as_ref()); - params.push_opt("reverse", self.reverse); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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)) - } -} -impl Pageable for Request<'_> { - fn use_keyset_pagination(&self) -> bool { - false - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/{account}", account = "account",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().account("account").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/{account}", account = "account",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/account/head.rs b/openstack_sdk/src/api/object_store/v1/account/head.rs deleted file mode 100644 index 4ac193317..000000000 --- a/openstack_sdk/src/api/object_store/v1/account/head.rs +++ /dev/null @@ -1,181 +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`. - -//! Shows metadata for an account. Because the storage system can store large -//! amounts of data, take care when you represent the total bytes response as -//! an integer; when possible, convert it to a 64-bit unsigned integer if your -//! platform supports that primitive type. Do not include metadata headers in -//! this request. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: 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 Account. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - self.account.as_ref().to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/{account}", account = "account",)); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder().account("account").build().unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!("/{account}", account = "account",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .account("account") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/account/set.rs b/openstack_sdk/src/api/object_store/v1/account/set.rs deleted file mode 100644 index 0c0168844..000000000 --- a/openstack_sdk/src/api/object_store/v1/account/set.rs +++ /dev/null @@ -1,193 +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`. - -//! Creates, updates, or deletes account metadata. To create, update, or delete -//! custom metadata, use the X-Account-Meta-{name} request header, where {name} -//! is the name of the metadata item. Account metadata operations work -//! differently than how object metadata operations work. Depending on the -//! contents of your POST account metadata request, the Object Storage API -//! updates the metadata as shown in the following table: TODO: fill the rest -//! To delete a metadata header, send an empty value for that header, such as -//! for the X-Account-Meta-Book header. If the tool you use to communicate with -//! Object Storage, such as an older version of cURL, does not support empty -//! headers, send the X-Remove-Account- Meta-{name} header with an arbitrary -//! value. For example, X-Remove-Account-Meta-Book: x. The operation ignores -//! the arbitrary value. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: 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 Account. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - self.account.as_ref().to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/{account}", account = "account",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().account("account").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!("/{account}", account = "account",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/container/create.rs b/openstack_sdk/src/api/object_store/v1/container/create.rs deleted file mode 100644 index 3699cc468..000000000 --- a/openstack_sdk/src/api/object_store/v1/container/create.rs +++ /dev/null @@ -1,211 +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`. - -//! Creates a container. You do not need to check whether a container already -//! exists before issuing a PUT operation because the operation is idempotent: -//! It creates a container or updates an existing container, as appropriate. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: 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 Container. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "{account}/{container}", - account = self.account.as_ref(), - container = self.container.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/container/delete.rs b/openstack_sdk/src/api/object_store/v1/container/delete.rs deleted file mode 100644 index c69a2bacd..000000000 --- a/openstack_sdk/src/api/object_store/v1/container/delete.rs +++ /dev/null @@ -1,210 +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`. - -//! Deletes an empty container. This operation fails unless the container is -//! empty. An empty container has no objects. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: 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 Container. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "{account}/{container}", - account = self.account.as_ref(), - container = self.container.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/container/get.rs b/openstack_sdk/src/api/object_store/v1/container/get.rs deleted file mode 100644 index 49fd7ebb1..000000000 --- a/openstack_sdk/src/api/object_store/v1/container/get.rs +++ /dev/null @@ -1,271 +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`. - -//! Shows details for a container and lists objects, sorted by name, in the -//! container. Specify query parameters in the request to filter the list and -//! return a subset of objects. Omit query parameters to return a list of -//! objects that are stored in the container, up to 10,000 names. The 10,000 -//! maximum value is configurable. To view the value for the cluster, issue a -//! GET /info request. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -use openstack_sdk_core::api::Pageable; -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: Cow<'a, str>, - - /// The delimiter is a single character used to split object names to - /// present a pseudo-directory hierarchy of objects. When combined with a - /// prefix query, this enables API users to simulate and traverse the - /// objects in a container as if they were in a directory tree. - #[builder(default, setter(into))] - delimiter: Option>, - - /// For a string value, x, constrains the list to items whose names are - /// less than x. - #[builder(default, setter(into))] - end_marker: Option>, - - /// The response format. Valid values are json, xml, or plain. The default - /// is plain. If you append the format=xml or format=json query parameter - /// to the storage account URL, the response shows extended container - /// information serialized in that format. If you append the format=plain - /// query parameter, the response lists the container names separated by - /// newlines. - #[builder(default, setter(into))] - format: Option>, - - /// For an integer value n, limits the number of results to n. - #[builder(default)] - limit: Option, - - /// For a string value, x, constrains the list to items whose names are - /// greater than x. - #[builder(default, setter(into))] - marker: Option>, - - /// Only objects with this prefix will be returned. When combined with a - /// delimiter query, this enables API users to simulate and traverse the - /// objects in a container as if they were in a directory tree. - #[builder(default, setter(into))] - prefix: Option>, - - /// By default, listings are returned sorted by name, ascending. If you - /// include the reverse=true query parameter, the listing will be returned - /// sorted by name, descending. - #[builder(default)] - reverse: 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> { - /// Add a single header to the Container. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "{account}/{container}", - account = self.account.as_ref(), - container = self.container.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("limit", self.limit); - params.push_opt("marker", self.marker.as_ref()); - params.push_opt("end_marker", self.end_marker.as_ref()); - params.push_opt("format", self.format.as_ref()); - params.push_opt("prefix", self.prefix.as_ref()); - params.push_opt("delimiter", self.delimiter.as_ref()); - params.push_opt("reverse", self.reverse); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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)) - } -} -impl Pageable for Request<'_> { - fn use_keyset_pagination(&self) -> bool { - false - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/container/head.rs b/openstack_sdk/src/api/object_store/v1/container/head.rs deleted file mode 100644 index 3fbedce04..000000000 --- a/openstack_sdk/src/api/object_store/v1/container/head.rs +++ /dev/null @@ -1,205 +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`. - -//! Shows container metadata, including the number of objects and the total -//! bytes of all objects stored in the container. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: 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 Container. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "{account}/{container}", - account = self.account.as_ref(), - container = self.container.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/container/set.rs b/openstack_sdk/src/api/object_store/v1/container/set.rs deleted file mode 100644 index f8a75f2a8..000000000 --- a/openstack_sdk/src/api/object_store/v1/container/set.rs +++ /dev/null @@ -1,209 +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`. - -//! Creates, updates, or deletes custom metadata for a container. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: 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 Container. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "{account}/{container}", - account = self.account.as_ref(), - container = self.container.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/{account}/{container}", - account = "account", - container = "container", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/object/delete.rs b/openstack_sdk/src/api/object_store/v1/object/delete.rs deleted file mode 100644 index 0fc4419ab..000000000 --- a/openstack_sdk/src/api/object_store/v1/object/delete.rs +++ /dev/null @@ -1,237 +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`. - -//! Permanently deletes an object from the object store. Object deletion occurs -//! immediately at request time. Any subsequent GET, HEAD, POST, or DELETE -//! operations will return a 404 Not Found error code. For static large object -//! manifests, you can add the ?multipart- manifest=delete query parameter. -//! This operation deletes the segment objects and, if all deletions succeed, -//! this operation deletes the manifest object. A DELETE request made to a -//! symlink path will delete the symlink rather than the target object. An -//! alternative to using the DELETE operation is to use the POST operation with -//! the bulk-delete query parameter. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: Cow<'a, str>, - - /// If you include the multipart-manifest=get query parameter and the - /// object is a large object, the object contents are not returned. - /// Instead, the manifest is returned in the X-Object-Manifest response - /// header for dynamic large objects or in the response body for static - /// large objects. - #[builder(default, setter(into))] - multipart_manifest: Option>, - - /// The unique name for the object. - #[builder(default, setter(into))] - object: 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 Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "{account}/{container}/{object}", - account = self.account.as_ref(), - container = self.container.as_ref(), - object = self.object.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/object/get.rs b/openstack_sdk/src/api/object_store/v1/object/get.rs deleted file mode 100644 index 8ccab28b2..000000000 --- a/openstack_sdk/src/api/object_store/v1/object/get.rs +++ /dev/null @@ -1,266 +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`. - -//! Downloads the object content and gets the object metadata. This operation -//! returns the object metadata in the response headers and the object content -//! in the response body. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: Cow<'a, str>, - - /// Overrides the default file name. Object Storage generates a default - /// file name for GET temporary URLs that is based on the object name. - /// Object Storage returns this value in the Content-Disposition response - /// header. Browsers can interpret this file name value as a file - /// attachment to save. For more information about temporary URLs, see - /// Temporary URL middleware. - #[builder(default, setter(into))] - filename: Option>, - - /// If you include the multipart-manifest=get query parameter and the - /// object is a large object, the object contents are not returned. - /// Instead, the manifest is returned in the X-Object-Manifest response - /// header for dynamic large objects or in the response body for static - /// large objects. - #[builder(default, setter(into))] - multipart_manifest: Option>, - - /// The unique name for the object. - #[builder(default, setter(into))] - object: Cow<'a, str>, - - /// If you include the symlink=get query parameter and the object is a - /// symlink, then the response will include data and metadata from the - /// symlink itself rather than from the target. - #[builder(default, setter(into))] - symlink: Option>, - - /// The date and time in UNIX Epoch time stamp format or ISO 8601 UTC - /// timestamp when the signature for temporary URLs expires. For example, - /// 1440619048 or 2015-08-26T19:57:28Z is equivalent to Mon, Wed, 26 Aug - /// 2015 19:57:28 GMT. For more information about temporary URLs, see - /// Temporary URL middleware. - #[builder(default)] - temp_url_expires: Option, - - /// Used with temporary URLs to sign the request with an HMAC-SHA1 - /// cryptographic signature that defines the allowed HTTP method, - /// expiration date, full path to the object, and the secret key for the - /// temporary URL. For more information about temporary URLs, see Temporary - /// URL middleware. - #[builder(default, setter(into))] - temp_url_sig: 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> { - /// Add a single header to the Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "{account}/{container}/{object}", - account = self.account.as_ref(), - container = self.container.as_ref(), - object = self.object.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); - params.push_opt("temp_url_sig", self.temp_url_sig.as_ref()); - params.push_opt("temp_url_expires", self.temp_url_expires); - params.push_opt("filename", self.filename.as_ref()); - params.push_opt("symlink", self.symlink.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/object/head.rs b/openstack_sdk/src/api/object_store/v1/object/head.rs deleted file mode 100644 index e2d308e4b..000000000 --- a/openstack_sdk/src/api/object_store/v1/object/head.rs +++ /dev/null @@ -1,259 +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`. - -//! Shows object metadata. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: Cow<'a, str>, - - /// Overrides the default file name. Object Storage generates a default - /// file name for GET temporary URLs that is based on the object name. - /// Object Storage returns this value in the Content-Disposition response - /// header. Browsers can interpret this file name value as a file - /// attachment to save. For more information about temporary URLs, see - /// Temporary URL middleware. - #[builder(default, setter(into))] - filename: Option>, - - /// If you include the multipart-manifest=get query parameter and the - /// object is a large object, the object contents are not returned. - /// Instead, the manifest is returned in the X-Object-Manifest response - /// header for dynamic large objects or in the response body for static - /// large objects. - #[builder(default, setter(into))] - multipart_manifest: Option>, - - /// The unique name for the object. - #[builder(default, setter(into))] - object: Cow<'a, str>, - - /// If you include the symlink=get query parameter and the object is a - /// symlink, then the response will include data and metadata from the - /// symlink itself rather than from the target. - #[builder(default, setter(into))] - symlink: Option>, - - /// The date and time in UNIX Epoch time stamp format or ISO 8601 UTC - /// timestamp when the signature for temporary URLs expires. For example, - /// 1440619048 or 2015-08-26T19:57:28Z is equivalent to Mon, Wed, 26 Aug - /// 2015 19:57:28 GMT. For more information about temporary URLs, see - /// Temporary URL middleware. - #[builder(default)] - temp_url_expires: Option, - - /// Used with temporary URLs to sign the request with an HMAC-SHA1 - /// cryptographic signature that defines the allowed HTTP method, - /// expiration date, full path to the object, and the secret key for the - /// temporary URL. For more information about temporary URLs, see Temporary - /// URL middleware. - #[builder(default, setter(into))] - temp_url_sig: 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> { - /// Add a single header to the Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::HEAD - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "{account}/{container}/{object}", - account = self.account.as_ref(), - container = self.container.as_ref(), - object = self.object.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); - params.push_opt("temp_url_sig", self.temp_url_sig.as_ref()); - params.push_opt("temp_url_expires", self.temp_url_expires); - params.push_opt("filename", self.filename.as_ref()); - params.push_opt("symlink", self.symlink.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::RawQuery; - use openstack_sdk_core::types::ServiceType; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD).path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )); - - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::HEAD) - .path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200).header("content-type", "application/json"); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _ = endpoint.raw_query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/object_store/v1/object/set.rs b/openstack_sdk/src/api/object_store/v1/object/set.rs deleted file mode 100644 index a5738075f..000000000 --- a/openstack_sdk/src/api/object_store/v1/object/set.rs +++ /dev/null @@ -1,278 +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`. - -//! Creates or updates object metadata. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The unique name for the account. An account is also known as the - /// project or tenant. - #[builder(default, setter(into))] - account: Cow<'a, str>, - - /// When the bulk-delete query parameter is present in the POST request, - /// multiple objects or containers can be deleted with a single request. - /// See Bulk Delete for how this feature is used. - #[builder(default)] - bulk_delete: Option, - - /// The unique (within an account) name for the container. The container - /// name must be from 1 to 256 characters long and can start with any - /// character and contain any pattern. Character set must be UTF-8. The - /// container name cannot contain a slash (/) character because this - /// character delimits the container and object name. For example, the path - /// /v1/account/www/pages specifies the www container, not the www/pages - /// container. - #[builder(default, setter(into))] - container: Cow<'a, str>, - - /// When the extract-archive query parameter is present in the POST - /// request, an archive (tar file) is uploaded and extracted to create - /// multiple objects. See Extract Archive for how this feature is used. - #[builder(default)] - extract_archive: Option, - - /// Overrides the default file name. Object Storage generates a default - /// file name for GET temporary URLs that is based on the object name. - /// Object Storage returns this value in the Content-Disposition response - /// header. Browsers can interpret this file name value as a file - /// attachment to save. For more information about temporary URLs, see - /// Temporary URL middleware. - #[builder(default, setter(into))] - filename: Option>, - - /// If you include the multipart-manifest=get query parameter and the - /// object is a large object, the object contents are not returned. - /// Instead, the manifest is returned in the X-Object-Manifest response - /// header for dynamic large objects or in the response body for static - /// large objects. - #[builder(default, setter(into))] - multipart_manifest: Option>, - - /// The unique name for the object. - #[builder(default, setter(into))] - object: Cow<'a, str>, - - /// If you include the symlink=get query parameter and the object is a - /// symlink, then the response will include data and metadata from the - /// symlink itself rather than from the target. - #[builder(default, setter(into))] - symlink: Option>, - - /// The date and time in UNIX Epoch time stamp format or ISO 8601 UTC - /// timestamp when the signature for temporary URLs expires. For example, - /// 1440619048 or 2015-08-26T19:57:28Z is equivalent to Mon, Wed, 26 Aug - /// 2015 19:57:28 GMT. For more information about temporary URLs, see - /// Temporary URL middleware. - #[builder(default)] - temp_url_expires: Option, - - /// Used with temporary URLs to sign the request with an HMAC-SHA1 - /// cryptographic signature that defines the allowed HTTP method, - /// expiration date, full path to the object, and the secret key for the - /// temporary URL. For more information about temporary URLs, see Temporary - /// URL middleware. - #[builder(default, setter(into))] - temp_url_sig: 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> { - /// Add a single header to the Object. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "{account}/{container}/{object}", - account = self.account.as_ref(), - container = self.container.as_ref(), - object = self.object.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); - params.push_opt("temp_url_sig", self.temp_url_sig.as_ref()); - params.push_opt("temp_url_expires", self.temp_url_expires); - params.push_opt("filename", self.filename.as_ref()); - params.push_opt("symlink", self.symlink.as_ref()); - params.push_opt("bulk-delete", self.bulk_delete); - params.push_opt("extract-archive", self.extract_archive); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::ObjectStore - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::ObjectStore - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/{account}/{container}/{object}", - account = "account", - container = "container", - object = "object", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .account("account") - .container("container") - .object("object") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement.rs b/openstack_sdk/src/api/placement.rs index 2378bb4d0..2718efa9a 100644 --- a/openstack_sdk/src/api/placement.rs +++ b/openstack_sdk/src/api/placement.rs @@ -12,5 +12,5 @@ // // SPDX-License-Identifier: Apache-2.0 -//! Placement bindings -pub mod v1; +//! # Placement bindings +pub use openstack_sdk_placement::*; diff --git a/openstack_sdk/src/api/placement/v1/allocation/create_134.rs b/openstack_sdk/src/api/placement/v1/allocation/create_134.rs deleted file mode 100644 index 7fc572c6d..000000000 --- a/openstack_sdk/src/api/placement/v1/allocation/create_134.rs +++ /dev/null @@ -1,295 +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`. - -//! Create, update or delete allocations for multiple consumers in a single -//! request. This allows a client to atomically set or swap allocations for -//! multiple consumers as may be required during a migration or move type -//! operation. -//! -//! The allocations for an individual consumer uuid mentioned in the request -//! can be removed by setting the allocations to an empty object (see the -//! example below). -//! -//! **Available as of microversion 1.13.** -//! -//! Normal response codes: 204 -//! -//! Error response codes: badRequest(400), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationsItem<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) generation: Option, - - #[serde()] - #[builder(private, setter(into, name = "_resources"))] - pub(crate) resources: BTreeMap, i32>, -} - -impl<'a> AllocationsItemBuilder<'a> { - pub fn resources(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.resources - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Item<'a> { - #[serde()] - #[builder(private, setter(into, name = "_allocations"))] - pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) consumer_generation: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_mappings"))] - pub(crate) mappings: Option, Vec>>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) project_id: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) user_id: Cow<'a, str>, -} - -impl<'a> ItemBuilder<'a> { - pub fn allocations(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.allocations - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - pub fn mappings(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: IntoIterator, - V1: Into>, - { - self.mappings - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Item<'a>>, -} -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 Allocation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "allocations".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - 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, 34)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/allocations".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/allocations".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/allocation/create_138.rs b/openstack_sdk/src/api/placement/v1/allocation/create_138.rs deleted file mode 100644 index 62d4ca2b6..000000000 --- a/openstack_sdk/src/api/placement/v1/allocation/create_138.rs +++ /dev/null @@ -1,299 +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`. - -//! Create, update or delete allocations for multiple consumers in a single -//! request. This allows a client to atomically set or swap allocations for -//! multiple consumers as may be required during a migration or move type -//! operation. -//! -//! The allocations for an individual consumer uuid mentioned in the request -//! can be removed by setting the allocations to an empty object (see the -//! example below). -//! -//! **Available as of microversion 1.13.** -//! -//! Normal response codes: 204 -//! -//! Error response codes: badRequest(400), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationsItem<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) generation: Option, - - #[serde()] - #[builder(private, setter(into, name = "_resources"))] - pub(crate) resources: BTreeMap, i32>, -} - -impl<'a> AllocationsItemBuilder<'a> { - pub fn resources(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.resources - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Item<'a> { - #[serde()] - #[builder(private, setter(into, name = "_allocations"))] - pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) consumer_generation: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) consumer_type: Cow<'a, str>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_mappings"))] - pub(crate) mappings: Option, Vec>>>, - - #[serde()] - #[builder(setter(into))] - pub(crate) project_id: Cow<'a, str>, - - #[serde()] - #[builder(setter(into))] - pub(crate) user_id: Cow<'a, str>, -} - -impl<'a> ItemBuilder<'a> { - pub fn allocations(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.allocations - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - pub fn mappings(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: IntoIterator, - V1: Into>, - { - self.mappings - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, - - #[builder(setter(name = "_properties"), default, private)] - _properties: BTreeMap, Item<'a>>, -} -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 Allocation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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 - } - - pub fn properties(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self._properties - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::POST - } - - fn endpoint(&self) -> Cow<'static, str> { - "allocations".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - for (key, val) in &self._properties { - params.push(key.clone(), serde_json::to_value(val)?); - } - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - 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, 38)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/allocations".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/allocations".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/allocation/delete.rs b/openstack_sdk/src/api/placement/v1/allocation/delete.rs deleted file mode 100644 index ead9efc6f..000000000 --- a/openstack_sdk/src/api/placement/v1/allocation/delete.rs +++ /dev/null @@ -1,193 +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`. - -//! Delete all allocation records for the consumer identified by -//! {consumer_uuid} on all resource providers it is consuming. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// consumer_uuid parameter for /allocations/{consumer_uuid} API - #[builder(default, setter(into))] - consumer_uuid: 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 Allocation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "allocations/{consumer_uuid}", - consumer_uuid = self.consumer_uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/allocations/{consumer_uuid}", - consumer_uuid = "consumer_uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consumer_uuid("consumer_uuid") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/allocations/{consumer_uuid}", - consumer_uuid = "consumer_uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consumer_uuid("consumer_uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/allocation/get.rs b/openstack_sdk/src/api/placement/v1/allocation/get.rs deleted file mode 100644 index e4200b4a6..000000000 --- a/openstack_sdk/src/api/placement/v1/allocation/get.rs +++ /dev/null @@ -1,191 +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`. - -//! List all allocation records for the consumer identified by {consumer_uuid} -//! on all the resource providers it is consuming. -//! -//! Normal Response Codes: 200 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// consumer_uuid parameter for /allocations/{consumer_uuid} API - #[builder(default, setter(into))] - consumer_uuid: 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 Allocation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "allocations/{consumer_uuid}", - consumer_uuid = self.consumer_uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/allocations/{consumer_uuid}", - consumer_uuid = "consumer_uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consumer_uuid("consumer_uuid") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/allocations/{consumer_uuid}", - consumer_uuid = "consumer_uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consumer_uuid("consumer_uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/allocation/set_10.rs b/openstack_sdk/src/api/placement/v1/allocation/set_10.rs deleted file mode 100644 index 0bd2245c9..000000000 --- a/openstack_sdk/src/api/placement/v1/allocation/set_10.rs +++ /dev/null @@ -1,297 +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`. - -//! Create or update one or more allocation records representing the -//! consumption of one or more classes of resources from one or more resource -//! providers by the consumer identified by {consumer_uuid}. If allocations -//! already exist for this consumer, they are replaced. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct ResourceProvider<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) uuid: Cow<'a, str>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct Allocations<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) resource_provider: ResourceProvider<'a>, - - #[serde()] - #[builder(private, setter(into, name = "_resources"))] - pub(crate) resources: BTreeMap, i32>, -} - -impl<'a> AllocationsBuilder<'a> { - pub fn resources(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.resources - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - #[builder(setter(into))] - pub(crate) allocations: Vec>, - - /// consumer_uuid parameter for /allocations/{consumer_uuid} API - #[builder(default, setter(into))] - consumer_uuid: 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 Allocation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "allocations/{consumer_uuid}", - consumer_uuid = self.consumer_uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("allocations", serde_json::to_value(&self.allocations)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .allocations(Vec::from([AllocationsBuilder::default() - .resource_provider( - ResourceProviderBuilder::default() - .uuid("foo") - .build() - .unwrap() - ) - .resources(BTreeMap::::new().into_iter()) - .build() - .unwrap()])) - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .allocations(Vec::from([AllocationsBuilder::default() - .resource_provider( - ResourceProviderBuilder::default() - .uuid("foo") - .build() - .unwrap() - ) - .resources(BTreeMap::::new().into_iter()) - .build() - .unwrap()])) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/allocations/{consumer_uuid}", - consumer_uuid = "consumer_uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consumer_uuid("consumer_uuid") - .allocations(Vec::from([AllocationsBuilder::default() - .resource_provider( - ResourceProviderBuilder::default() - .uuid("foo") - .build() - .unwrap(), - ) - .resources(BTreeMap::::new().into_iter()) - .build() - .unwrap()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/allocations/{consumer_uuid}", - consumer_uuid = "consumer_uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .consumer_uuid("consumer_uuid") - .allocations(Vec::from([AllocationsBuilder::default() - .resource_provider( - ResourceProviderBuilder::default() - .uuid("foo") - .build() - .unwrap(), - ) - .resources(BTreeMap::::new().into_iter()) - .build() - .unwrap()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/allocation_candidate/list.rs b/openstack_sdk/src/api/placement/v1/allocation_candidate/list.rs deleted file mode 100644 index 282e870de..000000000 --- a/openstack_sdk/src/api/placement/v1/allocation_candidate/list.rs +++ /dev/null @@ -1,384 +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`. - -//! Returns a dictionary representing a collection of allocation requests and -//! resource provider summaries. Each allocation request has information to -//! form a `PUT /allocations/{consumer_uuid}` request to claim resources -//! against a related set of resource providers. Additional parameters might be -//! required, see [Update allocations](#update-allocations). As several -//! allocation requests are available it’s necessary to select one. To make a -//! decision, resource provider summaries are provided with the -//! inventory/capacity information. For example, this information is used by -//! nova-scheduler’s FilterScheduler to make decisions about on which compute -//! host to build a server. -//! -//! You can also find additional case studies of the request parameters in the -//! [Modeling with Provider Trees](https://docs.openstack.org/placement/latest/usage/provider-tree.html) -//! document. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: badRequest(400) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// When more than one resourcesN query parameter is supplied, group_policy - /// is required to indicate how the groups should interact. With - /// group_policy=none, separate groupings - with or without a suffix - may - /// or may not be satisfied by the same provider. With - /// group_policy=isolate, suffixed groups are guaranteed to be satisfied by - /// different providers - though there may still be overlap with the - /// suffixless group. - #[builder(default, setter(into))] - group_policy: Option>, - - /// A string representing a resource provider uuid. When supplied, it will - /// filter the returned allocation candidates to only those resource - /// providers that are in the same tree with the given resource provider. - #[builder(default, setter(into))] - in_tree: Option>, - - /// A positive integer used to limit the maximum number of allocation - /// candidates returned in the response. - #[builder(default)] - limit: Option, - - /// A string representing an aggregate uuid; or the prefix in: followed by - /// a comma-separated list of strings representing aggregate uuids. The - /// resource providers in the allocation request in the response must - /// directly or via the root provider be associated with the aggregate or - /// aggregates identified by uuid: - /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, - /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` - /// Starting from microversion 1.24 specifying multiple member_of query - /// string parameters is possible. Multiple member_of parameters will - /// result in filtering providers that are directly or via root provider - /// associated with aggregates listed in all of the member_of query string - /// values. For example, to get the providers that are associated with - /// aggregate A as well as associated with any of aggregates B or C, the - /// user could issue the following query: - /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from - /// microversion 1.32 specifying forbidden aggregates is supported in the - /// member_of query string parameter. Forbidden aggregates are prefixed - /// with a !. This negative expression can also be used in multiple - /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would - /// translate logically to “Candidate resource providers must be in AGGA - /// and not in AGGB.” We do NOT support ! on the values within in:, but we - /// support !in:. Both of the following two example queries return - /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: - /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, - /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do - /// not check if the same aggregate uuid is in both positive and negative - /// expression to return 400 BadRequest. We still return 200 for such - /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would - /// return empty allocation_requests and provider_summaries, while: - /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return - /// resource providers that are NOT in AGGA but in AGGB. - #[builder(default, private, setter(name = "_member_of"))] - member_of: Option>>, - - /// A comma-separated list of traits that a provider must have: - /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the - /// response will be for resource providers that have capacity for all - /// requested resources and the set of those resource providers will - /// collectively contain all of the required traits. These traits may be - /// satisfied by any provider in the same non-sharing tree or associated - /// via aggregate as far as that provider also contributes resource to the - /// request. Starting from microversion 1.22 traits which are forbidden - /// from any resource provider contributing resources to the request may be - /// expressed by prefixing a trait with a `!`. Starting from microversion - /// 1.39 the required query parameter can be repeated. The trait lists from - /// the repeated parameters are AND-ed together. So: - /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting - /// from microversion 1.39 the required parameter supports the syntax: - /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden - /// traits into an in: prefixed value is not supported and rejected. But - /// mixing a normal trait list and an in: prefixed trait list in two query - /// params within the same request is supported. So: - /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and - /// not T2 and (T3 or T4). - #[builder(default, private, setter(name = "_required"))] - required: Option>>, - - /// A comma-separated list of strings indicating an amount of resource of a - /// specified class that providers in each allocation request must - /// collectively have the capacity and availability to serve: - /// `resources=VCPU:4,DISK_GB:64,MEMORY_MB:2048` These resources may be - /// satisfied by any provider in the same non-sharing tree or associated - /// via aggregate. - #[builder(default, setter(into))] - resources: Option>, - - /// A comma-separated list of trait requirements that the root provider of - /// the (non-sharing) tree must satisfy: - /// `root_required=COMPUTE_SUPPORTS_MULTI_ATTACH,!CUSTOM_WINDOWS_LICENSED` - /// Allocation requests in the response will be limited to those whose - /// (non-sharing) tree’s root provider satisfies the specified trait - /// requirements. Traits which are forbidden (must not be present on the - /// root provider) are expressed by prefixing the trait with a !. - #[builder(default, setter(into))] - root_required: Option>, - - /// A comma-separated list of request group suffix strings ($S). Each must - /// exactly match a suffix on a granular group somewhere else in the - /// request. Importantly, the identified request groups need not have a - /// resources[$S]. If this is provided, at least one of the resource - /// providers satisfying a specified request group must be an ancestor of - /// the rest. The same_subtree query parameter can be repeated and each - /// repeat group is treated independently. - #[builder(default, setter(into))] - same_subtree: 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> { - /// A string representing an aggregate uuid; or the prefix in: followed by - /// a comma-separated list of strings representing aggregate uuids. The - /// resource providers in the allocation request in the response must - /// directly or via the root provider be associated with the aggregate or - /// aggregates identified by uuid: - /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, - /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` - /// Starting from microversion 1.24 specifying multiple member_of query - /// string parameters is possible. Multiple member_of parameters will - /// result in filtering providers that are directly or via root provider - /// associated with aggregates listed in all of the member_of query string - /// values. For example, to get the providers that are associated with - /// aggregate A as well as associated with any of aggregates B or C, the - /// user could issue the following query: - /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from - /// microversion 1.32 specifying forbidden aggregates is supported in the - /// member_of query string parameter. Forbidden aggregates are prefixed - /// with a !. This negative expression can also be used in multiple - /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would - /// translate logically to “Candidate resource providers must be in AGGA - /// and not in AGGB.” We do NOT support ! on the values within in:, but we - /// support !in:. Both of the following two example queries return - /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: - /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, - /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do - /// not check if the same aggregate uuid is in both positive and negative - /// expression to return 400 BadRequest. We still return 200 for such - /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would - /// return empty allocation_requests and provider_summaries, while: - /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return - /// resource providers that are NOT in AGGA but in AGGB. - pub fn member_of(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.member_of - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// A comma-separated list of traits that a provider must have: - /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the - /// response will be for resource providers that have capacity for all - /// requested resources and the set of those resource providers will - /// collectively contain all of the required traits. These traits may be - /// satisfied by any provider in the same non-sharing tree or associated - /// via aggregate as far as that provider also contributes resource to the - /// request. Starting from microversion 1.22 traits which are forbidden - /// from any resource provider contributing resources to the request may be - /// expressed by prefixing a trait with a `!`. Starting from microversion - /// 1.39 the required query parameter can be repeated. The trait lists from - /// the repeated parameters are AND-ed together. So: - /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting - /// from microversion 1.39 the required parameter supports the syntax: - /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden - /// traits into an in: prefixed value is not supported and rejected. But - /// mixing a normal trait list and an in: prefixed trait list in two query - /// params within the same request is supported. So: - /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and - /// not T2 and (T3 or T4). - pub fn required(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.required - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Allocation_Candidate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "allocation_candidates".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("group_policy", self.group_policy.as_ref()); - params.push_opt("in_tree", self.in_tree.as_ref()); - params.push_opt("limit", self.limit); - if let Some(val) = &self.member_of { - params.extend(val.iter().map(|value| ("member_of", value))); - } - if let Some(val) = &self.required { - params.extend(val.iter().map(|value| ("required", value))); - } - params.push_opt("resources", self.resources.as_ref()); - params.push_opt("root_required", self.root_required.as_ref()); - params.push_opt("same_subtree", self.same_subtree.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/allocation_candidates".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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/allocation_candidates".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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/reshaper/create_134.rs b/openstack_sdk/src/api/placement/v1/reshaper/create_134.rs deleted file mode 100644 index 0e56ee90b..000000000 --- a/openstack_sdk/src/api/placement/v1/reshaper/create_134.rs +++ /dev/null @@ -1,428 +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`. - -//! Atomically migrate resource provider inventories and associated -//! allocations. This is used when some of the inventory needs to move from one -//! resource provider to another, such as when a class of inventory moves from -//! a parent provider to a new child provider. -//! -//! Normal Response Codes: 204 -//! -//! Error Response Codes: badRequest(400), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationsItem<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) generation: Option, - - /// A dictionary of resource records keyed by resource class name. - #[serde()] - #[builder(private, setter(into, name = "_resources"))] - pub(crate) resources: BTreeMap, i32>, -} - -impl<'a> AllocationsItemBuilder<'a> { - /// A dictionary of resource records keyed by resource class name. - pub fn resources(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.resources - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationsItemStruct<'a> { - /// A dictionary of resource allocations keyed by resource provider uuid. - /// If this is an empty object, allocations for this consumer will be - /// removed. - #[serde()] - #[builder(private, setter(into, name = "_allocations"))] - pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, - - /// The generation of the consumer. Should be set to null when indicating - /// that the caller expects the consumer does not yet exist. - #[serde()] - #[builder(setter(into))] - pub(crate) consumer_generation: Option, - - /// A dictionary associating request group suffixes with a list of uuids - /// identifying the resource providers that satisfied each group. The empty - /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent - /// when writing allocations back to the server but will be ignored; this - /// preserves symmetry between read and write representations. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_mappings"))] - pub(crate) mappings: Option, Vec>>>, - - /// The uuid of a project. - #[serde()] - #[builder(setter(into))] - pub(crate) project_id: Cow<'a, str>, - - /// The uuid of a user. - #[serde()] - #[builder(setter(into))] - pub(crate) user_id: Cow<'a, str>, -} - -impl<'a> AllocationsItemStructBuilder<'a> { - /// A dictionary of resource allocations keyed by resource provider uuid. - /// If this is an empty object, allocations for this consumer will be - /// removed. - pub fn allocations(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.allocations - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// A dictionary associating request group suffixes with a list of uuids - /// identifying the resource providers that satisfied each group. The empty - /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent - /// when writing allocations back to the server but will be ignored; this - /// preserves symmetry between read and write representations. - pub fn mappings(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: IntoIterator, - V1: Into>, - { - self.mappings - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); - self - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InventoriesItem { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allocation_ratio: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_unit: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_unit: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) reserved: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) resource_provider_generation: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) step_size: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) total: i32, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InventoriesItemStruct<'a> { - /// A dictionary of inventories keyed by resource classes. - #[serde()] - #[builder(private, setter(into, name = "_inventories"))] - pub(crate) inventories: BTreeMap, InventoriesItem>, - - /// A consistent view marker that assists with the management of concurrent - /// resource provider updates. - #[serde()] - #[builder(setter(into))] - pub(crate) resource_provider_generation: i32, -} - -impl<'a> InventoriesItemStructBuilder<'a> { - /// A dictionary of inventories keyed by resource classes. - pub fn inventories(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.inventories - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary of multiple allocations, keyed by consumer uuid. Each - /// collection of allocations describes the full set of allocations for - /// each consumer. Each consumer allocations dict is itself a dictionary of - /// resource allocations keyed by resource provider uuid. An empty - /// dictionary indicates no change in existing allocations, whereas an - /// empty `allocations` dictionary **within** a consumer dictionary - /// indicates that all allocations for that consumer should be deleted. - #[builder(private, setter(into, name = "_allocations"))] - pub(crate) allocations: BTreeMap, AllocationsItemStruct<'a>>, - - /// A dictionary of multiple inventories, keyed by resource provider uuid. - /// Each inventory describes the desired full inventory for each resource - /// provider. An empty dictionary causes the inventory for that provider to - /// be deleted. - #[builder(private, setter(into, name = "_inventories"))] - pub(crate) inventories: BTreeMap, InventoriesItemStruct<'a>>, - - #[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> { - /// A dictionary of multiple allocations, keyed by consumer uuid. Each - /// collection of allocations describes the full set of allocations for - /// each consumer. Each consumer allocations dict is itself a dictionary of - /// resource allocations keyed by resource provider uuid. An empty - /// dictionary indicates no change in existing allocations, whereas an - /// empty `allocations` dictionary **within** a consumer dictionary - /// indicates that all allocations for that consumer should be deleted. - pub fn allocations(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.allocations - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// A dictionary of multiple inventories, keyed by resource provider uuid. - /// Each inventory describes the desired full inventory for each resource - /// provider. An empty dictionary causes the inventory for that provider to - /// be deleted. - pub fn inventories(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.inventories - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Reshaper. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "reshaper".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("allocations", serde_json::to_value(&self.allocations)?); - params.push("inventories", serde_json::to_value(&self.inventories)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - 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, 34)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/reshaper".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/reshaper".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() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/reshaper/create_138.rs b/openstack_sdk/src/api/placement/v1/reshaper/create_138.rs deleted file mode 100644 index d5f1ec818..000000000 --- a/openstack_sdk/src/api/placement/v1/reshaper/create_138.rs +++ /dev/null @@ -1,438 +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`. - -//! Atomically migrate resource provider inventories and associated -//! allocations. This is used when some of the inventory needs to move from one -//! resource provider to another, such as when a class of inventory moves from -//! a parent provider to a new child provider. -//! -//! Normal Response Codes: 204 -//! -//! Error Response Codes: badRequest(400), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationsItem<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) generation: Option, - - /// A dictionary of resource records keyed by resource class name. - #[serde()] - #[builder(private, setter(into, name = "_resources"))] - pub(crate) resources: BTreeMap, i32>, -} - -impl<'a> AllocationsItemBuilder<'a> { - /// A dictionary of resource records keyed by resource class name. - pub fn resources(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.resources - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct AllocationsItemStruct<'a> { - /// A dictionary of resource allocations keyed by resource provider uuid. - /// If this is an empty object, allocations for this consumer will be - /// removed. - #[serde()] - #[builder(private, setter(into, name = "_allocations"))] - pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, - - /// The generation of the consumer. Should be set to null when indicating - /// that the caller expects the consumer does not yet exist. - #[serde()] - #[builder(setter(into))] - pub(crate) consumer_generation: Option, - - /// A string that consists of numbers, A-Z, and _ describing what kind of - /// consumer is creating, or has created, allocations using a quantity of - /// inventory. The string is determined by the client when writing - /// allocations and it is up to the client to ensure correct choices - /// amongst collaborating services. For example, the compute service may - /// choose to type some consumers ‘INSTANCE’ and others ‘MIGRATION’. - #[serde()] - #[builder(setter(into))] - pub(crate) consumer_type: Cow<'a, str>, - - /// A dictionary associating request group suffixes with a list of uuids - /// identifying the resource providers that satisfied each group. The empty - /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent - /// when writing allocations back to the server but will be ignored; this - /// preserves symmetry between read and write representations. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, private, setter(into, name = "_mappings"))] - pub(crate) mappings: Option, Vec>>>, - - /// The uuid of a project. - #[serde()] - #[builder(setter(into))] - pub(crate) project_id: Cow<'a, str>, - - /// The uuid of a user. - #[serde()] - #[builder(setter(into))] - pub(crate) user_id: Cow<'a, str>, -} - -impl<'a> AllocationsItemStructBuilder<'a> { - /// A dictionary of resource allocations keyed by resource provider uuid. - /// If this is an empty object, allocations for this consumer will be - /// removed. - pub fn allocations(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.allocations - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// A dictionary associating request group suffixes with a list of uuids - /// identifying the resource providers that satisfied each group. The empty - /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent - /// when writing allocations back to the server but will be ignored; this - /// preserves symmetry between read and write representations. - pub fn mappings(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: IntoIterator, - V1: Into>, - { - self.mappings - .get_or_insert(None) - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); - self - } -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InventoriesItem { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allocation_ratio: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_unit: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_unit: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) reserved: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) resource_provider_generation: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) step_size: Option, - - #[serde()] - #[builder(setter(into))] - pub(crate) total: i32, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InventoriesItemStruct<'a> { - /// A dictionary of inventories keyed by resource classes. - #[serde()] - #[builder(private, setter(into, name = "_inventories"))] - pub(crate) inventories: BTreeMap, InventoriesItem>, - - /// A consistent view marker that assists with the management of concurrent - /// resource provider updates. - #[serde()] - #[builder(setter(into))] - pub(crate) resource_provider_generation: i32, -} - -impl<'a> InventoriesItemStructBuilder<'a> { - /// A dictionary of inventories keyed by resource classes. - pub fn inventories(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.inventories - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary of multiple allocations, keyed by consumer uuid. Each - /// collection of allocations describes the full set of allocations for - /// each consumer. Each consumer allocations dict is itself a dictionary of - /// resource allocations keyed by resource provider uuid. An empty - /// dictionary indicates no change in existing allocations, whereas an - /// empty `allocations` dictionary **within** a consumer dictionary - /// indicates that all allocations for that consumer should be deleted. - #[builder(private, setter(into, name = "_allocations"))] - pub(crate) allocations: BTreeMap, AllocationsItemStruct<'a>>, - - /// A dictionary of multiple inventories, keyed by resource provider uuid. - /// Each inventory describes the desired full inventory for each resource - /// provider. An empty dictionary causes the inventory for that provider to - /// be deleted. - #[builder(private, setter(into, name = "_inventories"))] - pub(crate) inventories: BTreeMap, InventoriesItemStruct<'a>>, - - #[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> { - /// A dictionary of multiple allocations, keyed by consumer uuid. Each - /// collection of allocations describes the full set of allocations for - /// each consumer. Each consumer allocations dict is itself a dictionary of - /// resource allocations keyed by resource provider uuid. An empty - /// dictionary indicates no change in existing allocations, whereas an - /// empty `allocations` dictionary **within** a consumer dictionary - /// indicates that all allocations for that consumer should be deleted. - pub fn allocations(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.allocations - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// A dictionary of multiple inventories, keyed by resource provider uuid. - /// Each inventory describes the desired full inventory for each resource - /// provider. An empty dictionary causes the inventory for that provider to - /// be deleted. - pub fn inventories(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into>, - { - self.inventories - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Reshaper. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "reshaper".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("allocations", serde_json::to_value(&self.allocations)?); - params.push("inventories", serde_json::to_value(&self.inventories)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - 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, 38)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/reshaper".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/reshaper".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() - .allocations(BTreeMap::>::new().into_iter()) - .inventories(BTreeMap::>::new().into_iter()) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_class/create.rs b/openstack_sdk/src/api/placement/v1/resource_class/create.rs deleted file mode 100644 index dfbbf288f..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_class/create.rs +++ /dev/null @@ -1,207 +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`. - -//! Create a new resource class. The new class must be a *custom* resource -//! class, prefixed with CUSTOM\_ and distinct from the standard resource -//! classes. -//! -//! Normal Response Codes: 201 -//! -//! Error response codes: badRequest(400), conflict(409) -//! -//! A 400 BadRequest response code will be returned if the resource class does -//! not have prefix CUSTOM\_. -//! -//! A 409 Conflict response code will be returned if another resource class -//! exists with the provided name. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The name of one resource class. - #[builder(setter(into))] - pub(crate) name: 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 Resource_Class. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "resource_classes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("name", serde_json::to_value(&self.name)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/resource_classes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().name("foo").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/resource_classes".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() - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_class/delete.rs b/openstack_sdk/src/api/placement/v1/resource_class/delete.rs deleted file mode 100644 index d5c1b88c2..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_class/delete.rs +++ /dev/null @@ -1,186 +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`. - -//! Delete the resource class identified by {name}. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) -//! -//! A 400 BadRequest response code will be returned if trying to delete a -//! standard resource class. -//! -//! A 409 Conflict response code will be returned if there exist inventories -//! for the resource class. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// name parameter for /resource_classes/{name} API - #[builder(default, setter(into))] - name: 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 Resource_Class. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("resource_classes/{name}", name = self.name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/resource_classes/{name}", name = "name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().name("name").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/resource_classes/{name}", name = "name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_class/get.rs b/openstack_sdk/src/api/placement/v1/resource_class/get.rs deleted file mode 100644 index c4044c89a..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_class/get.rs +++ /dev/null @@ -1,180 +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`. - -//! Return a representation of the resource class identified by {name}. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// name parameter for /resource_classes/{name} API - #[builder(default, setter(into))] - name: 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 Resource_Class. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("resource_classes/{name}", name = self.name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_classes/{name}", name = "name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().name("name").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_classes/{name}", name = "name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_class/list.rs b/openstack_sdk/src/api/placement/v1/resource_class/list.rs deleted file mode 100644 index 215c44ddc..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_class/list.rs +++ /dev/null @@ -1,174 +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`. - -//! Return a list of all resource classes. -//! -//! Normal Response Codes: 200 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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 Resource_Class. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "resource_classes".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - Some("resource_classes".into()) - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "resource_classes" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/resource_classes".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_classes": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/resource_classes".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_classes": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/aggregate/list.rs b/openstack_sdk/src/api/placement/v1/resource_provider/aggregate/list.rs deleted file mode 100644 index f715378fc..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/aggregate/list.rs +++ /dev/null @@ -1,195 +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`. - -//! Return a list of aggregates associated with the resource provider -//! identified by {uuid}. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) if the provider does not exist. (If -//! the provider has no aggregates, the result is 200 with an empty aggregate -//! list.) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for /resource_providers/{uuid}/aggregates API - #[builder(default, setter(into))] - uuid: 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 Aggregate. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/aggregates", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - Some("aggregates".into()) - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "aggregates" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/resource_providers/{uuid}/aggregates", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregates": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/resource_providers/{uuid}/aggregates", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "aggregates": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/allocation/list.rs b/openstack_sdk/src/api/placement/v1/resource_provider/allocation/list.rs deleted file mode 100644 index faa27c6c3..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/allocation/list.rs +++ /dev/null @@ -1,191 +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`. - -//! Return a representation of all allocations made against this resource -//! provider, keyed by consumer uuid. Each allocation includes one or more -//! classes of resource and the amount consumed. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for /resource_providers/{uuid}/allocations API - #[builder(default, setter(into))] - uuid: 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 Allocation. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/allocations", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/resource_providers/{uuid}/allocations", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/resource_providers/{uuid}/allocations", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/delete.rs b/openstack_sdk/src/api/placement/v1/resource_provider/delete.rs deleted file mode 100644 index 03ca8706e..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/delete.rs +++ /dev/null @@ -1,188 +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`. - -//! Delete the resource provider identified by {uuid}. This will also -//! disassociate aggregates and delete inventories. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: itemNotFound(404), conflict(409) -//! -//! A 409 Conflict response code will be returned if there exist allocations -//! records for any of the inventories that would be deleted as a result of -//! removing the resource provider. -//! -//! This error code will be also returned if there are existing child resource -//! providers under the parent resource provider being deleted. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for /resource_providers/{uuid} API - #[builder(default, setter(into))] - uuid: 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 Resource_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("resource_providers/{uuid}", uuid = self.uuid.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/resource_providers/{uuid}", uuid = "uuid",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/resource_providers/{uuid}", uuid = "uuid",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/get.rs b/openstack_sdk/src/api/placement/v1/resource_provider/get.rs deleted file mode 100644 index ee3bcb78f..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/get.rs +++ /dev/null @@ -1,180 +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`. - -//! Return a representation of the resource provider identified by {uuid}. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for /resource_providers/{uuid} API - #[builder(default, setter(into))] - uuid: 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 Resource_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("resource_providers/{uuid}", uuid = self.uuid.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_providers/{uuid}", uuid = "uuid",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_providers/{uuid}", uuid = "uuid",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/create.rs b/openstack_sdk/src/api/placement/v1/resource_provider/inventory/create.rs deleted file mode 100644 index e53de3abd..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/create.rs +++ /dev/null @@ -1,292 +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`. - -//! POST to create one inventory. -//! -//! On success return a 201 response, a location header pointing to the newly -//! created inventory and an application/json representation of the inventory. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InventoriesItem { - /// It is used in determining whether consumption of the resource of the - /// provider can exceed physical constraints. - /// - /// For example, for a vCPU resource with: - /// - /// ```text - /// allocation_ratio = 16.0 - /// total = 8 - /// ``` - /// - /// Overall capacity is equal to 128 vCPUs. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allocation_ratio: Option, - - /// A maximum amount any single allocation against an inventory can have. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_unit: Option, - - /// A minimum amount any single allocation against an inventory can have. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_unit: Option, - - /// The amount of the resource a provider has reserved for its own use. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) reserved: Option, - - /// A representation of the divisible amount of the resource that may be - /// requested. For example, step_size = 5 means that only values divisible - /// by 5 (5, 10, 15, etc.) can be requested. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) step_size: Option, - - /// The actual amount of the resource that the provider can accommodate. - #[serde()] - #[builder(setter(into))] - pub(crate) total: i32, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary of inventories keyed by resource classes. - #[builder(private, setter(into, name = "_inventories"))] - pub(crate) inventories: BTreeMap, InventoriesItem>, - - /// A consistent view marker that assists with the management of concurrent - /// resource provider updates. - #[builder(setter(into))] - pub(crate) resource_provider_generation: i32, - - /// uuid parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - uuid: 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> { - /// A dictionary of inventories keyed by resource classes. - pub fn inventories(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.inventories - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Inventory. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - format!( - "resource_providers/{uuid}/inventories", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("inventories", serde_json::to_value(&self.inventories)?); - params.push( - "resource_provider_generation", - serde_json::to_value(self.resource_provider_generation)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST).path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/delete.rs b/openstack_sdk/src/api/placement/v1/resource_provider/inventory/delete.rs deleted file mode 100644 index 4518787e0..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/delete.rs +++ /dev/null @@ -1,210 +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`. - -//! Delete the inventory record of the {resource_class} for the resource -//! provider identified by {uuid}. -//! -//! See -//! [Troubleshooting](?expanded=delete-resource-provider-inventories-detail#delete-resource-provider-inventories) -//! section in `Delete resource provider inventories` for a description. In -//! addition, the request returns HTTP 409 when there are allocations for the -//! specified resource provider and resource class. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// resource_class parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - resource_class: Cow<'a, str>, - - /// uuid parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - uuid: 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 Inventory. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/inventories/{resource_class}", - resource_class = self.resource_class.as_ref(), - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/resource_providers/{uuid}/inventories/{resource_class}", - resource_class = "resource_class", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .resource_class("resource_class") - .uuid("uuid") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/resource_providers/{uuid}/inventories/{resource_class}", - resource_class = "resource_class", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .resource_class("resource_class") - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/delete_all.rs b/openstack_sdk/src/api/placement/v1/resource_provider/inventory/delete_all.rs deleted file mode 100644 index 6a491adab..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/delete_all.rs +++ /dev/null @@ -1,197 +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`. - -//! Deletes all inventory records for the resource provider identified by -//! {uuid}. -//! -//! **Troubleshooting** -//! -//! The request returns an HTTP 409 when there are allocations against the -//! provider or if the provider’s inventory is updated by another thread while -//! attempting the operation. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - uuid: 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 Inventory. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/inventories", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE).path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/get.rs b/openstack_sdk/src/api/placement/v1/resource_provider/inventory/get.rs deleted file mode 100644 index 656feaf05..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/get.rs +++ /dev/null @@ -1,201 +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`. - -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// resource_class parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - resource_class: Cow<'a, str>, - - /// uuid parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - uuid: 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 Inventory. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/inventories/{resource_class}", - resource_class = self.resource_class.as_ref(), - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/resource_providers/{uuid}/inventories/{resource_class}", - resource_class = "resource_class", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .resource_class("resource_class") - .uuid("uuid") - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/resource_providers/{uuid}/inventories/{resource_class}", - resource_class = "resource_class", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .resource_class("resource_class") - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/list.rs b/openstack_sdk/src/api/placement/v1/resource_provider/inventory/list.rs deleted file mode 100644 index 157fef512..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/list.rs +++ /dev/null @@ -1,188 +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`. - -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - uuid: 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 Inventory. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/inventories", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET).path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/replace.rs b/openstack_sdk/src/api/placement/v1/resource_provider/inventory/replace.rs deleted file mode 100644 index 1d1e35548..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/replace.rs +++ /dev/null @@ -1,294 +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`. - -//! Replaces the set of inventory records for the resource provider identified -//! by {uuid}. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; -use std::collections::BTreeMap; - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(setter(strip_option))] -pub struct InventoriesItem { - /// It is used in determining whether consumption of the resource of the - /// provider can exceed physical constraints. - /// - /// For example, for a vCPU resource with: - /// - /// ```text - /// allocation_ratio = 16.0 - /// total = 8 - /// ``` - /// - /// Overall capacity is equal to 128 vCPUs. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) allocation_ratio: Option, - - /// A maximum amount any single allocation against an inventory can have. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) max_unit: Option, - - /// A minimum amount any single allocation against an inventory can have. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) min_unit: Option, - - /// The amount of the resource a provider has reserved for its own use. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) reserved: Option, - - /// A representation of the divisible amount of the resource that may be - /// requested. For example, step_size = 5 means that only values divisible - /// by 5 (5, 10, 15, etc.) can be requested. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) step_size: Option, - - /// The actual amount of the resource that the provider can accommodate. - #[serde()] - #[builder(setter(into))] - pub(crate) total: i32, -} - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A dictionary of inventories keyed by resource classes. - #[builder(private, setter(into, name = "_inventories"))] - pub(crate) inventories: BTreeMap, InventoriesItem>, - - /// A consistent view marker that assists with the management of concurrent - /// resource provider updates. - #[builder(setter(into))] - pub(crate) resource_provider_generation: i32, - - /// uuid parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - uuid: 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> { - /// A dictionary of inventories keyed by resource classes. - pub fn inventories(&mut self, iter: I) -> &mut Self - where - I: Iterator, - K: Into>, - V: Into, - { - self.inventories - .get_or_insert_with(BTreeMap::new) - .extend(iter.map(|(k, v)| (k.into(), v.into()))); - self - } - - /// Add a single header to the Inventory. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "resource_providers/{uuid}/inventories", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("inventories", serde_json::to_value(&self.inventories)?); - params.push( - "resource_provider_generation", - serde_json::to_value(self.resource_provider_generation)?, - ); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/resource_providers/{uuid}/inventories", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .inventories(BTreeMap::::new().into_iter()) - .resource_provider_generation(123) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/set.rs b/openstack_sdk/src/api/placement/v1/resource_provider/inventory/set.rs deleted file mode 100644 index 7a70c9126..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/inventory/set.rs +++ /dev/null @@ -1,289 +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`. - -//! Replace the inventory record of the {resource_class} for the resource -//! provider identified by {uuid}. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// It is used in determining whether consumption of the resource of the - /// provider can exceed physical constraints. - /// - /// For example, for a vCPU resource with: - /// - /// ```text - /// allocation_ratio = 16.0 - /// total = 8 - /// ``` - /// - /// Overall capacity is equal to 128 vCPUs. - #[builder(default, setter(into))] - pub(crate) allocation_ratio: Option, - - /// A maximum amount any single allocation against an inventory can have. - #[builder(default, setter(into))] - pub(crate) max_unit: Option, - - /// A minimum amount any single allocation against an inventory can have. - #[builder(default, setter(into))] - pub(crate) min_unit: Option, - - /// The amount of the resource a provider has reserved for its own use. - #[builder(default, setter(into))] - pub(crate) reserved: Option, - - /// A consistent view marker that assists with the management of concurrent - /// resource provider updates. - #[builder(setter(into))] - pub(crate) resource_provider_generation: i32, - - /// A representation of the divisible amount of the resource that may be - /// requested. For example, step_size = 5 means that only values divisible - /// by 5 (5, 10, 15, etc.) can be requested. - #[builder(default, setter(into))] - pub(crate) step_size: Option, - - /// The actual amount of the resource that the provider can accommodate. - #[builder(setter(into))] - pub(crate) total: i32, - - /// resource_class parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - resource_class: Cow<'a, str>, - - /// uuid parameter for - /// /resource_providers/{uuid}/inventories/{resource_class} API - #[builder(default, setter(into))] - uuid: 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 Inventory. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "resource_providers/{uuid}/inventories/{resource_class}", - resource_class = self.resource_class.as_ref(), - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.allocation_ratio { - params.push("allocation_ratio", serde_json::to_value(val)?); - } - if let Some(val) = &self.max_unit { - params.push("max_unit", serde_json::to_value(val)?); - } - if let Some(val) = &self.min_unit { - params.push("min_unit", serde_json::to_value(val)?); - } - if let Some(val) = &self.reserved { - params.push("reserved", serde_json::to_value(val)?); - } - params.push( - "resource_provider_generation", - serde_json::to_value(self.resource_provider_generation)?, - ); - if let Some(val) = &self.step_size { - params.push("step_size", serde_json::to_value(val)?); - } - params.push("total", serde_json::to_value(self.total)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .resource_provider_generation(123) - .total(123) - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .resource_provider_generation(123) - .total(123) - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT).path(format!( - "/resource_providers/{uuid}/inventories/{resource_class}", - resource_class = "resource_class", - uuid = "uuid", - )); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .resource_class("resource_class") - .uuid("uuid") - .resource_provider_generation(123) - .total(123) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!( - "/resource_providers/{uuid}/inventories/{resource_class}", - resource_class = "resource_class", - uuid = "uuid", - )) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .resource_class("resource_class") - .uuid("uuid") - .resource_provider_generation(123) - .total(123) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/list.rs b/openstack_sdk/src/api/placement/v1/resource_provider/list.rs deleted file mode 100644 index 636b9bc74..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/list.rs +++ /dev/null @@ -1,348 +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`. - -//! List an optionally filtered collection of resource providers. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: badRequest(400) -//! -//! A 400 BadRequest response code will be returned if a resource class -//! specified in `resources` request parameter does not exist. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A string representing a resource provider uuid. When supplied, it will - /// filter the returned allocation candidates to only those resource - /// providers that are in the same tree with the given resource provider. - #[builder(default, setter(into))] - in_tree: Option>, - - /// A string representing an aggregate uuid; or the prefix in: followed by - /// a comma-separated list of strings representing aggregate uuids. The - /// resource providers in the allocation request in the response must - /// directly or via the root provider be associated with the aggregate or - /// aggregates identified by uuid: - /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, - /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` - /// Starting from microversion 1.24 specifying multiple member_of query - /// string parameters is possible. Multiple member_of parameters will - /// result in filtering providers that are directly or via root provider - /// associated with aggregates listed in all of the member_of query string - /// values. For example, to get the providers that are associated with - /// aggregate A as well as associated with any of aggregates B or C, the - /// user could issue the following query: - /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from - /// microversion 1.32 specifying forbidden aggregates is supported in the - /// member_of query string parameter. Forbidden aggregates are prefixed - /// with a !. This negative expression can also be used in multiple - /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would - /// translate logically to “Candidate resource providers must be in AGGA - /// and not in AGGB.” We do NOT support ! on the values within in:, but we - /// support !in:. Both of the following two example queries return - /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: - /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, - /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do - /// not check if the same aggregate uuid is in both positive and negative - /// expression to return 400 BadRequest. We still return 200 for such - /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would - /// return empty allocation_requests and provider_summaries, while: - /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return - /// resource providers that are NOT in AGGA but in AGGB. - #[builder(default, private, setter(name = "_member_of"))] - member_of: Option>>, - - /// The name of a resource provider to filter the list. - #[builder(default, setter(into))] - name: Option>, - - /// A comma-separated list of traits that a provider must have: - /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the - /// response will be for resource providers that have capacity for all - /// requested resources and the set of those resource providers will - /// collectively contain all of the required traits. These traits may be - /// satisfied by any provider in the same non-sharing tree or associated - /// via aggregate as far as that provider also contributes resource to the - /// request. Starting from microversion 1.22 traits which are forbidden - /// from any resource provider contributing resources to the request may be - /// expressed by prefixing a trait with a `!`. Starting from microversion - /// 1.39 the required query parameter can be repeated. The trait lists from - /// the repeated parameters are AND-ed together. So: - /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting - /// from microversion 1.39 the required parameter supports the syntax: - /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden - /// traits into an in: prefixed value is not supported and rejected. But - /// mixing a normal trait list and an in: prefixed trait list in two query - /// params within the same request is supported. So: - /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and - /// not T2 and (T3 or T4). - #[builder(default, private, setter(name = "_required"))] - required: Option>>, - - /// A comma-separated list of strings indicating an amount of resource of a - /// specified class that providers in each allocation request must - /// collectively have the capacity and availability to serve: - /// `resources=VCPU:4,DISK_GB:64,MEMORY_MB:2048` These resources may be - /// satisfied by any provider in the same non-sharing tree or associated - /// via aggregate. - #[builder(default, setter(into))] - resources: Option>, - - /// The uuid of a resource provider. - #[builder(default, setter(into))] - 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> { - /// A string representing an aggregate uuid; or the prefix in: followed by - /// a comma-separated list of strings representing aggregate uuids. The - /// resource providers in the allocation request in the response must - /// directly or via the root provider be associated with the aggregate or - /// aggregates identified by uuid: - /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, - /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` - /// Starting from microversion 1.24 specifying multiple member_of query - /// string parameters is possible. Multiple member_of parameters will - /// result in filtering providers that are directly or via root provider - /// associated with aggregates listed in all of the member_of query string - /// values. For example, to get the providers that are associated with - /// aggregate A as well as associated with any of aggregates B or C, the - /// user could issue the following query: - /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from - /// microversion 1.32 specifying forbidden aggregates is supported in the - /// member_of query string parameter. Forbidden aggregates are prefixed - /// with a !. This negative expression can also be used in multiple - /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would - /// translate logically to “Candidate resource providers must be in AGGA - /// and not in AGGB.” We do NOT support ! on the values within in:, but we - /// support !in:. Both of the following two example queries return - /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: - /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, - /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do - /// not check if the same aggregate uuid is in both positive and negative - /// expression to return 400 BadRequest. We still return 200 for such - /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would - /// return empty allocation_requests and provider_summaries, while: - /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return - /// resource providers that are NOT in AGGA but in AGGB. - pub fn member_of(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.member_of - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// A comma-separated list of traits that a provider must have: - /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the - /// response will be for resource providers that have capacity for all - /// requested resources and the set of those resource providers will - /// collectively contain all of the required traits. These traits may be - /// satisfied by any provider in the same non-sharing tree or associated - /// via aggregate as far as that provider also contributes resource to the - /// request. Starting from microversion 1.22 traits which are forbidden - /// from any resource provider contributing resources to the request may be - /// expressed by prefixing a trait with a `!`. Starting from microversion - /// 1.39 the required query parameter can be repeated. The trait lists from - /// the repeated parameters are AND-ed together. So: - /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting - /// from microversion 1.39 the required parameter supports the syntax: - /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden - /// traits into an in: prefixed value is not supported and rejected. But - /// mixing a normal trait list and an in: prefixed trait list in two query - /// params within the same request is supported. So: - /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and - /// not T2 and (T3 or T4). - pub fn required(&mut self, iter: I) -> &mut Self - where - I: Iterator, - T: Into>, - { - self.required - .get_or_insert(None) - .get_or_insert_with(Vec::new) - .extend(iter.map(Into::into)); - self - } - - /// Add a single header to the Resource_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "resource_providers".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("in_tree", self.in_tree.as_ref()); - if let Some(val) = &self.member_of { - params.extend(val.iter().map(|value| ("member_of", value))); - } - params.push_opt("name", self.name.as_ref()); - if let Some(val) = &self.required { - params.extend(val.iter().map(|value| ("required", value))); - } - params.push_opt("resources", self.resources.as_ref()); - params.push_opt("uuid", self.uuid.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - Some("resource_providers".into()) - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "resource_providers" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/resource_providers".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_providers": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/resource_providers".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "resource_providers": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/set_10.rs b/openstack_sdk/src/api/placement/v1/resource_provider/set_10.rs deleted file mode 100644 index 8bf08b9e5..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/set_10.rs +++ /dev/null @@ -1,212 +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`. - -//! Update the name of the resource provider identified by {uuid}. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) -//! -//! A 409 Conflict response code will be returned if another resource provider -//! exists with the provided name. -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// The name of one resource provider. - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// uuid parameter for /resource_providers/{uuid} API - #[builder(default, setter(into))] - uuid: 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 Resource_Provider. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("resource_providers/{uuid}", uuid = self.uuid.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("name", serde_json::to_value(&self.name)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - 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 { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .is_none() - ) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/resource_providers/{uuid}", uuid = "uuid",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").name("foo").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/resource_providers/{uuid}", uuid = "uuid",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/trait/delete.rs b/openstack_sdk/src/api/placement/v1/resource_provider/trait/delete.rs deleted file mode 100644 index 497b83ccb..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/trait/delete.rs +++ /dev/null @@ -1,184 +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`. - -//! Dissociate all the traits from the resource provider identified by {uuid}. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for /resource_providers/{uuid}/traits API - #[builder(default, setter(into))] - uuid: 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 Trait. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/traits", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/trait/list.rs b/openstack_sdk/src/api/placement/v1/resource_provider/trait/list.rs deleted file mode 100644 index ddb06a268..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/trait/list.rs +++ /dev/null @@ -1,187 +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`. - -//! Return a list of traits for the resource provider identified by {uuid}. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for /resource_providers/{uuid}/traits API - #[builder(default, setter(into))] - uuid: 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 Trait. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/traits", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - Some("traits".into()) - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "traits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "traits": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "traits": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/trait/set.rs b/openstack_sdk/src/api/placement/v1/resource_provider/trait/set.rs deleted file mode 100644 index 7f65ae7fb..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/trait/set.rs +++ /dev/null @@ -1,215 +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`. - -//! Associate traits with the resource provider identified by {uuid}. All the -//! associated traits will be replaced by the traits specified in the request -//! body. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A list of traits. - #[builder(setter(into))] - pub(crate) traits: Vec>, - - /// uuid parameter for /resource_providers/{uuid}/traits API - #[builder(default, setter(into))] - uuid: 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 Trait. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!( - "resource_providers/{uuid}/traits", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("traits", serde_json::to_value(&self.traits)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - Some("traits".into()) - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .traits(Vec::from(["foo".into()])) - .build() - .unwrap() - .service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .traits(Vec::from(["foo".into()])) - .build() - .unwrap() - .response_key() - .unwrap(), - "traits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "traits": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .traits(Vec::from(["foo".into()])) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "traits": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .traits(Vec::from(["foo".into()])) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/usage/get.rs b/openstack_sdk/src/api/placement/v1/resource_provider/usage/get.rs deleted file mode 100644 index 180963673..000000000 --- a/openstack_sdk/src/api/placement/v1/resource_provider/usage/get.rs +++ /dev/null @@ -1,187 +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`. - -//! Return a report of usage information for resources associated with the -//! resource provider identified by {uuid}. The value is a dictionary of -//! resource classes paired with the sum of the allocations of that resource -//! class for this resource provider. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// uuid parameter for /resource_providers/{uuid}/usages API - #[builder(default, setter(into))] - uuid: 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 Usage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!( - "resource_providers/{uuid}/usages", - uuid = self.uuid.as_ref(), - ) - .into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_providers/{uuid}/usages", uuid = "uuid",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().uuid("uuid").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/resource_providers/{uuid}/usages", uuid = "uuid",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .uuid("uuid") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/trait/delete.rs b/openstack_sdk/src/api/placement/v1/trait/delete.rs deleted file mode 100644 index 5756fa98b..000000000 --- a/openstack_sdk/src/api/placement/v1/trait/delete.rs +++ /dev/null @@ -1,181 +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`. - -//! Delete the trait specified be {name}. Note that only custom traits can be -//! deleted. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// name parameter for /traits/{name} API - #[builder(default, setter(into))] - name: 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 Trait. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("traits/{name}", name = self.name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/traits/{name}", name = "name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().name("name").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::DELETE) - .path(format!("/traits/{name}", name = "name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/trait/get.rs b/openstack_sdk/src/api/placement/v1/trait/get.rs deleted file mode 100644 index 812d76637..000000000 --- a/openstack_sdk/src/api/placement/v1/trait/get.rs +++ /dev/null @@ -1,180 +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`. - -//! Check if a trait name exists in this cloud. -//! -//! Normal Response Codes: 204 -//! -//! Error response codes: itemNotFound(404) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// name parameter for /traits/{name} API - #[builder(default, setter(into))] - name: 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 Trait. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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!("traits/{name}", name = self.name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/traits/{name}", name = "name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().name("name").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path(format!("/traits/{name}", name = "name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/trait/list.rs b/openstack_sdk/src/api/placement/v1/trait/list.rs deleted file mode 100644 index 11f1678e0..000000000 --- a/openstack_sdk/src/api/placement/v1/trait/list.rs +++ /dev/null @@ -1,190 +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`. - -//! Return a list of valid trait strings according to parameters specified. -//! -//! Normal Response Codes: 200 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// If this parameter has a true value, the returned traits will be those - /// that are associated with at least one resource provider. Available - /// values for the parameter are true and false. - #[builder(default)] - associated: Option, - - /// The name of a resource provider to filter the list. - #[builder(default, setter(into))] - name: 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> { - /// Add a single header to the Trait. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "traits".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("associated", self.associated); - params.push_opt("name", self.name.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - Some("traits".into()) - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "traits" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/traits".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "traits": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/traits".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "traits": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/trait/set.rs b/openstack_sdk/src/api/placement/v1/trait/set.rs deleted file mode 100644 index 76976839c..000000000 --- a/openstack_sdk/src/api/placement/v1/trait/set.rs +++ /dev/null @@ -1,188 +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`. - -//! Insert a new custom trait. If traits already exists 204 will be returned. -//! -//! There are two kinds of traits: the standard traits and the custom traits. -//! The standard traits are interoperable across different OpenStack cloud -//! deployments. The definition of standard traits comes from the os-traits -//! library. The standard traits are read-only in the placement API which means -//! that the user can’t modify any standard traits through API. The custom -//! traits are used by admin users to manage the non-standard qualitative -//! information of resource providers. -//! -//! Normal Response Codes: 201, 204 -//! -//! Error response codes: badRequest(400) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// name parameter for /traits/{name} API - #[builder(default, setter(into))] - name: 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 Trait. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("traits/{name}", name = self.name.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/traits/{name}", name = "name",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder().name("name").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/traits/{name}", name = "name",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "dummy": {} })); - }); - - let endpoint = Request::builder() - .name("name") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/usage/list.rs b/openstack_sdk/src/api/placement/v1/usage/list.rs deleted file mode 100644 index fef50fedc..000000000 --- a/openstack_sdk/src/api/placement/v1/usage/list.rs +++ /dev/null @@ -1,203 +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`. - -//! Return a report of usage information for resources associated with the -//! project identified by project_id and user identified by user_id. The value -//! is a dictionary of resource classes paired with the sum of the allocations -//! of that resource class for provided parameters. -//! -//! Normal Response Codes: 200 -//! -//! Error response codes: badRequest(400) -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::api::rest_endpoint_prelude::*; - -use std::borrow::Cow; - -#[derive(Builder, Debug, Clone)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// A string that consists of numbers, A-Z, and _ describing the consumer - /// type by which to filter usage results. For example, to retrieve only - /// usage information for ‘INSTANCE’ type consumers a parameter of - /// consumer_type=INSTANCE should be provided. The all query parameter may - /// be specified to group all results under one key, all. The unknown query - /// parameter may be specified to group all results under one key, unknown. - #[builder(default, setter(into))] - consumer_type: Option>, - - /// The uuid of a project. - #[builder(default, setter(into))] - project_id: Cow<'a, str>, - - /// The uuid of a user. - #[builder(default, setter(into))] - user_id: 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> { - /// Add a single header to the Usage. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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> { - "usages".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - let mut params = QueryParams::default(); - params.push_opt("consumer_type", self.consumer_type.as_ref()); - params.push("project_id", self.project_id.as_ref()); - params.push_opt("user_id", self.user_id.as_ref()); - - params - } - - fn service_type(&self) -> ServiceType { - ServiceType::Placement - } - - fn response_key(&self) -> Option> { - Some("usages".into()) - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder().build().unwrap().response_key().unwrap(), - "usages" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/usages".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "usages": {} })); - }); - - let endpoint = Request::builder().build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::GET) - .path("/usages".to_string()) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "usages": {} })); - }); - - let endpoint = Request::builder() - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/placement/v1/version/get.rs b/openstack_sdk/src/api/placement/v1/version/get.rs deleted file mode 100644 index b69f5700f..000000000 --- a/openstack_sdk/src/api/placement/v1/version/get.rs +++ /dev/null @@ -1,171 +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`. - -//! Fetch information about all known major versions of the placement API, -//! including information about the minimum and maximum microversions. -//! -//! Normal Response Codes: 200 -//! -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; - -use openstack_sdk_core::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: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::Placement - } - - fn response_key(&self) -> Option> { - None - } - - /// Returns headers to be set into the request - fn request_headers(&self) -> Option<&HeaderMap> { - self._headers.as_ref() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - #[cfg(feature = "sync")] - use openstack_sdk_core::api::Query; - use openstack_sdk_core::types::ServiceType; - use serde_json::json; - - use crate::test::client::FakeOpenStackClient; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder().build().unwrap().service_type(), - ServiceType::Placement - ); - } - - #[test] - fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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 server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = 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( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/api/rest_endpoint_prelude.rs b/openstack_sdk/src/api/rest_endpoint_prelude.rs index f55f7534b..dccc61ab3 100644 --- a/openstack_sdk/src/api/rest_endpoint_prelude.rs +++ b/openstack_sdk/src/api/rest_endpoint_prelude.rs @@ -22,7 +22,7 @@ pub use std::borrow::Cow; pub use crate::api::BodyError; pub use crate::api::JsonBodyParams; pub use crate::api::Pageable; -pub use crate::api::QueryParams; pub use crate::api::RestEndpoint; pub use crate::types::ApiVersion; -pub use crate::types::ServiceType; +pub use openstack_sdk_core::api::QueryParams; +pub use openstack_sdk_core::types::ServiceType; diff --git a/openstack_sdk/src/auth.rs b/openstack_sdk/src/auth.rs index 675ee61e8..f2b697dde 100644 --- a/openstack_sdk/src/auth.rs +++ b/openstack_sdk/src/auth.rs @@ -20,7 +20,6 @@ //! - None (unauthenticated) pub mod auth_helper; -//mod auth_token_endpoint; pub mod authtoken; pub mod v3_token_info; diff --git a/openstack_sdk/src/auth/auth_token_endpoint.rs b/openstack_sdk/src/auth/auth_token_endpoint.rs deleted file mode 100644 index 413b7475c..000000000 --- a/openstack_sdk/src/auth/auth_token_endpoint.rs +++ /dev/null @@ -1,522 +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 -// -//! Token authentication endpoint. -//! -//! This is mostly a copy of the identity/auth/token/create endpoint which is necessary to -//! guarantee certain code stability once the autogenerated endpoint code changes. -use derive_builder::Builder; -use http::{HeaderMap, HeaderName, HeaderValue}; -use secrecy::SecretString; -use serde::Deserialize; -use serde::Serialize; -use std::borrow::Cow; - -use openstack_sdk_core::BuilderError; - -use crate::api::common::serialize_sensitive_optional_string; -use crate::api::common::serialize_sensitive_string; -use crate::api::rest_endpoint_prelude::*; - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Methods { - #[serde(rename = "application_credential")] - ApplicationCredential, - #[serde(rename = "password")] - Password, - #[serde(rename = "token")] - Token, - #[serde(rename = "totp")] - Totp, -} - -/// A `domain` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Domain<'a> { - /// User Domain ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// User Domain Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// A `user` object for the password authentication. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct PasswordUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The ID of the user. Required if you do not specify the user name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name. Required if you do not specify the ID of the user. If - /// you specify the user name, you must also specify the domain, by ID or - /// name. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// User Password - #[serde( - serialize_with = "serialize_sensitive_optional_string", - skip_serializing_if = "Option::is_none" - )] - #[builder(default, setter(into))] - pub(crate) password: Option, -} - -/// The `password` object, contains the authentication information. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Password<'a> { - /// A `user` object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -/// A `token` object -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Token { - /// Authorization Token value - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) id: SecretString, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct TotpUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// MFA passcode - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) passcode: SecretString, -} - -/// Multi Factor Authentication information -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Totp<'a> { - #[serde()] - #[builder(setter(into))] - pub(crate) user: TotpUser<'a>, -} - -/// A user object, required if an application credential is identified by name -/// and not ID. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct ApplicationCredentialUser<'a> { - /// A `domain` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// The user ID - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The user name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -/// An application credential object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct ApplicationCredential<'a> { - /// The ID of the application credential used for authentication. If not - /// provided, the application credential must be identified by its name and - /// its owning user. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// The name of the application credential used for authentication. If - /// provided, must be accompanied by a user object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, - - /// The secret for authenticating the application credential. - #[serde(serialize_with = "serialize_sensitive_string")] - #[builder(setter(into))] - pub(crate) secret: SecretString, - - /// A user object, required if an application credential is identified by - /// name and not ID. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) user: Option>, -} - -/// An `identity` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Identity<'a> { - /// An application credential object. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) application_credential: Option>, - - /// The authentication method. For password authentication, specify - /// `password`. - #[serde()] - #[builder(setter(into))] - pub(crate) methods: Vec, - - /// The `password` object, contains the authentication information. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) password: Option>, - - /// A `token` object - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) token: Option, - - /// Multi Factor Authentication information - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) totp: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Project<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - /// Project Id - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, - - /// Project Name - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) name: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct OsTrustTrust<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) id: Option>, -} - -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct System { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) all: Option, -} - -/// The authorization scope, including the system (Since v3.10), a project, or -/// a domain (Since v3.4). If multiple scopes are specified in the same request -/// (e.g. project and domain or domain and system) an HTTP 400 Bad Request will -/// be returned, as a token cannot be simultaneously scoped to multiple -/// authorization targets. An ID is sufficient to uniquely identify a project -/// but if a project is specified by name, then the domain of the project must -/// also be specified in order to uniquely identify the project by name. A -/// domain scope may be specified by either the domain’s ID or name with -/// equivalent results. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Scope<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) domain: Option>, - - #[serde(rename = "OS-TRUST:trust", skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) os_trust_trust: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) project: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) system: Option, -} - -/// An `auth` object. -#[derive(Builder, Debug, Deserialize, Clone, Serialize)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Auth<'a> { - /// An `identity` object. - #[serde()] - #[builder(setter(into))] - pub(crate) identity: Identity<'a>, - - /// The authorization scope, including the system (Since v3.10), a project, - /// or a domain (Since v3.4). If multiple scopes are specified in the same - /// request (e.g. project and domain or domain and system) an HTTP 400 Bad - /// Request will be returned, as a token cannot be simultaneously scoped to - /// multiple authorization targets. An ID is sufficient to uniquely - /// identify a project but if a project is specified by name, then the - /// domain of the project must also be specified in order to uniquely - /// identify the project by name. A domain scope may be specified by either - /// the domain’s ID or name with equivalent results. - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(default, setter(into))] - pub(crate) scope: Option>, -} - -#[derive(Builder, Debug, Clone)] -#[builder(build_fn(error = "BuilderError"))] -#[builder(setter(strip_option))] -pub struct Request<'a> { - /// An `auth` object. - #[builder(setter(into))] - pub(crate) auth: Auth<'a>, - - #[builder(setter(name = "_headers"), default, private)] - _headers: Option, -} - -impl RequestBuilder<'_> { - /// 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> { - "auth/tokens".to_string().into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - params.push("auth", serde_json::to_value(&self.auth)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Identity - } - - fn response_key(&self) -> Option> { - Some("token".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(3, 0)) - } -} - -//impl From for AuthTokenError { -// fn from(value: BuilderError) -> Self { -// AuthTokenError::auth_request(value) -// } -//} - -#[cfg(test)] -mod tests { - use super::*; - #[cfg(feature = "sync")] - use crate::api::Query; - use crate::test::client::FakeOpenStackClient; - use crate::types::ServiceType; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - use serde_json::json; - - #[test] - fn test_service_type() { - assert_eq!( - RequestBuilder::default() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .service_type(), - ServiceType::Identity - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - RequestBuilder::default() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap() - ) - .build() - .unwrap() - ) - .build() - .unwrap() - .response_key() - .unwrap(), - "token" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/tokens".to_string()); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = RequestBuilder::default() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::POST) - .path("/auth/tokens".to_string()) - .header("foo", "bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "token": {} })); - }); - - let endpoint = RequestBuilder::default() - .auth( - AuthBuilder::default() - .identity( - IdentityBuilder::default() - .methods(Vec::from([Methods::ApplicationCredential])) - .build() - .unwrap(), - ) - .build() - .unwrap(), - ) - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_sdk/src/auth/v3_token_info.rs b/openstack_sdk/src/auth/v3_token_info.rs index e8301f4f2..563b9bb30 100644 --- a/openstack_sdk/src/auth/v3_token_info.rs +++ b/openstack_sdk/src/auth/v3_token_info.rs @@ -27,7 +27,7 @@ use derive_builder::Builder; use http::{HeaderMap, HeaderName, HeaderValue}; -use crate::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::rest_endpoint_prelude::*; use std::borrow::Cow; @@ -107,12 +107,12 @@ impl RestEndpoint for Request { #[cfg(test)] mod tests { use super::*; - #[cfg(feature = "sync")] - use crate::api::Query; use crate::test::client::FakeOpenStackClient; - use crate::types::ServiceType; use http::{HeaderName, HeaderValue}; use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; use serde_json::json; #[test] diff --git a/sdk-core/README.md b/sdk-core/README.md deleted file mode 100644 index abc317f48..000000000 --- a/sdk-core/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# OpenStack API bindings (SDK) - core - -`openstack_sdk_core` implements basic functionality used by the `openstack_sdk` -crate as the OpenStack SDK (interfaces, connection client, catalog, version -discovery, etc). This crate does not implement service bindings, and is -therefore not very useful alone. - -## Features - -- Sync and Async interface -- `Query`, `Find` and `Pagination` interfaces implementing basic functionality -- `RawQuery` interface providing more control over the API invocation with - upload and download capabilities. - -# Using - -The simplest example demonstrating how to list compute flavors: - -```rust -use openstack_sdk_core::api::{paged, Pagination, QueryAsync, Pageable, - RestEndpoint}; -use openstack_sdk_core::{config::ConfigFile, OpenStackError}; -use openstack_sdk_core::types::ServiceType; -use std::borrow::Cow; - -#[derive(derive_builder::Builder)] -#[builder(setter(strip_option))] -pub struct Request<'a> { - id: Cow<'a, str>, - #[builder(default, setter(into))] - min_disk: Option>, -} - -impl RestEndpoint for Request<'_> { - fn method(&self) -> http::Method { - http::Method::GET - } - - fn endpoint(&self) -> Cow<'static, str> { - "flavors".to_string().into() - } - - fn service_type(&self) -> ServiceType { - ServiceType::Compute - } - - fn response_key(&self) -> Option> { - Some("flavor".into()) - } -} -impl Pageable for Request<'_> {} - -async fn list_flavors() -> Result<(), OpenStackError> { - // Get the builder for the listing Flavors Endpoint - let mut ep_builder = RequestBuilder::default(); - // Set the `min_disk` query param - ep_builder.min_disk("15"); - let ep = ep_builder.build().unwrap(); - - let cfg = ConfigFile::new().unwrap(); - // Get connection config from clouds.yaml/secure.yaml - let _profile = cfg.get_cloud_config("devstack").unwrap().unwrap(); - // Establish connection - // let mut session = AsyncOpenStack::new(&profile).await?; - - // Invoke service discovery when desired. - // session.discover_service_endpoint(&ServiceType::Compute).await?; - - // Execute the call with pagination limiting maximum amount of entries to 1000 - // let data: Vec = paged(ep, Pagination::Limit(1000)) - // .query_async(&session) - // .await.unwrap(); - - // println!("Data = {:?}", data); - Ok(()) -} -``` diff --git a/sdk-core/src/lib.rs b/sdk-core/src/lib.rs deleted file mode 100644 index 81753f314..000000000 --- a/sdk-core/src/lib.rs +++ /dev/null @@ -1,29 +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 - -#![doc = include_str!("../README.md")] - -pub mod api; -pub mod auth; -pub mod catalog; -pub mod config; -pub mod error; -pub mod state; -pub mod types; -pub mod utils; - -pub use crate::error::{BuilderError, OpenStackError, RestError}; - -#[allow(dead_code)] -pub mod test; diff --git a/auth-application-credential/Cargo.toml b/sdk/auth-application-credential/Cargo.toml similarity index 100% rename from auth-application-credential/Cargo.toml rename to sdk/auth-application-credential/Cargo.toml diff --git a/auth-application-credential/src/lib.rs b/sdk/auth-application-credential/src/lib.rs similarity index 100% rename from auth-application-credential/src/lib.rs rename to sdk/auth-application-credential/src/lib.rs diff --git a/auth-core/Cargo.toml b/sdk/auth-core/Cargo.toml similarity index 100% rename from auth-core/Cargo.toml rename to sdk/auth-core/Cargo.toml diff --git a/auth-core/src/authtoken.rs b/sdk/auth-core/src/authtoken.rs similarity index 100% rename from auth-core/src/authtoken.rs rename to sdk/auth-core/src/authtoken.rs diff --git a/auth-core/src/authtoken_scope.rs b/sdk/auth-core/src/authtoken_scope.rs similarity index 100% rename from auth-core/src/authtoken_scope.rs rename to sdk/auth-core/src/authtoken_scope.rs diff --git a/auth-core/src/lib.rs b/sdk/auth-core/src/lib.rs similarity index 100% rename from auth-core/src/lib.rs rename to sdk/auth-core/src/lib.rs diff --git a/auth-core/src/types.rs b/sdk/auth-core/src/types.rs similarity index 100% rename from auth-core/src/types.rs rename to sdk/auth-core/src/types.rs diff --git a/auth-federation/Cargo.toml b/sdk/auth-federation/Cargo.toml similarity index 100% rename from auth-federation/Cargo.toml rename to sdk/auth-federation/Cargo.toml diff --git a/auth-federation/src/lib.rs b/sdk/auth-federation/src/lib.rs similarity index 100% rename from auth-federation/src/lib.rs rename to sdk/auth-federation/src/lib.rs diff --git a/auth-federation/static/callback.html b/sdk/auth-federation/static/callback.html similarity index 100% rename from auth-federation/static/callback.html rename to sdk/auth-federation/static/callback.html diff --git a/auth-federation/static/callback_error.html b/sdk/auth-federation/static/callback_error.html similarity index 100% rename from auth-federation/static/callback_error.html rename to sdk/auth-federation/static/callback_error.html diff --git a/auth-jwt/Cargo.toml b/sdk/auth-jwt/Cargo.toml similarity index 100% rename from auth-jwt/Cargo.toml rename to sdk/auth-jwt/Cargo.toml diff --git a/auth-jwt/src/lib.rs b/sdk/auth-jwt/src/lib.rs similarity index 100% rename from auth-jwt/src/lib.rs rename to sdk/auth-jwt/src/lib.rs diff --git a/auth-multifactor/Cargo.toml b/sdk/auth-multifactor/Cargo.toml similarity index 100% rename from auth-multifactor/Cargo.toml rename to sdk/auth-multifactor/Cargo.toml diff --git a/auth-multifactor/src/lib.rs b/sdk/auth-multifactor/src/lib.rs similarity index 100% rename from auth-multifactor/src/lib.rs rename to sdk/auth-multifactor/src/lib.rs diff --git a/auth-oidcaccesstoken/Cargo.toml b/sdk/auth-oidcaccesstoken/Cargo.toml similarity index 100% rename from auth-oidcaccesstoken/Cargo.toml rename to sdk/auth-oidcaccesstoken/Cargo.toml diff --git a/auth-oidcaccesstoken/src/lib.rs b/sdk/auth-oidcaccesstoken/src/lib.rs similarity index 100% rename from auth-oidcaccesstoken/src/lib.rs rename to sdk/auth-oidcaccesstoken/src/lib.rs diff --git a/auth-passkey/Cargo.toml b/sdk/auth-passkey/Cargo.toml similarity index 100% rename from auth-passkey/Cargo.toml rename to sdk/auth-passkey/Cargo.toml diff --git a/auth-passkey/src/error.rs b/sdk/auth-passkey/src/error.rs similarity index 100% rename from auth-passkey/src/error.rs rename to sdk/auth-passkey/src/error.rs diff --git a/auth-passkey/src/finish.rs b/sdk/auth-passkey/src/finish.rs similarity index 100% rename from auth-passkey/src/finish.rs rename to sdk/auth-passkey/src/finish.rs diff --git a/auth-passkey/src/lib.rs b/sdk/auth-passkey/src/lib.rs similarity index 100% rename from auth-passkey/src/lib.rs rename to sdk/auth-passkey/src/lib.rs diff --git a/auth-passkey/src/start.rs b/sdk/auth-passkey/src/start.rs similarity index 100% rename from auth-passkey/src/start.rs rename to sdk/auth-passkey/src/start.rs diff --git a/auth-password/Cargo.toml b/sdk/auth-password/Cargo.toml similarity index 100% rename from auth-password/Cargo.toml rename to sdk/auth-password/Cargo.toml diff --git a/auth-password/src/lib.rs b/sdk/auth-password/src/lib.rs similarity index 100% rename from auth-password/src/lib.rs rename to sdk/auth-password/src/lib.rs diff --git a/auth-receipt/Cargo.toml b/sdk/auth-receipt/Cargo.toml similarity index 100% rename from auth-receipt/Cargo.toml rename to sdk/auth-receipt/Cargo.toml diff --git a/auth-receipt/src/lib.rs b/sdk/auth-receipt/src/lib.rs similarity index 100% rename from auth-receipt/src/lib.rs rename to sdk/auth-receipt/src/lib.rs diff --git a/auth-token/Cargo.toml b/sdk/auth-token/Cargo.toml similarity index 100% rename from auth-token/Cargo.toml rename to sdk/auth-token/Cargo.toml diff --git a/auth-token/src/lib.rs b/sdk/auth-token/src/lib.rs similarity index 100% rename from auth-token/src/lib.rs rename to sdk/auth-token/src/lib.rs diff --git a/auth-totp/Cargo.toml b/sdk/auth-totp/Cargo.toml similarity index 100% rename from auth-totp/Cargo.toml rename to sdk/auth-totp/Cargo.toml diff --git a/auth-totp/src/lib.rs b/sdk/auth-totp/src/lib.rs similarity index 100% rename from auth-totp/src/lib.rs rename to sdk/auth-totp/src/lib.rs diff --git a/auth-websso/Cargo.toml b/sdk/auth-websso/Cargo.toml similarity index 100% rename from auth-websso/Cargo.toml rename to sdk/auth-websso/Cargo.toml diff --git a/auth-websso/src/lib.rs b/sdk/auth-websso/src/lib.rs similarity index 100% rename from auth-websso/src/lib.rs rename to sdk/auth-websso/src/lib.rs diff --git a/auth-websso/static/callback.html b/sdk/auth-websso/static/callback.html similarity index 100% rename from auth-websso/static/callback.html rename to sdk/auth-websso/static/callback.html diff --git a/sdk/block-storage/Cargo.toml b/sdk/block-storage/Cargo.toml new file mode 100644 index 000000000..739abeaa4 --- /dev/null +++ b/sdk/block-storage/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "openstack-sdk-block-storage" +description = "OpenStack SDK Block Storage service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true +serde_json.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/block-storage/src/lib.rs b/sdk/block-storage/src/lib.rs new file mode 100644 index 000000000..cd673f0b4 --- /dev/null +++ b/sdk/block-storage/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Block_storage` Service bindings +pub mod v3; diff --git a/openstack_sdk/src/api/block_storage/v3.rs b/sdk/block-storage/src/v3.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3.rs rename to sdk/block-storage/src/v3.rs diff --git a/openstack_sdk/src/api/block_storage/v3/attachment.rs b/sdk/block-storage/src/v3/attachment.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/attachment.rs rename to sdk/block-storage/src/v3/attachment.rs diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/create_327.rs b/sdk/block-storage/src/v3/attachment/create_327.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/attachment/create_327.rs rename to sdk/block-storage/src/v3/attachment/create_327.rs index f96b5c3f7..d42bd9460 100644 --- a/openstack_sdk/src/api/block_storage/v3/attachment/create_327.rs +++ b/sdk/block-storage/src/v3/attachment/create_327.rs @@ -218,7 +218,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/create_354.rs b/sdk/block-storage/src/v3/attachment/create_354.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/attachment/create_354.rs rename to sdk/block-storage/src/v3/attachment/create_354.rs index 9f2a3e4f5..d62dc7c50 100644 --- a/openstack_sdk/src/api/block_storage/v3/attachment/create_354.rs +++ b/sdk/block-storage/src/v3/attachment/create_354.rs @@ -234,7 +234,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/attachment/delete.rs b/sdk/block-storage/src/v3/attachment/delete.rs new file mode 100644 index 000000000..f1d88edbd --- /dev/null +++ b/sdk/block-storage/src/v3/attachment/delete.rs @@ -0,0 +1,186 @@ +// 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 an attachment. +//! +//! Disconnects/Deletes the specified attachment, returns a list of any known +//! shared attachment-id's for the effected backend device. +//! +//! returns: A summary list of any attachments sharing this connection +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/attachments/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("attachments/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/attachments/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/attachments/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/attachment/get.rs b/sdk/block-storage/src/v3/attachment/get.rs new file mode 100644 index 000000000..d0283ca6c --- /dev/null +++ b/sdk/block-storage/src/v3/attachment/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about the given attachment. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/attachments/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("attachments/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("attachment".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "attachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/attachments/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "attachment": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/attachments/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "attachment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/attachment/list.rs b/sdk/block-storage/src/v3/attachment/list.rs new file mode 100644 index 000000000..a29ad70ec --- /dev/null +++ b/sdk/block-storage/src/v3/attachment/list.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Return a summary list of attachments. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "attachments".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("attachments".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "attachments" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/attachments".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "attachments": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/attachments".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "attachments": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/attachment/list_detailed.rs b/sdk/block-storage/src/v3/attachment/list_detailed.rs new file mode 100644 index 000000000..27069887a --- /dev/null +++ b/sdk/block-storage/src/v3/attachment/list_detailed.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Return a detailed list of attachments. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "attachments/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("attachments".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "attachments" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/attachments/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "attachments": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/attachments/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "attachments": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/os_complete_344.rs b/sdk/block-storage/src/v3/attachment/os_complete_344.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/attachment/os_complete_344.rs rename to sdk/block-storage/src/v3/attachment/os_complete_344.rs index 331cf1cea..6edb01a0f 100644 --- a/openstack_sdk/src/api/block_storage/v3/attachment/os_complete_344.rs +++ b/sdk/block-storage/src/v3/attachment/os_complete_344.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/set_327.rs b/sdk/block-storage/src/v3/attachment/set_327.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/attachment/set_327.rs rename to sdk/block-storage/src/v3/attachment/set_327.rs index 5d66b626f..938c1b84f 100644 --- a/openstack_sdk/src/api/block_storage/v3/attachment/set_327.rs +++ b/sdk/block-storage/src/v3/attachment/set_327.rs @@ -172,7 +172,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/availability_zone.rs b/sdk/block-storage/src/v3/availability_zone.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/availability_zone.rs rename to sdk/block-storage/src/v3/availability_zone.rs diff --git a/sdk/block-storage/src/v3/availability_zone/list.rs b/sdk/block-storage/src/v3/availability_zone/list.rs new file mode 100644 index 000000000..d1c18bd9d --- /dev/null +++ b/sdk/block-storage/src/v3/availability_zone/list.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`. + +//! Describe all known availability zones. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-availability-zone".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("availabilityZoneInfo".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availabilityZoneInfo" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-availability-zone".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availabilityZoneInfo": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-availability-zone".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availabilityZoneInfo": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/backup.rs b/sdk/block-storage/src/v3/backup.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/backup.rs rename to sdk/block-storage/src/v3/backup.rs diff --git a/sdk/block-storage/src/v3/backup/create_30.rs b/sdk/block-storage/src/v3/backup/create_30.rs new file mode 100644 index 000000000..0183b4ef4 --- /dev/null +++ b/sdk/block-storage/src/v3/backup/create_30.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`. + +//! Create a new backup. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `backup` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Backup<'a> { + /// The container name or null. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) container: Option>>, + + /// The backup description or null. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Indicates whether to backup, even if the volume is attached. Default is + /// `false`. See [valid boolean values](#valid-boolean-values) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) force: Option, + + /// Indicates whether to backup, even if the volume is attached. Default is + /// `false`. See [valid boolean values](#valid-boolean-values) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) incremental: Option, + + /// The name of the Volume Backup. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The UUID of the source snapshot that you want to back up. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) snapshot_id: Option>>, + + /// The UUID of the volume that you want to back up. + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `backup` object. + #[builder(setter(into))] + pub(crate) backup: Backup<'a>, + + #[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 Backup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "backups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("backup", serde_json::to_value(&self.backup)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("backup".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "backup" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/backups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup": {} })); + }); + + let endpoint = Request::builder() + .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/backups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup": {} })); + }); + + let endpoint = Request::builder() + .backup(BackupBuilder::default().volume_id("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/create_343.rs b/sdk/block-storage/src/v3/backup/create_343.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/backup/create_343.rs rename to sdk/block-storage/src/v3/backup/create_343.rs index 8b94c09ad..8806633df 100644 --- a/openstack_sdk/src/api/block_storage/v3/backup/create_343.rs +++ b/sdk/block-storage/src/v3/backup/create_343.rs @@ -190,7 +190,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/backup/create_351.rs b/sdk/block-storage/src/v3/backup/create_351.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/backup/create_351.rs rename to sdk/block-storage/src/v3/backup/create_351.rs index 7f7f23467..073e3eb98 100644 --- a/openstack_sdk/src/api/block_storage/v3/backup/create_351.rs +++ b/sdk/block-storage/src/v3/backup/create_351.rs @@ -197,7 +197,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/backup/delete.rs b/sdk/block-storage/src/v3/backup/delete.rs new file mode 100644 index 000000000..e38b5ac3b --- /dev/null +++ b/sdk/block-storage/src/v3/backup/delete.rs @@ -0,0 +1,181 @@ +// 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 backup. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/backups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Backup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("backups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/backups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/backups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/export_record.rs b/sdk/block-storage/src/v3/backup/export_record.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/backup/export_record.rs rename to sdk/block-storage/src/v3/backup/export_record.rs diff --git a/sdk/block-storage/src/v3/backup/export_record/get.rs b/sdk/block-storage/src/v3/backup/export_record/get.rs new file mode 100644 index 000000000..edfebe8b3 --- /dev/null +++ b/sdk/block-storage/src/v3/backup/export_record/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Export a backup. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/backups/{id}/export_record 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<'a> RequestBuilder<'a> { + /// Add a single header to the Export_Record. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("backups/{id}/export_record", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("backup-record".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "backup-record" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/backups/{id}/export_record", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup-record": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/backups/{id}/export_record", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup-record": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/backup/find.rs b/sdk/block-storage/src/v3/backup/find.rs new file mode 100644 index 000000000..18b1fabaa --- /dev/null +++ b/sdk/block-storage/src/v3/backup/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::backup::{get as Get, list_detailed as List}; + +/// Find for backup 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate backup in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // backup 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/backup/get.rs b/sdk/block-storage/src/v3/backup/get.rs new file mode 100644 index 000000000..fe4bda360 --- /dev/null +++ b/sdk/block-storage/src/v3/backup/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about the given backup. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/backups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Backup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("backups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("backup".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "backup" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/backups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/backups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/import_record.rs b/sdk/block-storage/src/v3/backup/import_record.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/backup/import_record.rs rename to sdk/block-storage/src/v3/backup/import_record.rs diff --git a/sdk/block-storage/src/v3/backup/import_record/create.rs b/sdk/block-storage/src/v3/backup/import_record/create.rs new file mode 100644 index 000000000..1e3d0eb19 --- /dev/null +++ b/sdk/block-storage/src/v3/backup/import_record/create.rs @@ -0,0 +1,247 @@ +// 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`. + +//! Import a backup. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// An object recording volume backup metadata, including `backup_service` and +/// `backup_url`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct BackupRecord<'a> { + /// The service used to perform the backup. + #[serde()] + #[builder(setter(into))] + pub(crate) backup_service: Cow<'a, str>, + + /// An identifier string to locate the backup. + #[serde()] + #[builder(setter(into))] + pub(crate) backup_url: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An object recording volume backup metadata, including `backup_service` + /// and `backup_url`. + #[builder(setter(into))] + pub(crate) backup_record: BackupRecord<'a>, + + #[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 Import_Record. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "backups/import_record".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("backup-record", serde_json::to_value(&self.backup_record)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("backup".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .backup_record( + BackupRecordBuilder::default() + .backup_service("foo") + .backup_url("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .backup_record( + BackupRecordBuilder::default() + .backup_service("foo") + .backup_url("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "backup" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/backups/import_record".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup": {} })); + }); + + let endpoint = Request::builder() + .backup_record( + BackupRecordBuilder::default() + .backup_service("foo") + .backup_url("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/backups/import_record".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backup": {} })); + }); + + let endpoint = Request::builder() + .backup_record( + BackupRecordBuilder::default() + .backup_service("foo") + .backup_url("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/backup/list.rs b/sdk/block-storage/src/v3/backup/list.rs new file mode 100644 index 000000000..4a51dcde4 --- /dev/null +++ b/sdk/block-storage/src/v3/backup/list.rs @@ -0,0 +1,236 @@ +// 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`. + +//! Returns a summary list of backups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Whether to show count in API response or not, default is False. + #[builder(default)] + with_count: 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> { + /// Add a single header to the Backup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "backups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("with_count", self.with_count); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("backups".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "backups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/backups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/backups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/backup/list_detailed.rs b/sdk/block-storage/src/v3/backup/list_detailed.rs new file mode 100644 index 000000000..1997510e2 --- /dev/null +++ b/sdk/block-storage/src/v3/backup/list_detailed.rs @@ -0,0 +1,236 @@ +// 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`. + +//! Returns a detailed list of backups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Whether to show count in API response or not, default is False. + #[builder(default)] + with_count: 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> { + /// Add a single header to the Backup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "backups/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("with_count", self.with_count); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("backups".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "backups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/backups/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/backups/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "backups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/backup/os_force_delete.rs b/sdk/block-storage/src/v3/backup/os_force_delete.rs new file mode 100644 index 000000000..81c88702a --- /dev/null +++ b/sdk/block-storage/src/v3/backup/os_force_delete.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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// OpenAPI specifies the field as '{}'. + #[builder(setter(into))] + pub(crate) os_force_delete: Value, + + /// id parameter for /v3/backups/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Backup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("backups/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "os-force_delete", + serde_json::to_value(&self.os_force_delete)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_force_delete(json!({})) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_force_delete(json!({})) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/backups/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_force_delete(json!({})) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/backups/{id}/action", 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") + .os_force_delete(json!({})) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/backup/os_reset_status.rs b/sdk/block-storage/src/v3/backup/os_reset_status.rs new file mode 100644 index 000000000..1e4c4b35b --- /dev/null +++ b/sdk/block-storage/src/v3/backup/os_reset_status.rs @@ -0,0 +1,239 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsResetStatus<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) status: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) os_reset_status: OsResetStatus<'a>, + + /// id parameter for /v3/backups/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Backup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("backups/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "os-reset_status", + serde_json::to_value(&self.os_reset_status)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/backups/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/backups/{id}/action", 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") + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/restore.rs b/sdk/block-storage/src/v3/backup/restore.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/backup/restore.rs rename to sdk/block-storage/src/v3/backup/restore.rs diff --git a/sdk/block-storage/src/v3/backup/restore/create.rs b/sdk/block-storage/src/v3/backup/restore/create.rs new file mode 100644 index 000000000..657ed7bf5 --- /dev/null +++ b/sdk/block-storage/src/v3/backup/restore/create.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Restore an existing backup to a volume. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Restore<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_id: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) restore: Option>, + + /// id parameter for /v3/backups/{id}/restore 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<'a> RequestBuilder<'a> { + /// Add a single header to the Restore. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("backups/{id}/restore", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("restore", serde_json::to_value(&self.restore)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("restore".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .restore(RestoreBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .restore(RestoreBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "restore" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/backups/{id}/restore", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "restore": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .restore(RestoreBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/backups/{id}/restore", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "restore": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .restore(RestoreBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/backup/set_343.rs b/sdk/block-storage/src/v3/backup/set_343.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/backup/set_343.rs rename to sdk/block-storage/src/v3/backup/set_343.rs index 1cbf44d1a..6b6200869 100644 --- a/openstack_sdk/src/api/block_storage/v3/backup/set_343.rs +++ b/sdk/block-storage/src/v3/backup/set_343.rs @@ -156,7 +156,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/backup/set_39.rs b/sdk/block-storage/src/v3/backup/set_39.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/backup/set_39.rs rename to sdk/block-storage/src/v3/backup/set_39.rs index 97a4b1632..c559cd211 100644 --- a/openstack_sdk/src/api/block_storage/v3/backup/set_39.rs +++ b/sdk/block-storage/src/v3/backup/set_39.rs @@ -136,7 +136,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/capability.rs b/sdk/block-storage/src/v3/capability.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/capability.rs rename to sdk/block-storage/src/v3/capability.rs diff --git a/sdk/block-storage/src/v3/capability/get.rs b/sdk/block-storage/src/v3/capability/get.rs new file mode 100644 index 000000000..e6dd0d074 --- /dev/null +++ b/sdk/block-storage/src/v3/capability/get.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Return capabilities list of given backend. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/capabilities/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Capability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("capabilities/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/capabilities/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/capabilities/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot.rs b/sdk/block-storage/src/v3/cgsnapshot.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/cgsnapshot.rs rename to sdk/block-storage/src/v3/cgsnapshot.rs diff --git a/sdk/block-storage/src/v3/cgsnapshot/create.rs b/sdk/block-storage/src/v3/cgsnapshot/create.rs new file mode 100644 index 000000000..79e300350 --- /dev/null +++ b/sdk/block-storage/src/v3/cgsnapshot/create.rs @@ -0,0 +1,282 @@ +// 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 cgsnapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A consistency group snapshot object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Cgsnapshot<'a> { + /// The UUID of the consistency group. + #[serde()] + #[builder(setter(into))] + pub(crate) consistencygroup_id: Cow<'a, str>, + + /// The consistency group snapshot description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The name of the snapshot. Default is `None`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> CgsnapshotBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A consistency group snapshot object. + #[builder(setter(into))] + pub(crate) cgsnapshot: Cgsnapshot<'a>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Cgsnapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "cgsnapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("cgsnapshot", serde_json::to_value(&self.cgsnapshot)?); + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .cgsnapshot( + CgsnapshotBuilder::default() + .consistencygroup_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .cgsnapshot( + CgsnapshotBuilder::default() + .consistencygroup_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/cgsnapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .cgsnapshot( + CgsnapshotBuilder::default() + .consistencygroup_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/cgsnapshots".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() + .cgsnapshot( + CgsnapshotBuilder::default() + .consistencygroup_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/cgsnapshot/delete.rs b/sdk/block-storage/src/v3/cgsnapshot/delete.rs new file mode 100644 index 000000000..b12ff40b2 --- /dev/null +++ b/sdk/block-storage/src/v3/cgsnapshot/delete.rs @@ -0,0 +1,181 @@ +// 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 cgsnapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/cgsnapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Cgsnapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("cgsnapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/cgsnapshots/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/cgsnapshots/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/cgsnapshot/get.rs b/sdk/block-storage/src/v3/cgsnapshot/get.rs new file mode 100644 index 000000000..932a86459 --- /dev/null +++ b/sdk/block-storage/src/v3/cgsnapshot/get.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Return data about the given cgsnapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/cgsnapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Cgsnapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("cgsnapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/cgsnapshots/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/cgsnapshots/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/cgsnapshot/list.rs b/sdk/block-storage/src/v3/cgsnapshot/list.rs new file mode 100644 index 000000000..0ef40edaf --- /dev/null +++ b/sdk/block-storage/src/v3/cgsnapshot/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`. + +//! Returns a summary list of cgsnapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Cgsnapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "cgsnapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/cgsnapshot/list_detailed.rs b/sdk/block-storage/src/v3/cgsnapshot/list_detailed.rs new file mode 100644 index 000000000..ae3e4fb07 --- /dev/null +++ b/sdk/block-storage/src/v3/cgsnapshot/list_detailed.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`. + +//! Returns a detailed list of cgsnapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Cgsnapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "cgsnapshots/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots/detail".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots/detail".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/cluster.rs b/sdk/block-storage/src/v3/cluster.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/cluster.rs rename to sdk/block-storage/src/v3/cluster.rs diff --git a/sdk/block-storage/src/v3/cluster/get.rs b/sdk/block-storage/src/v3/cluster/get.rs new file mode 100644 index 000000000..594a5fe5e --- /dev/null +++ b/sdk/block-storage/src/v3/cluster/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data for a given cluster name with optional binary. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/clusters/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("cluster".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "cluster" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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!({ "cluster": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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!({ "cluster": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/cluster/list.rs b/sdk/block-storage/src/v3/cluster/list.rs new file mode 100644 index 000000000..9daa3e74a --- /dev/null +++ b/sdk/block-storage/src/v3/cluster/list.rs @@ -0,0 +1,220 @@ +// 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`. + +//! Return a non detailed list of all existing clusters. +//! +//! Filter by is_up, disabled, num_hosts, and num_down_hosts. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filter the cluster list result by binary name of the clustered + /// services. One of cinder-api, cinder-scheduler, cinder-volume or + /// cinder-backup. + #[builder(default, setter(into))] + binary: Option>, + + /// Filter the cluster list result by status. + #[builder(default)] + disabled: Option, + + /// Filter the cluster list result by state. + #[builder(default)] + is_up: Option, + + /// Filter the cluster list result by cluster name. + #[builder(default, setter(into))] + name: Option>, + + /// Filter the cluster list result by number of down hosts. + #[builder(default)] + num_down_hosts: Option, + + /// Filter the cluster list result by number of hosts. + #[builder(default)] + num_hosts: Option, + + /// Filter the cluster list result by replication status. + #[builder(default, setter(into))] + replication_stats: 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> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'_> { + let mut params = QueryParams::default(); + params.push_opt("binary", self.binary.as_ref()); + params.push_opt("disabled", self.disabled); + params.push_opt("is_up", self.is_up); + params.push_opt("name", self.name.as_ref()); + params.push_opt("num_down_hosts", self.num_down_hosts); + params.push_opt("num_hosts", self.num_hosts); + params.push_opt("replication_stats", self.replication_stats.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "clusters" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/cluster/list_detailed.rs b/sdk/block-storage/src/v3/cluster/list_detailed.rs new file mode 100644 index 000000000..3188d6796 --- /dev/null +++ b/sdk/block-storage/src/v3/cluster/list_detailed.rs @@ -0,0 +1,230 @@ +// 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`. + +//! Return a detailed list of all existing clusters. +//! +//! Filter by is_up, disabled, num_hosts, and num_down_hosts. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of active storage backend. Only in cinder-volume service. + #[builder(default, setter(into))] + active_backend_id: Option>, + + /// Filter the cluster list result by binary name of the clustered + /// services. One of cinder-api, cinder-scheduler, cinder-volume or + /// cinder-backup. + #[builder(default, setter(into))] + binary: Option>, + + /// Filter the cluster list result by status. + #[builder(default)] + disabled: Option, + + /// Whether the cluster is frozen or not. + #[builder(default)] + frozen: Option, + + /// Filter the cluster list result by state. + #[builder(default)] + is_up: Option, + + /// Filter the cluster list result by cluster name. + #[builder(default, setter(into))] + name: Option>, + + /// Filter the cluster list result by number of down hosts. + #[builder(default)] + num_down_hosts: Option, + + /// Filter the cluster list result by number of hosts. + #[builder(default)] + num_hosts: Option, + + /// Filter the cluster list result by replication status. + #[builder(default, setter(into))] + replication_stats: 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> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("active_backend_id", self.active_backend_id.as_ref()); + params.push_opt("binary", self.binary.as_ref()); + params.push_opt("disabled", self.disabled); + params.push_opt("frozen", self.frozen); + params.push_opt("is_up", self.is_up); + params.push_opt("name", self.name.as_ref()); + params.push_opt("num_down_hosts", self.num_down_hosts); + params.push_opt("num_hosts", self.num_hosts); + params.push_opt("replication_stats", self.replication_stats.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "clusters" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clusters/detail".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/clusters/detail".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup.rs b/sdk/block-storage/src/v3/consistencygroup.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/consistencygroup.rs rename to sdk/block-storage/src/v3/consistencygroup.rs diff --git a/sdk/block-storage/src/v3/consistencygroup/create.rs b/sdk/block-storage/src/v3/consistencygroup/create.rs new file mode 100644 index 000000000..b7208bc94 --- /dev/null +++ b/sdk/block-storage/src/v3/consistencygroup/create.rs @@ -0,0 +1,290 @@ +// 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 consistency group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A consistency group. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Consistencygroup<'a> { + /// OpenAPI specifies the field as '{}'. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option, + + /// The consistency group description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The consistency group name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// OpenAPI specifies the field as '{}'. + #[serde()] + #[builder(setter(into))] + pub(crate) volume_types: Value, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> ConsistencygroupBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A consistency group. + #[builder(setter(into))] + pub(crate) consistencygroup: Consistencygroup<'a>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Consistencygroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "consistencygroups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "consistencygroup", + serde_json::to_value(&self.consistencygroup)?, + ); + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .consistencygroup( + ConsistencygroupBuilder::default() + .volume_types(json!({})) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .consistencygroup( + ConsistencygroupBuilder::default() + .volume_types(json!({})) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consistencygroup( + ConsistencygroupBuilder::default() + .volume_types(json!({})) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups".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() + .consistencygroup( + ConsistencygroupBuilder::default() + .volume_types(json!({})) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src.rs b/sdk/block-storage/src/v3/consistencygroup/create_from_src.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src.rs rename to sdk/block-storage/src/v3/consistencygroup/create_from_src.rs diff --git a/sdk/block-storage/src/v3/consistencygroup/create_from_src/create.rs b/sdk/block-storage/src/v3/consistencygroup/create_from_src/create.rs new file mode 100644 index 000000000..0ed190cba --- /dev/null +++ b/sdk/block-storage/src/v3/consistencygroup/create_from_src/create.rs @@ -0,0 +1,277 @@ +// 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 consistency group from a source. +//! +//! The source can be a CG snapshot or a CG. Note that this does not require +//! volume_types as the "create" API above. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// The consistency group from source object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ConsistencygroupFromSrc<'a> { + /// The UUID of the consistency group snapshot. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cgsnapshot_id: Option>, + + /// The consistency group description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The name of the object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The UUID of the source consistency group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) source_cgid: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> ConsistencygroupFromSrcBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The consistency group from source object. + #[builder(setter(into))] + pub(crate) consistencygroup_from_src: ConsistencygroupFromSrc<'a>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Create_From_Src. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "consistencygroups/create_from_src".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "consistencygroup-from-src", + serde_json::to_value(&self.consistencygroup_from_src)?, + ); + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .consistencygroup_from_src( + ConsistencygroupFromSrcBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .consistencygroup_from_src( + ConsistencygroupFromSrcBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups/create_from_src".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consistencygroup_from_src(ConsistencygroupFromSrcBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups/create_from_src".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() + .consistencygroup_from_src(ConsistencygroupFromSrcBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete.rs b/sdk/block-storage/src/v3/consistencygroup/delete.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/consistencygroup/delete.rs rename to sdk/block-storage/src/v3/consistencygroup/delete.rs diff --git a/sdk/block-storage/src/v3/consistencygroup/delete/create.rs b/sdk/block-storage/src/v3/consistencygroup/delete/create.rs new file mode 100644 index 000000000..7dde23ee1 --- /dev/null +++ b/sdk/block-storage/src/v3/consistencygroup/delete/create.rs @@ -0,0 +1,181 @@ +// 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 consistency group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/consistencygroups/{id}/delete 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<'a> RequestBuilder<'a> { + /// Add a single header to the Delete. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("consistencygroups/{id}/delete", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/consistencygroups/{id}/delete", 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/consistencygroups/{id}/delete", 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/consistencygroup/get.rs b/sdk/block-storage/src/v3/consistencygroup/get.rs new file mode 100644 index 000000000..180f8079e --- /dev/null +++ b/sdk/block-storage/src/v3/consistencygroup/get.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Return data about the given consistency group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/consistencygroups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Consistencygroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("consistencygroups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/consistencygroups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/consistencygroups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/consistencygroup/list.rs b/sdk/block-storage/src/v3/consistencygroup/list.rs new file mode 100644 index 000000000..17698ba7f --- /dev/null +++ b/sdk/block-storage/src/v3/consistencygroup/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`. + +//! Returns a summary list of consistency groups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Consistencygroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "consistencygroups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/consistencygroup/list_detailed.rs b/sdk/block-storage/src/v3/consistencygroup/list_detailed.rs new file mode 100644 index 000000000..f1926938b --- /dev/null +++ b/sdk/block-storage/src/v3/consistencygroup/list_detailed.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`. + +//! Returns a detailed list of consistency groups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Consistencygroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "consistencygroups/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups/detail".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups/detail".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/consistencygroup/set.rs b/sdk/block-storage/src/v3/consistencygroup/set.rs new file mode 100644 index 000000000..c0722da18 --- /dev/null +++ b/sdk/block-storage/src/v3/consistencygroup/set.rs @@ -0,0 +1,284 @@ +// 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 the consistency group. +//! +//! Expected format of the input parameter 'body': +//! +//! ```text +//! { +//! "consistencygroup": +//! { +//! "name": "my_cg", +//! "description": "My consistency group", +//! "add_volumes": "volume-uuid-1,volume-uuid-2,...", +//! "remove_volumes": "volume-uuid-8,volume-uuid-9,..." +//! } +//! } +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Consistencygroup<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) add_volumes: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remove_volumes: Option>>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> ConsistencygroupBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) consistencygroup: Consistencygroup<'a>, + + /// id parameter for /v3/consistencygroups/{id}/update API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Consistencygroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("consistencygroups/{id}/update", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "consistencygroup", + serde_json::to_value(&self.consistencygroup)?, + ); + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/consistencygroups/{id}/update", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/consistencygroups/{id}/update", 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") + .consistencygroup(ConsistencygroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/default_type.rs b/sdk/block-storage/src/v3/default_type.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/default_type.rs rename to sdk/block-storage/src/v3/default_type.rs diff --git a/sdk/block-storage/src/v3/default_type/delete.rs b/sdk/block-storage/src/v3/default_type/delete.rs new file mode 100644 index 000000000..5c6ebc5a9 --- /dev/null +++ b/sdk/block-storage/src/v3/default_type/delete.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Unset a default volume type for a project. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/default-types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Default_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("default-types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/default-types/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/default-types/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/default_type/get.rs b/sdk/block-storage/src/v3/default_type/get.rs new file mode 100644 index 000000000..6f80d5721 --- /dev/null +++ b/sdk/block-storage/src/v3/default_type/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return detail of a default type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/default-types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Default_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("default-types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("default_type".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "default_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/default-types/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_type": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/default-types/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/default_type/list.rs b/sdk/block-storage/src/v3/default_type/list.rs new file mode 100644 index 000000000..4ba4a0f58 --- /dev/null +++ b/sdk/block-storage/src/v3/default_type/list.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`. + +//! Return a list of default types. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Default_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "default-types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("default_types".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "default_types" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/default-types".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_types": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/default-types".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_types": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/default_type/set_362.rs b/sdk/block-storage/src/v3/default_type/set_362.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/default_type/set_362.rs rename to sdk/block-storage/src/v3/default_type/set_362.rs index 083cd034f..fe00eaab3 100644 --- a/openstack_sdk/src/api/block_storage/v3/default_type/set_362.rs +++ b/sdk/block-storage/src/v3/default_type/set_362.rs @@ -132,7 +132,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/extension.rs b/sdk/block-storage/src/v3/extension.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/extension.rs rename to sdk/block-storage/src/v3/extension.rs diff --git a/sdk/block-storage/src/v3/extension/list.rs b/sdk/block-storage/src/v3/extension/list.rs new file mode 100644 index 000000000..4907eb51d --- /dev/null +++ b/sdk/block-storage/src/v3/extension/list.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Extension. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "extensions".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("extensions".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "extensions" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/extensions".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extensions": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/extensions".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extensions": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/group.rs b/sdk/block-storage/src/v3/group.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/group.rs rename to sdk/block-storage/src/v3/group.rs diff --git a/sdk/block-storage/src/v3/group/create_313.rs b/sdk/block-storage/src/v3/group/create_313.rs new file mode 100644 index 000000000..b64dc215c --- /dev/null +++ b/sdk/block-storage/src/v3/group/create_313.rs @@ -0,0 +1,264 @@ +// 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 group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A group object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Group<'a> { + /// The name of the availability zone. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// The group description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The group type ID. + #[serde()] + #[builder(setter(into))] + pub(crate) group_type: Cow<'a, str>, + + /// The group name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The list of volume types. In an environment with multiple-storage back + /// ends, the scheduler determines where to send the volume based on the + /// volume type. For information about how to use volume types to create + /// multiple- storage back ends, see + /// [Configure multiple-storage back ends](https://docs.openstack.org/cinder/latest/admin/blockstorage-multi-backend.html). + #[serde()] + #[builder(setter(into))] + pub(crate) volume_types: Vec>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A group object. + #[builder(setter(into))] + pub(crate) group: Group<'a>, + + #[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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("group", serde_json::to_value(&self.group)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group".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(3, 13)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .group( + GroupBuilder::default() + .group_type("foo") + .volume_types(Vec::from(["foo".into()])) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .group( + GroupBuilder::default() + .group_type("foo") + .volume_types(Vec::from(["foo".into()])) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .group( + GroupBuilder::default() + .group_type("foo") + .volume_types(Vec::from(["foo".into()])) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .group( + GroupBuilder::default() + .group_type("foo") + .volume_types(Vec::from(["foo".into()])) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/group/create_from_src_314.rs b/sdk/block-storage/src/v3/group/create_from_src_314.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group/create_from_src_314.rs rename to sdk/block-storage/src/v3/group/create_from_src_314.rs index e244042fd..3832a40b7 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/create_from_src_314.rs +++ b/sdk/block-storage/src/v3/group/create_from_src_314.rs @@ -141,7 +141,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group/delete_313.rs b/sdk/block-storage/src/v3/group/delete_313.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/group/delete_313.rs rename to sdk/block-storage/src/v3/group/delete_313.rs index c59c1def1..dd07130d3 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/delete_313.rs +++ b/sdk/block-storage/src/v3/group/delete_313.rs @@ -125,7 +125,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group/disable_replication_338.rs b/sdk/block-storage/src/v3/group/disable_replication_338.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group/disable_replication_338.rs rename to sdk/block-storage/src/v3/group/disable_replication_338.rs index 895ab3431..a9deab128 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/disable_replication_338.rs +++ b/sdk/block-storage/src/v3/group/disable_replication_338.rs @@ -132,7 +132,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group/enable_replication_338.rs b/sdk/block-storage/src/v3/group/enable_replication_338.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group/enable_replication_338.rs rename to sdk/block-storage/src/v3/group/enable_replication_338.rs index f9b8ba213..55b3dee45 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/enable_replication_338.rs +++ b/sdk/block-storage/src/v3/group/enable_replication_338.rs @@ -132,7 +132,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group/failover_replication_338.rs b/sdk/block-storage/src/v3/group/failover_replication_338.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group/failover_replication_338.rs rename to sdk/block-storage/src/v3/group/failover_replication_338.rs index 061692e04..c64de1ebc 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/failover_replication_338.rs +++ b/sdk/block-storage/src/v3/group/failover_replication_338.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/group/find.rs b/sdk/block-storage/src/v3/group/find.rs new file mode 100644 index 000000000..7d964cefe --- /dev/null +++ b/sdk/block-storage/src/v3/group/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::group::{get as Get, list_detailed as List}; + +/// Find for group 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate group in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // group 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/group/get.rs b/sdk/block-storage/src/v3/group/get.rs new file mode 100644 index 000000000..ecc46a1c1 --- /dev/null +++ b/sdk/block-storage/src/v3/group/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about the given group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group/list.rs b/sdk/block-storage/src/v3/group/list.rs new file mode 100644 index 000000000..7d260097f --- /dev/null +++ b/sdk/block-storage/src/v3/group/list.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Returns a summary list of groups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("groups".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group/list_detailed.rs b/sdk/block-storage/src/v3/group/list_detailed.rs new file mode 100644 index 000000000..698980152 --- /dev/null +++ b/sdk/block-storage/src/v3/group/list_detailed.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Returns a detailed list of groups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "groups/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("groups".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/groups/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/groups/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/group/list_replication_targets_338.rs b/sdk/block-storage/src/v3/group/list_replication_targets_338.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group/list_replication_targets_338.rs rename to sdk/block-storage/src/v3/group/list_replication_targets_338.rs index 75b355713..4dfaa771c 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/list_replication_targets_338.rs +++ b/sdk/block-storage/src/v3/group/list_replication_targets_338.rs @@ -132,7 +132,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group/reset_status_320.rs b/sdk/block-storage/src/v3/group/reset_status_320.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/group/reset_status_320.rs rename to sdk/block-storage/src/v3/group/reset_status_320.rs index b5d821736..ba347db82 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/reset_status_320.rs +++ b/sdk/block-storage/src/v3/group/reset_status_320.rs @@ -126,7 +126,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group/set_313.rs b/sdk/block-storage/src/v3/group/set_313.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group/set_313.rs rename to sdk/block-storage/src/v3/group/set_313.rs index 47947dc6a..4e3cd29e0 100644 --- a/openstack_sdk/src/api/block_storage/v3/group/set_313.rs +++ b/sdk/block-storage/src/v3/group/set_313.rs @@ -158,7 +158,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group_snapshot.rs b/sdk/block-storage/src/v3/group_snapshot.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/group_snapshot.rs rename to sdk/block-storage/src/v3/group_snapshot.rs diff --git a/openstack_sdk/src/api/block_storage/v3/group_snapshot/create_314.rs b/sdk/block-storage/src/v3/group_snapshot/create_314.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group_snapshot/create_314.rs rename to sdk/block-storage/src/v3/group_snapshot/create_314.rs index 9aed95819..0a3abdf40 100644 --- a/openstack_sdk/src/api/block_storage/v3/group_snapshot/create_314.rs +++ b/sdk/block-storage/src/v3/group_snapshot/create_314.rs @@ -144,7 +144,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/group_snapshot/delete.rs b/sdk/block-storage/src/v3/group_snapshot/delete.rs new file mode 100644 index 000000000..ffba01447 --- /dev/null +++ b/sdk/block-storage/src/v3/group_snapshot/delete.rs @@ -0,0 +1,181 @@ +// 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 group_snapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/group_snapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("group_snapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/group_snapshots/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/group_snapshots/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_snapshot/find.rs b/sdk/block-storage/src/v3/group_snapshot/find.rs new file mode 100644 index 000000000..427d5b611 --- /dev/null +++ b/sdk/block-storage/src/v3/group_snapshot/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::group_snapshot::{get as Get, list_detailed as List}; + +/// Find for group_snapshot 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate group_snapshot in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // group_snapshot 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/group_snapshot/get.rs b/sdk/block-storage/src/v3/group_snapshot/get.rs new file mode 100644 index 000000000..87c40bbcc --- /dev/null +++ b/sdk/block-storage/src/v3/group_snapshot/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about the given group_snapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/group_snapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("group_snapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_snapshot".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group_snapshot" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/group_snapshots/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_snapshot": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/group_snapshots/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_snapshot": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_snapshot/list.rs b/sdk/block-storage/src/v3/group_snapshot/list.rs new file mode 100644 index 000000000..4c596db76 --- /dev/null +++ b/sdk/block-storage/src/v3/group_snapshot/list.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Returns a summary list of group_snapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Group_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "group_snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_snapshots".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group_snapshots" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/group_snapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_snapshots": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/group_snapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_snapshots": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_snapshot/list_detailed.rs b/sdk/block-storage/src/v3/group_snapshot/list_detailed.rs new file mode 100644 index 000000000..cdaaf178a --- /dev/null +++ b/sdk/block-storage/src/v3/group_snapshot/list_detailed.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Returns a detailed list of group_snapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Group_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "group_snapshots/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_snapshots".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group_snapshots" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/group_snapshots/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_snapshots": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/group_snapshots/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_snapshots": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/group_snapshot/reset_status_319.rs b/sdk/block-storage/src/v3/group_snapshot/reset_status_319.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/group_snapshot/reset_status_319.rs rename to sdk/block-storage/src/v3/group_snapshot/reset_status_319.rs index 14db1cfaf..3d9752563 100644 --- a/openstack_sdk/src/api/block_storage/v3/group_snapshot/reset_status_319.rs +++ b/sdk/block-storage/src/v3/group_snapshot/reset_status_319.rs @@ -130,7 +130,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/group_type.rs b/sdk/block-storage/src/v3/group_type.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/group_type.rs rename to sdk/block-storage/src/v3/group_type.rs diff --git a/sdk/block-storage/src/v3/group_type/create_311.rs b/sdk/block-storage/src/v3/group_type/create_311.rs new file mode 100644 index 000000000..7ed5d2f13 --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/create_311.rs @@ -0,0 +1,252 @@ +// 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`. + +//! Creates a new group type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `group_type` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct GroupType<'a> { + /// The group type description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// A set of key and value pairs that contains the specifications for a + /// group type. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_group_specs"))] + pub(crate) group_specs: Option, Cow<'a, str>>>>, + + /// Whether the group type is publicly visible. See + /// [valid boolean values](#valid-boolean-values) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_public: Option, + + /// The group type name. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +impl<'a> GroupTypeBuilder<'a> { + /// A set of key and value pairs that contains the specifications for a + /// group type. + pub fn group_specs(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.group_specs + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `group_type` object. + #[builder(setter(into))] + pub(crate) group_type: GroupType<'a>, + + #[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 Group_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "group_types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("group_type", serde_json::to_value(&self.group_type)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_type".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(3, 11)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "group_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/group_types".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_type": {} })); + }); + + let endpoint = Request::builder() + .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/group_types".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_type": {} })); + }); + + let endpoint = Request::builder() + .group_type(GroupTypeBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/delete.rs b/sdk/block-storage/src/v3/group_type/delete.rs new file mode 100644 index 000000000..ede91b14a --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/delete.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Deletes an existing group type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/group_types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("group_types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/group_types/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/group_types/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/find.rs b/sdk/block-storage/src/v3/group_type/find.rs new file mode 100644 index 000000000..10dcb099f --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::group_type::{get as Get, list as List}; + +/// Find for group_type 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate group_type in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // group_type 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/group_type/get.rs b/sdk/block-storage/src/v3/group_type/get.rs new file mode 100644 index 000000000..54fc83a5d --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return a single group type item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/group_types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("group_types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_type".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/group_types/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_type": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/group_types/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/group_type/group_spec.rs b/sdk/block-storage/src/v3/group_type/group_spec.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/group_type/group_spec.rs rename to sdk/block-storage/src/v3/group_type/group_spec.rs diff --git a/sdk/block-storage/src/v3/group_type/group_spec/create_311.rs b/sdk/block-storage/src/v3/group_type/group_spec/create_311.rs new file mode 100644 index 000000000..066c9b22e --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/group_spec/create_311.rs @@ -0,0 +1,250 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A set of key and value pairs that contains the specifications for a + /// group type. + #[builder(private, setter(into, name = "_group_specs"))] + pub(crate) group_specs: BTreeMap, Option>>, + + /// group_type_id parameter for + /// /v3/group_types/{group_type_id}/group_specs/{id} API + #[builder(default, setter(into))] + group_type_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> { + /// A set of key and value pairs that contains the specifications for a + /// group type. + pub fn group_specs(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>>, + { + self.group_specs + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Group_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "group_types/{group_type_id}/group_specs", + group_type_id = self.group_type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("group_specs", serde_json::to_value(&self.group_specs)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_specs".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(3, 11)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .group_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))) + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .group_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))) + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "group_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/group_types/{group_type_id}/group_specs", + group_type_id = "group_type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_specs": {} })); + }); + + let endpoint = Request::builder() + .group_type_id("group_type_id") + .group_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/group_types/{group_type_id}/group_specs", + group_type_id = "group_type_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_specs": {} })); + }); + + let endpoint = Request::builder() + .group_type_id("group_type_id") + .group_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/group_spec/delete.rs b/sdk/block-storage/src/v3/group_type/group_spec/delete.rs new file mode 100644 index 000000000..d71e898b0 --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/group_spec/delete.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`. + +//! Deletes an existing group spec. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_type_id parameter for + /// /v3/group_types/{group_type_id}/group_specs/{id} API + #[builder(default, setter(into))] + group_type_id: Cow<'a, str>, + + /// id parameter for /v3/group_types/{group_type_id}/group_specs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "group_types/{group_type_id}/group_specs/{id}", + group_type_id = self.group_type_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/group_types/{group_type_id}/group_specs/{id}", + group_type_id = "group_type_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_type_id("group_type_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/group_types/{group_type_id}/group_specs/{id}", + group_type_id = "group_type_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() + .group_type_id("group_type_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/group_spec/get.rs b/sdk/block-storage/src/v3/group_type/group_spec/get.rs new file mode 100644 index 000000000..4d486f653 --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/group_spec/get.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`. + +//! Return a single extra spec item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_type_id parameter for + /// /v3/group_types/{group_type_id}/group_specs/{id} API + #[builder(default, setter(into))] + group_type_id: Cow<'a, str>, + + /// id parameter for /v3/group_types/{group_type_id}/group_specs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "group_types/{group_type_id}/group_specs/{id}", + group_type_id = self.group_type_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/group_types/{group_type_id}/group_specs/{id}", + group_type_id = "group_type_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_type_id("group_type_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/group_types/{group_type_id}/group_specs/{id}", + group_type_id = "group_type_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() + .group_type_id("group_type_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/group_spec/list.rs b/sdk/block-storage/src/v3/group_type/group_spec/list.rs new file mode 100644 index 000000000..981d55e71 --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/group_spec/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`. + +//! Returns the list of group specs for a given group type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_type_id parameter for + /// /v3/group_types/{group_type_id}/group_specs/{id} API + #[builder(default, setter(into))] + group_type_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 Group_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "group_types/{group_type_id}/group_specs", + group_type_id = self.group_type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_specs".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/group_types/{group_type_id}/group_specs", + group_type_id = "group_type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_specs": {} })); + }); + + let endpoint = Request::builder() + .group_type_id("group_type_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/group_types/{group_type_id}/group_specs", + group_type_id = "group_type_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_specs": {} })); + }); + + let endpoint = Request::builder() + .group_type_id("group_type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/group_spec/set_311.rs b/sdk/block-storage/src/v3/group_type/group_spec/set_311.rs new file mode 100644 index 000000000..b7361836c --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/group_spec/set_311.rs @@ -0,0 +1,227 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_type_id parameter for + /// /v3/group_types/{group_type_id}/group_specs/{id} API + #[builder(default, setter(into))] + group_type_id: Cow<'a, str>, + + /// id parameter for /v3/group_types/{group_type_id}/group_specs/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, 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 Group_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>>, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "group_types/{group_type_id}/group_specs/{id}", + group_type_id = self.group_type_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), serde_json::Value::from(val.clone())); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 11)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/group_types/{group_type_id}/group_specs/{id}", + group_type_id = "group_type_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_type_id("group_type_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/group_types/{group_type_id}/group_specs/{id}", + group_type_id = "group_type_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() + .group_type_id("group_type_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/list.rs b/sdk/block-storage/src/v3/group_type/list.rs new file mode 100644 index 000000000..a514596a3 --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/list.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Returns the list of group types. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Group_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "group_types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_types".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group_types" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/group_types".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_types": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/group_types".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_types": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/group_type/set_311.rs b/sdk/block-storage/src/v3/group_type/set_311.rs new file mode 100644 index 000000000..5f9ccc9b9 --- /dev/null +++ b/sdk/block-storage/src/v3/group_type/set_311.rs @@ -0,0 +1,225 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct GroupType<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_public: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) group_type: GroupType<'a>, + + /// id parameter for /v3/group_types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Group_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("group_types/{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("group_type", serde_json::to_value(&self.group_type)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("group_type".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(3, 11)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .group_type(GroupTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .group_type(GroupTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "group_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/group_types/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .group_type(GroupTypeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/group_types/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .group_type(GroupTypeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/host.rs b/sdk/block-storage/src/v3/host.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/host.rs rename to sdk/block-storage/src/v3/host.rs diff --git a/sdk/block-storage/src/v3/host/get.rs b/sdk/block-storage/src/v3/host/get.rs new file mode 100644 index 000000000..f41665362 --- /dev/null +++ b/sdk/block-storage/src/v3/host/get.rs @@ -0,0 +1,184 @@ +// 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 Host Details for a project +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-hosts/{id} API + #[builder(default, setter(into))] + host_name: 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 Host. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-hosts/{host_name}", host_name = self.host_name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("host".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "host" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hosts/{host_name}", host_name = "host_name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "host": {} })); + }); + + let endpoint = Request::builder().host_name("host_name").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hosts/{host_name}", host_name = "host_name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "host": {} })); + }); + + let endpoint = Request::builder() + .host_name("host_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/host/list.rs b/sdk/block-storage/src/v3/host/list.rs new file mode 100644 index 000000000..09c60437d --- /dev/null +++ b/sdk/block-storage/src/v3/host/list.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`. + +//! List all hosts for a project +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Host. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-hosts".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("hosts".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "hosts" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hosts".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hosts": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hosts".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hosts": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/limit.rs b/sdk/block-storage/src/v3/limit.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/limit.rs rename to sdk/block-storage/src/v3/limit.rs diff --git a/sdk/block-storage/src/v3/limit/list.rs b/sdk/block-storage/src/v3/limit/list.rs new file mode 100644 index 000000000..ce92f247c --- /dev/null +++ b/sdk/block-storage/src/v3/limit/list.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`. + +//! Return all global and rate limit information. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "limits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("limits".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "limits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot.rs b/sdk/block-storage/src/v3/manageable_snapshot.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/manageable_snapshot.rs rename to sdk/block-storage/src/v3/manageable_snapshot.rs diff --git a/sdk/block-storage/src/v3/manageable_snapshot/create.rs b/sdk/block-storage/src/v3/manageable_snapshot/create.rs new file mode 100644 index 000000000..d5990ca69 --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_snapshot/create.rs @@ -0,0 +1,322 @@ +// 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`. + +//! Instruct Cinder to manage a storage snapshot object. +//! +//! Manages an existing backend storage snapshot object (e.g. a Linux logical +//! volume or a SAN disk) by creating the Cinder objects required to manage it, +//! and possibly renaming the backend storage snapshot object (driver +//! dependent). +//! +//! From an API perspective, this operation behaves very much like a snapshot +//! creation operation. +//! +//! Required HTTP Body: +//! +//! ```text +//! { +//! "snapshot": +//! { +//! "volume_id": "", +//! "ref": +//! "" +//! } +//! } +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_snapshot +//! method to find out the accepted format of 'ref'. For example,in LVM driver, +//! it will be the logic volume name of snapshot which you want to manage. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'volume_id' element refers to a cinder +//! volume that could not be found. +//! +//! The snapshot will later enter the error state if it is discovered that +//! 'ref' is bad. +//! +//! Optional elements to 'snapshot' are: +//! +//! ```text +//! name A name for the new snapshot. +//! description A description for the new snapshot. +//! metadata Key/value pairs to be associated with the new snapshot. +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `snapshot` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Snapshot<'a> { + /// A description for the snapshot. Default is `None`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// One or more metadata key and value pairs for the snapshot. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + /// The name of the snapshot. Default is `None`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Option, + + /// The UUID of the volume. + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +impl<'a> SnapshotBuilder<'a> { + /// One or more metadata key and value pairs for the snapshot. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `snapshot` object. + #[builder(setter(into))] + pub(crate) snapshot: Snapshot<'a>, + + #[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 Manageable_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("snapshot", serde_json::to_value(&self.snapshot)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("snapshot".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "snapshot" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_snapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_snapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/manageable_snapshot/get.rs b/sdk/block-storage/src/v3/manageable_snapshot/get.rs new file mode 100644 index 000000000..c2b8d72c4 --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_snapshot/get.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Returns a summary list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Manageable_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/manageable_snapshot/list_detailed.rs b/sdk/block-storage/src/v3/manageable_snapshot/list_detailed.rs new file mode 100644 index 000000000..e55cb7090 --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_snapshot/list_detailed.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Returns a detailed list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Manageable_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_snapshots/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots/detail".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots/detail".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume.rs b/sdk/block-storage/src/v3/manageable_volume.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/manageable_volume.rs rename to sdk/block-storage/src/v3/manageable_volume.rs diff --git a/sdk/block-storage/src/v3/manageable_volume/create.rs b/sdk/block-storage/src/v3/manageable_volume/create.rs new file mode 100644 index 000000000..362301542 --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_volume/create.rs @@ -0,0 +1,324 @@ +// 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`. + +//! Instruct Cinder to manage a storage object. +//! +//! Manages an existing backend storage object (e.g. a Linux logical volume or +//! a SAN disk) by creating the Cinder objects required to manage it, and +//! possibly renaming the backend storage object (driver dependent) +//! +//! From an API perspective, this operation behaves very much like a volume +//! creation operation, except that properties such as image, snapshot and +//! volume references don't make sense, because we are taking an existing +//! storage object into Cinder management. +//! +//! Required HTTP Body: +//! +//! ```text +//! { +//! "volume": { +//! "host": "", +//! "cluster": "", +//! "ref": "" +//! } +//! } +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_volume +//! method to find out the accepted format of 'ref'. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'host' element refers to a cinder host +//! that is not registered. +//! +//! The volume will later enter the error state if it is discovered that 'ref' +//! is bad. +//! +//! Optional elements to 'volume' are: +//! +//! ```text +//! name A name for the new volume. +//! description A description for the new volume. +//! volume_type ID or name of a volume type to associate with +//! the new Cinder volume. Does not necessarily +//! guarantee that the managed volume will have the +//! properties described in the volume_type. The +//! driver may choose to fail if it identifies that +//! the specified volume_type is not compatible with +//! the backend storage object. +//! metadata Key/value pairs to be associated with the new +//! volume. +//! availability_zone The availability zone to associate with the new +//! volume. +//! bootable If set to True, marks the volume as bootable. +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `volume` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// Enables or disables the bootable attribute. You can boot an instance + /// from a bootable volume. See + /// [valid boolean values](#valid-boolean-values) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bootable: Option, + + /// The volume description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The OpenStack Block Storage host where the existing resource resides. + /// Optional only if cluster field is provided. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>>, + + /// One or more metadata key and value pairs to be associated with the new + /// volume. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Value, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, +} + +impl<'a> VolumeBuilder<'a> { + /// One or more metadata key and value pairs to be associated with the new + /// volume. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `volume` object. + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[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 Manageable_Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + use openstack_sdk_core::test::client::FakeOpenStackClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".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() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/manageable_volume/create_30.rs b/sdk/block-storage/src/v3/manageable_volume/create_30.rs new file mode 100644 index 000000000..c40fa2db0 --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_volume/create_30.rs @@ -0,0 +1,327 @@ +// 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`. + +//! Instruct Cinder to manage a storage object. +//! +//! Manages an existing backend storage object (e.g. a Linux logical volume or +//! a SAN disk) by creating the Cinder objects required to manage it, and +//! possibly renaming the backend storage object (driver dependent) +//! +//! From an API perspective, this operation behaves very much like a volume +//! creation operation, except that properties such as image, snapshot and +//! volume references don't make sense, because we are taking an existing +//! storage object into Cinder management. +//! +//! Required HTTP Body: +//! +//! ```text +//! { +//! "volume": { +//! "host": "", +//! "cluster": "", +//! "ref": "" +//! } +//! } +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_volume +//! method to find out the accepted format of 'ref'. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'host' element refers to a cinder host +//! that is not registered. +//! +//! The volume will later enter the error state if it is discovered that 'ref' +//! is bad. +//! +//! Optional elements to 'volume' are: +//! +//! ```text +//! name A name for the new volume. +//! description A description for the new volume. +//! volume_type ID or name of a volume type to associate with +//! the new Cinder volume. Does not necessarily +//! guarantee that the managed volume will have the +//! properties described in the volume_type. The +//! driver may choose to fail if it identifies that +//! the specified volume_type is not compatible with +//! the backend storage object. +//! metadata Key/value pairs to be associated with the new +//! volume. +//! availability_zone The availability zone to associate with the new +//! volume. +//! bootable If set to True, marks the volume as bootable. +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `volume` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// Enables or disables the bootable attribute. You can boot an instance + /// from a bootable volume. See + /// [valid boolean values](#valid-boolean-values) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bootable: Option, + + /// The volume description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The OpenStack Block Storage host where the existing resource resides. + /// Optional only if cluster field is provided. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>>, + + /// One or more metadata key and value pairs to be associated with the new + /// volume. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Value, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, +} + +impl<'a> VolumeBuilder<'a> { + /// One or more metadata key and value pairs to be associated with the new + /// volume. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `volume` object. + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[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 Manageable_Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".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() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/manageable_volume/create_316.rs b/sdk/block-storage/src/v3/manageable_volume/create_316.rs new file mode 100644 index 000000000..ecd225634 --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_volume/create_316.rs @@ -0,0 +1,333 @@ +// 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`. + +//! Instruct Cinder to manage a storage object. +//! +//! Manages an existing backend storage object (e.g. a Linux logical volume or +//! a SAN disk) by creating the Cinder objects required to manage it, and +//! possibly renaming the backend storage object (driver dependent) +//! +//! From an API perspective, this operation behaves very much like a volume +//! creation operation, except that properties such as image, snapshot and +//! volume references don't make sense, because we are taking an existing +//! storage object into Cinder management. +//! +//! Required HTTP Body: +//! +//! ```text +//! { +//! "volume": { +//! "host": "", +//! "cluster": "", +//! "ref": "" +//! } +//! } +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_volume +//! method to find out the accepted format of 'ref'. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'host' element refers to a cinder host +//! that is not registered. +//! +//! The volume will later enter the error state if it is discovered that 'ref' +//! is bad. +//! +//! Optional elements to 'volume' are: +//! +//! ```text +//! name A name for the new volume. +//! description A description for the new volume. +//! volume_type ID or name of a volume type to associate with +//! the new Cinder volume. Does not necessarily +//! guarantee that the managed volume will have the +//! properties described in the volume_type. The +//! driver may choose to fail if it identifies that +//! the specified volume_type is not compatible with +//! the backend storage object. +//! metadata Key/value pairs to be associated with the new +//! volume. +//! availability_zone The availability zone to associate with the new +//! volume. +//! bootable If set to True, marks the volume as bootable. +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `volume` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// Enables or disables the bootable attribute. You can boot an instance + /// from a bootable volume. See + /// [valid boolean values](#valid-boolean-values) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bootable: Option, + + /// The OpenStack Block Storage cluster where the resource resides. + /// Optional only if host field is provided. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cluster: Option>>, + + /// The volume description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The OpenStack Block Storage host where the existing resource resides. + /// Optional only if cluster field is provided. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>>, + + /// One or more metadata key and value pairs to be associated with the new + /// volume. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Value, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, +} + +impl<'a> VolumeBuilder<'a> { + /// One or more metadata key and value pairs to be associated with the new + /// volume. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `volume` object. + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[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 Manageable_Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 16)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".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() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/manageable_volume/get.rs b/sdk/block-storage/src/v3/manageable_volume/get.rs new file mode 100644 index 000000000..15de167fa --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_volume/get.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Returns a summary list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Manageable_Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/manageable_volume/list_detailed.rs b/sdk/block-storage/src/v3/manageable_volume/list_detailed.rs new file mode 100644 index 000000000..4e015ac61 --- /dev/null +++ b/sdk/block-storage/src/v3/manageable_volume/list_detailed.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Returns a detailed list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Manageable_Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "manageable_volumes/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes/detail".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes/detail".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/message.rs b/sdk/block-storage/src/v3/message.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/message.rs rename to sdk/block-storage/src/v3/message.rs diff --git a/sdk/block-storage/src/v3/message/delete.rs b/sdk/block-storage/src/v3/message/delete.rs new file mode 100644 index 000000000..acb56f29b --- /dev/null +++ b/sdk/block-storage/src/v3/message/delete.rs @@ -0,0 +1,181 @@ +// 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 message. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/messages/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Message. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("messages/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/messages/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/messages/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/message/get.rs b/sdk/block-storage/src/v3/message/get.rs new file mode 100644 index 000000000..f03064149 --- /dev/null +++ b/sdk/block-storage/src/v3/message/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return the given message. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/messages/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Message. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("messages/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("message".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "message" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/messages/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "message": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/messages/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "message": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/message/list.rs b/sdk/block-storage/src/v3/message/list.rs new file mode 100644 index 000000000..1d2933bc3 --- /dev/null +++ b/sdk/block-storage/src/v3/message/list.rs @@ -0,0 +1,226 @@ +// 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`. + +//! Returns a list of messages, transformed through view builder. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Message. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "messages".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("messages".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "messages" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/messages".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "messages": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/messages".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "messages": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/os_volume_transfer.rs b/sdk/block-storage/src/v3/os_volume_transfer.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/os_volume_transfer.rs rename to sdk/block-storage/src/v3/os_volume_transfer.rs diff --git a/sdk/block-storage/src/v3/os_volume_transfer/accept.rs b/sdk/block-storage/src/v3/os_volume_transfer/accept.rs new file mode 100644 index 000000000..79ae2b74b --- /dev/null +++ b/sdk/block-storage/src/v3/os_volume_transfer/accept.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`. + +//! Accept a new volume transfer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Accept<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) auth_key: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) accept: Accept<'a>, + + /// id parameter for /v3/os-volume-transfer/{id}/accept 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<'a> RequestBuilder<'a> { + /// Add a single header to the Os_Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("os-volume-transfer/{id}/accept", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("accept", serde_json::to_value(&self.accept)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfer".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "transfer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/os-volume-transfer/{id}/accept", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/os-volume-transfer/{id}/accept", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/os_volume_transfer/create.rs b/sdk/block-storage/src/v3/os_volume_transfer/create.rs new file mode 100644 index 000000000..d40fa2d66 --- /dev/null +++ b/sdk/block-storage/src/v3/os_volume_transfer/create.rs @@ -0,0 +1,221 @@ +// 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 volume transfer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The volume transfer object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Transfer<'a> { + /// The name of the object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The UUID of the volume. + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The volume transfer object. + #[builder(setter(into))] + pub(crate) transfer: Transfer<'a>, + + #[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 Os_Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-volume-transfer".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("transfer", serde_json::to_value(&self.transfer)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfer".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "transfer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-volume-transfer".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-volume-transfer".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/os_volume_transfer/delete.rs b/sdk/block-storage/src/v3/os_volume_transfer/delete.rs new file mode 100644 index 000000000..c1159cae0 --- /dev/null +++ b/sdk/block-storage/src/v3/os_volume_transfer/delete.rs @@ -0,0 +1,181 @@ +// 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 transfer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-volume-transfer/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Os_Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-volume-transfer/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-volume-transfer/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-volume-transfer/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/os_volume_transfer/find.rs b/sdk/block-storage/src/v3/os_volume_transfer/find.rs new file mode 100644 index 000000000..5c98dff17 --- /dev/null +++ b/sdk/block-storage/src/v3/os_volume_transfer/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::os_volume_transfer::{get as Get, list_detailed as List}; + +/// Find for os_volume_transfer 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate os_volume_transfer in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // os_volume_transfer 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/os_volume_transfer/get.rs b/sdk/block-storage/src/v3/os_volume_transfer/get.rs new file mode 100644 index 000000000..090353a02 --- /dev/null +++ b/sdk/block-storage/src/v3/os_volume_transfer/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about active transfers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-volume-transfer/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Os_Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-volume-transfer/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfer".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "transfer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-volume-transfer/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-volume-transfer/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/os_volume_transfer/list.rs b/sdk/block-storage/src/v3/os_volume_transfer/list.rs new file mode 100644 index 000000000..a58d5459d --- /dev/null +++ b/sdk/block-storage/src/v3/os_volume_transfer/list.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`. + +//! Returns a summary list of transfers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Os_Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-volume-transfer".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfers".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "transfers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-transfer".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-transfer".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/os_volume_transfer/list_detailed.rs b/sdk/block-storage/src/v3/os_volume_transfer/list_detailed.rs new file mode 100644 index 000000000..84f759cfb --- /dev/null +++ b/sdk/block-storage/src/v3/os_volume_transfer/list_detailed.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`. + +//! Returns a detailed list of transfers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Os_Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-volume-transfer/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfers".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "transfers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-transfer/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-transfer/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec.rs b/sdk/block-storage/src/v3/qos_spec.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/qos_spec.rs rename to sdk/block-storage/src/v3/qos_spec.rs diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/associate.rs b/sdk/block-storage/src/v3/qos_spec/associate.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/qos_spec/associate.rs rename to sdk/block-storage/src/v3/qos_spec/associate.rs index dd1697de5..7d83547a7 100644 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/associate.rs +++ b/sdk/block-storage/src/v3/qos_spec/associate.rs @@ -111,7 +111,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/association.rs b/sdk/block-storage/src/v3/qos_spec/association.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/qos_spec/association.rs rename to sdk/block-storage/src/v3/qos_spec/association.rs diff --git a/sdk/block-storage/src/v3/qos_spec/association/list.rs b/sdk/block-storage/src/v3/qos_spec/association/list.rs new file mode 100644 index 000000000..81d84e2e2 --- /dev/null +++ b/sdk/block-storage/src/v3/qos_spec/association/list.rs @@ -0,0 +1,184 @@ +// 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 associations of given qos specs. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/qos-specs/{id}/associations 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<'a> RequestBuilder<'a> { + /// Add a single header to the Association. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos-specs/{id}/associations", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("qos_associations".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "qos_associations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos-specs/{id}/associations", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_associations": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos-specs/{id}/associations", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_associations": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/qos_spec/create.rs b/sdk/block-storage/src/v3/qos_spec/create.rs new file mode 100644 index 000000000..242eed116 --- /dev/null +++ b/sdk/block-storage/src/v3/qos_spec/create.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `qos_specs` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct QosSpecs<'a> { + /// The name of the QoS specification. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> QosSpecsBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `qos_specs` object. + #[builder(setter(into))] + pub(crate) qos_specs: QosSpecs<'a>, + + #[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 Qos_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos-specs".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("qos_specs", serde_json::to_value(&self.qos_specs)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("qos_specs".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "qos_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos-specs".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + let endpoint = Request::builder() + .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos-specs".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + let endpoint = Request::builder() + .qos_specs(QosSpecsBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/qos_spec/delete.rs b/sdk/block-storage/src/v3/qos_spec/delete.rs new file mode 100644 index 000000000..9fc899692 --- /dev/null +++ b/sdk/block-storage/src/v3/qos_spec/delete.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Deletes an existing qos specs. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/qos-specs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Qos_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos-specs/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos-specs/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos-specs/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/delete_keys.rs b/sdk/block-storage/src/v3/qos_spec/delete_keys.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/qos_spec/delete_keys.rs rename to sdk/block-storage/src/v3/qos_spec/delete_keys.rs index 84c539f22..c9af3cc07 100644 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/delete_keys.rs +++ b/sdk/block-storage/src/v3/qos_spec/delete_keys.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/disassociate.rs b/sdk/block-storage/src/v3/qos_spec/disassociate.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/qos_spec/disassociate.rs rename to sdk/block-storage/src/v3/qos_spec/disassociate.rs index dd6cd9ba9..8758d91de 100644 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/disassociate.rs +++ b/sdk/block-storage/src/v3/qos_spec/disassociate.rs @@ -111,7 +111,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/qos_spec/disassociate_all.rs b/sdk/block-storage/src/v3/qos_spec/disassociate_all.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/qos_spec/disassociate_all.rs rename to sdk/block-storage/src/v3/qos_spec/disassociate_all.rs index 09a829289..114d3d1ef 100644 --- a/openstack_sdk/src/api/block_storage/v3/qos_spec/disassociate_all.rs +++ b/sdk/block-storage/src/v3/qos_spec/disassociate_all.rs @@ -111,7 +111,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/qos_spec/find.rs b/sdk/block-storage/src/v3/qos_spec/find.rs new file mode 100644 index 000000000..7d22d3ac0 --- /dev/null +++ b/sdk/block-storage/src/v3/qos_spec/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::qos_spec::{get as Get, list as List}; + +/// Find for qos_spec 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate qos_spec in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // qos_spec 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/qos_spec/get.rs b/sdk/block-storage/src/v3/qos_spec/get.rs new file mode 100644 index 000000000..bab4bd728 --- /dev/null +++ b/sdk/block-storage/src/v3/qos_spec/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return a single qos spec item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/qos-specs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Qos_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos-specs/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("qos_specs".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "qos_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos-specs/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos-specs/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/qos_spec/list.rs b/sdk/block-storage/src/v3/qos_spec/list.rs new file mode 100644 index 000000000..54ad75a83 --- /dev/null +++ b/sdk/block-storage/src/v3/qos_spec/list.rs @@ -0,0 +1,226 @@ +// 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`. + +//! Returns the list of qos_specs. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Qos_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos-specs".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("qos_specs".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "qos_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos-specs".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos-specs".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/qos_spec/set.rs b/sdk/block-storage/src/v3/qos_spec/set.rs new file mode 100644 index 000000000..9e33d937b --- /dev/null +++ b/sdk/block-storage/src/v3/qos_spec/set.rs @@ -0,0 +1,236 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_qos_specs"))] + pub(crate) qos_specs: BTreeMap, Option>>, + + /// id parameter for /v3/qos-specs/{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<'a> RequestBuilder<'a> { + pub fn qos_specs(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>>, + { + self.qos_specs + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Qos_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("qos-specs/{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("qos_specs", serde_json::to_value(&self.qos_specs)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("qos_specs".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .qos_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))) + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .qos_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))) + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "qos_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos-specs/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .qos_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos-specs/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "qos_specs": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .qos_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_class_set.rs b/sdk/block-storage/src/v3/quota_class_set.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/quota_class_set.rs rename to sdk/block-storage/src/v3/quota_class_set.rs diff --git a/sdk/block-storage/src/v3/quota_class_set/get.rs b/sdk/block-storage/src/v3/quota_class_set/get.rs new file mode 100644 index 000000000..7adcb2631 --- /dev/null +++ b/sdk/block-storage/src/v3/quota_class_set/get.rs @@ -0,0 +1,184 @@ +// 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 classes for a project +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-quota-class-sets/{id} API + #[builder(default, setter(into))] + name: 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 Quota_Class_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-quota-class-sets/{name}", name = self.name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("quota_class_set".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota_class_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-class-sets/{name}", name = "name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder().name("name").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-class-sets/{name}", name = "name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/quota_class_set/set.rs b/sdk/block-storage/src/v3/quota_class_set/set.rs new file mode 100644 index 000000000..72548c947 --- /dev/null +++ b/sdk/block-storage/src/v3/quota_class_set/set.rs @@ -0,0 +1,225 @@ +// 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 quota classes for a project +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_quota_class_set"))] + pub(crate) quota_class_set: BTreeMap, i32>, + + /// id parameter for /v3/os-quota-class-sets/{id} API + #[builder(default, setter(into))] + name: 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> { + pub fn quota_class_set(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.quota_class_set + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Quota_Class_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-class-sets/{name}", name = self.name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "quota_class_set", + serde_json::to_value(&self.quota_class_set)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("quota_class_set".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_class_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota_class_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota_class_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{name}", name = "name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .quota_class_set(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{name}", name = "name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .quota_class_set(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set.rs b/sdk/block-storage/src/v3/quota_set.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/quota_set.rs rename to sdk/block-storage/src/v3/quota_set.rs diff --git a/sdk/block-storage/src/v3/quota_set/defaults.rs b/sdk/block-storage/src/v3/quota_set/defaults.rs new file mode 100644 index 000000000..46d929590 --- /dev/null +++ b/sdk/block-storage/src/v3/quota_set/defaults.rs @@ -0,0 +1,191 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The quota-set project_id attribute + #[builder(default, setter(into))] + project_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 Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "os-quota-sets/{project_id}/defaults", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/os-quota-sets/{project_id}/defaults", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/os-quota-sets/{project_id}/defaults", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/quota_set/delete.rs b/sdk/block-storage/src/v3/quota_set/delete.rs new file mode 100644 index 000000000..e7a9744ad --- /dev/null +++ b/sdk/block-storage/src/v3/quota_set/delete.rs @@ -0,0 +1,190 @@ +// 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 particular tenant +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The quota-set project_id attribute + #[builder(default, setter(into))] + project_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 Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "os-quota-sets/{project_id}", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/os-quota-sets/{project_id}", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/os-quota-sets/{project_id}", + project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/quota_set/get.rs b/sdk/block-storage/src/v3/quota_set/get.rs new file mode 100644 index 000000000..2f56ed998 --- /dev/null +++ b/sdk/block-storage/src/v3/quota_set/get.rs @@ -0,0 +1,200 @@ +// 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 for a particular tenant +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The quota-set project_id attribute + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// Show project’s quota usage information. Default is false. + #[builder(default)] + usage: 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> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "os-quota-sets/{project_id}", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("usage", self.usage); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/os-quota-sets/{project_id}", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/os-quota-sets/{project_id}", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/quota_set/set.rs b/sdk/block-storage/src/v3/quota_set/set.rs new file mode 100644 index 000000000..611ae5d8c --- /dev/null +++ b/sdk/block-storage/src/v3/quota_set/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 quota for a particular tenant +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `quota_set` object. + #[builder(private, setter(into, name = "_quota_set"))] + pub(crate) quota_set: BTreeMap, Value>, + + /// The quota-set project_id attribute + #[builder(default, setter(into))] + project_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> { + /// A `quota_set` object. + pub fn quota_set(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.quota_set + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "os-quota-sets/{project_id}", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("quota_set", serde_json::to_value(&self.quota_set)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/os-quota-sets/{project_id}", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .quota_set(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/os-quota-sets/{project_id}", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .quota_set(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/resource_filter.rs b/sdk/block-storage/src/v3/resource_filter.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/resource_filter.rs rename to sdk/block-storage/src/v3/resource_filter.rs diff --git a/sdk/block-storage/src/v3/resource_filter/list.rs b/sdk/block-storage/src/v3/resource_filter/list.rs new file mode 100644 index 000000000..3b44cb4d4 --- /dev/null +++ b/sdk/block-storage/src/v3/resource_filter/list.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`. + +//! Return a list of resource filters. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Resource_Filter. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "resource_filters".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("resource_filters".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "resource_filters" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/resource_filters".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_filters": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/resource_filters".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_filters": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/scheduler_stat.rs b/sdk/block-storage/src/v3/scheduler_stat.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/scheduler_stat.rs rename to sdk/block-storage/src/v3/scheduler_stat.rs diff --git a/openstack_sdk/src/api/block_storage/v3/scheduler_stat/pool.rs b/sdk/block-storage/src/v3/scheduler_stat/pool.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/scheduler_stat/pool.rs rename to sdk/block-storage/src/v3/scheduler_stat/pool.rs diff --git a/sdk/block-storage/src/v3/scheduler_stat/pool/list.rs b/sdk/block-storage/src/v3/scheduler_stat/pool/list.rs new file mode 100644 index 000000000..f14a7dceb --- /dev/null +++ b/sdk/block-storage/src/v3/scheduler_stat/pool/list.rs @@ -0,0 +1,186 @@ +// 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 active pools in scheduler. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + /// Indicates whether to show pool details or only pool names in the + /// response. Set to true to show pool details. Set to false to show only + /// pool names. Default is false. + #[builder(default)] + detail: Option, + + #[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 Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "scheduler-stats/get_pools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("detail", self.detail); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("pools".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "pools" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/scheduler-stats/get_pools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pools": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/scheduler-stats/get_pools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pools": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/service.rs b/sdk/block-storage/src/v3/service.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/service.rs rename to sdk/block-storage/src/v3/service.rs diff --git a/sdk/block-storage/src/v3/service/list.rs b/sdk/block-storage/src/v3/service/list.rs new file mode 100644 index 000000000..ef46d9fb1 --- /dev/null +++ b/sdk/block-storage/src/v3/service/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`. + +//! Return a list of all running services. +//! +//! Filter by host & service name. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-services".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-services".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-services".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/service/set.rs b/sdk/block-storage/src/v3/service/set.rs new file mode 100644 index 000000000..608160d24 --- /dev/null +++ b/sdk/block-storage/src/v3/service/set.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`. + +//! Enable/Disable scheduling for a service. +//! +//! Includes Freeze/Thaw which sends call down to drivers and allows +//! volume.manager for the specified host to disable the service rather than +//! accessing the service directly in this API layer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-services/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-services/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + use openstack_sdk_core::test::client::FakeOpenStackClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-services/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-services/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot.rs b/sdk/block-storage/src/v3/snapshot.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/snapshot.rs rename to sdk/block-storage/src/v3/snapshot.rs diff --git a/sdk/block-storage/src/v3/snapshot/create.rs b/sdk/block-storage/src/v3/snapshot/create.rs new file mode 100644 index 000000000..fda67dbf3 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/create.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`. + +//! Creates a new snapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `snapshot` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Snapshot<'a> { + /// A description for the snapshot. Default is `None`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The name of the snapshot. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) display_name: Option>>, + + /// Indicates whether to snapshot, even if the volume is attached. Default + /// is `false`. See [valid boolean values](#valid-boolean-values) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) force: Option, + + /// One or more metadata key and value pairs for the snapshot. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + /// The name of the snapshot. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The UUID of the volume. + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Option>, +} + +impl<'a> SnapshotBuilder<'a> { + /// One or more metadata key and value pairs for the snapshot. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `snapshot` object. + #[builder(setter(into))] + pub(crate) snapshot: Snapshot<'a>, + + #[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 Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("snapshot", serde_json::to_value(&self.snapshot)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("snapshot".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "snapshot" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/snapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/snapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot(SnapshotBuilder::default().volume_id("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/delete.rs b/sdk/block-storage/src/v3/snapshot/delete.rs new file mode 100644 index 000000000..e01627001 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/delete.rs @@ -0,0 +1,181 @@ +// 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 snapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/snapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("snapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/snapshots/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/snapshots/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/find.rs b/sdk/block-storage/src/v3/snapshot/find.rs new file mode 100644 index 000000000..5b5a98c24 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::snapshot::{get as Get, list_detailed as List}; + +/// Find for snapshot 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate snapshot in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // snapshot 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/snapshot/get.rs b/sdk/block-storage/src/v3/snapshot/get.rs new file mode 100644 index 000000000..9c8ce1025 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about the given snapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/snapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("snapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("snapshot".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "snapshot" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/snapshots/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/snapshots/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/list.rs b/sdk/block-storage/src/v3/snapshot/list.rs new file mode 100644 index 000000000..8f2e77fde --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/list.rs @@ -0,0 +1,245 @@ +// 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`. + +//! Returns a summary list of snapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Filters results by consumes_quota field. Resources that don’t use + /// quotas are usually temporary internal resources created to perform an + /// operation. Default is to not filter by it. Filtering by this option may + /// not be always possible in a cloud, see List Resource Filters to + /// determine whether this filter is available in your cloud. + #[builder(default)] + consumes_quota: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Whether to show count in API response or not, default is False. + #[builder(default)] + with_count: 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> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("consumes_quota", self.consumes_quota); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("with_count", self.with_count); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("snapshots".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "snapshots" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/snapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshots": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/snapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshots": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/list_detailed.rs b/sdk/block-storage/src/v3/snapshot/list_detailed.rs new file mode 100644 index 000000000..f282faea5 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/list_detailed.rs @@ -0,0 +1,245 @@ +// 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`. + +//! Returns a detailed list of snapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Filters results by consumes_quota field. Resources that don’t use + /// quotas are usually temporary internal resources created to perform an + /// operation. Default is to not filter by it. Filtering by this option may + /// not be always possible in a cloud, see List Resource Filters to + /// determine whether this filter is available in your cloud. + #[builder(default)] + consumes_quota: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Whether to show count in API response or not, default is False. + #[builder(default)] + with_count: 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> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "snapshots/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("consumes_quota", self.consumes_quota); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("with_count", self.with_count); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("snapshots".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "snapshots" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/snapshots/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshots": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/snapshots/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshots": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/metadata.rs b/sdk/block-storage/src/v3/snapshot/metadata.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/snapshot/metadata.rs rename to sdk/block-storage/src/v3/snapshot/metadata.rs diff --git a/sdk/block-storage/src/v3/snapshot/metadata/create.rs b/sdk/block-storage/src/v3/snapshot/metadata/create.rs new file mode 100644 index 000000000..5986c6b21 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/metadata/create.rs @@ -0,0 +1,249 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// One or more metadata key and value pairs for the snapshot, if any. + #[builder(private, setter(into, name = "_metadata"))] + pub(crate) metadata: BTreeMap, Cow<'a, str>>, + + /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API + #[builder(default, setter(into))] + snapshot_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// One or more metadata key and value pairs for the snapshot, if any. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "snapshots/{snapshot_id}/metadata", + snapshot_id = self.snapshot_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("metadata", serde_json::to_value(&self.metadata)?); + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("metadata".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/snapshots/{snapshot_id}/metadata", + snapshot_id = "snapshot_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .snapshot_id("snapshot_id") + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/snapshots/{snapshot_id}/metadata", + snapshot_id = "snapshot_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .snapshot_id("snapshot_id") + .metadata(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/metadata/delete.rs b/sdk/block-storage/src/v3/snapshot/metadata/delete.rs new file mode 100644 index 000000000..546710ae5 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/metadata/delete.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Deletes an existing metadata. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/snapshots/{snapshot_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API + #[builder(default, setter(into))] + snapshot_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "snapshots/{snapshot_id}/metadata/{id}", + id = self.id.as_ref(), + snapshot_id = self.snapshot_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/snapshots/{snapshot_id}/metadata/{id}", + id = "id", + snapshot_id = "snapshot_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .snapshot_id("snapshot_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/snapshots/{snapshot_id}/metadata/{id}", + id = "id", + snapshot_id = "snapshot_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") + .snapshot_id("snapshot_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/metadata/get.rs b/sdk/block-storage/src/v3/snapshot/metadata/get.rs new file mode 100644 index 000000000..7405a6954 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/metadata/get.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Return a single metadata item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/snapshots/{snapshot_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API + #[builder(default, setter(into))] + snapshot_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "snapshots/{snapshot_id}/metadata/{id}", + id = self.id.as_ref(), + snapshot_id = self.snapshot_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("meta".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "meta" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/snapshots/{snapshot_id}/metadata/{id}", + id = "id", + snapshot_id = "snapshot_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .snapshot_id("snapshot_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/snapshots/{snapshot_id}/metadata/{id}", + id = "id", + snapshot_id = "snapshot_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .snapshot_id("snapshot_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/metadata/list.rs b/sdk/block-storage/src/v3/snapshot/metadata/list.rs new file mode 100644 index 000000000..d31fe7ba6 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/metadata/list.rs @@ -0,0 +1,196 @@ +// 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`. + +//! Returns the list of metadata for a given snapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API + #[builder(default, setter(into))] + snapshot_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "snapshots/{snapshot_id}/metadata", + snapshot_id = self.snapshot_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("metadata".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/snapshots/{snapshot_id}/metadata", + snapshot_id = "snapshot_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .snapshot_id("snapshot_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/snapshots/{snapshot_id}/metadata", + snapshot_id = "snapshot_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .snapshot_id("snapshot_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/metadata/replace.rs b/sdk/block-storage/src/v3/snapshot/metadata/replace.rs new file mode 100644 index 000000000..12f94ed5c --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/metadata/replace.rs @@ -0,0 +1,249 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// One or more metadata key and value pairs for the snapshot, if any. + #[builder(private, setter(into, name = "_metadata"))] + pub(crate) metadata: BTreeMap, Cow<'a, str>>, + + /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API + #[builder(default, setter(into))] + snapshot_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// One or more metadata key and value pairs for the snapshot, if any. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "snapshots/{snapshot_id}/metadata", + snapshot_id = self.snapshot_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("metadata", serde_json::to_value(&self.metadata)?); + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("metadata".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/snapshots/{snapshot_id}/metadata", + snapshot_id = "snapshot_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .snapshot_id("snapshot_id") + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/snapshots/{snapshot_id}/metadata", + snapshot_id = "snapshot_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .snapshot_id("snapshot_id") + .metadata(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/metadata/set.rs b/sdk/block-storage/src/v3/snapshot/metadata/set.rs new file mode 100644 index 000000000..1986b5612 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/metadata/set.rs @@ -0,0 +1,256 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_meta"))] + pub(crate) meta: BTreeMap, Cow<'a, str>>, + + /// id parameter for /v3/snapshots/{snapshot_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// snapshot_id parameter for /v3/snapshots/{snapshot_id}/metadata API + #[builder(default, setter(into))] + snapshot_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + pub fn meta(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.meta + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "snapshots/{snapshot_id}/metadata/{id}", + id = self.id.as_ref(), + snapshot_id = self.snapshot_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("meta", serde_json::to_value(&self.meta)?); + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("meta".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "meta" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/snapshots/{snapshot_id}/metadata/{id}", + id = "id", + snapshot_id = "snapshot_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .snapshot_id("snapshot_id") + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/snapshots/{snapshot_id}/metadata/{id}", + id = "id", + snapshot_id = "snapshot_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .snapshot_id("snapshot_id") + .meta(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/os_force_delete.rs b/sdk/block-storage/src/v3/snapshot/os_force_delete.rs new file mode 100644 index 000000000..26182d08c --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/os_force_delete.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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// OpenAPI specifies the field as '{}'. + #[builder(setter(into))] + pub(crate) os_force_delete: Value, + + /// id parameter for /v3/snapshots/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("snapshots/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "os-force_delete", + serde_json::to_value(&self.os_force_delete)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_force_delete(json!({})) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_force_delete(json!({})) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/snapshots/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_force_delete(json!({})) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/snapshots/{id}/action", 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") + .os_force_delete(json!({})) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/os_reset_status.rs b/sdk/block-storage/src/v3/snapshot/os_reset_status.rs new file mode 100644 index 000000000..a13be425c --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/os_reset_status.rs @@ -0,0 +1,239 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsResetStatus<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) status: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) os_reset_status: OsResetStatus<'a>, + + /// id parameter for /v3/snapshots/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("snapshots/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "os-reset_status", + serde_json::to_value(&self.os_reset_status)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/snapshots/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/snapshots/{id}/action", 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") + .os_reset_status( + OsResetStatusBuilder::default() + .status("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot/os_unmanage.rs b/sdk/block-storage/src/v3/snapshot/os_unmanage.rs new file mode 100644 index 000000000..abd78dfc1 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/os_unmanage.rs @@ -0,0 +1,208 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// OpenAPI specifies the field as '{}'. + #[builder(setter(into))] + pub(crate) os_unmanage: Value, + + /// id parameter for /v3/snapshots/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("snapshots/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("os-unmanage", serde_json::to_value(&self.os_unmanage)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_unmanage(json!({})) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_unmanage(json!({})) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/snapshots/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_unmanage(json!({})) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/snapshots/{id}/action", 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") + .os_unmanage(json!({})) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot/os_update_snapshot_status.rs b/sdk/block-storage/src/v3/snapshot/os_update_snapshot_status.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/snapshot/os_update_snapshot_status.rs rename to sdk/block-storage/src/v3/snapshot/os_update_snapshot_status.rs index 20ee01e49..e903ba5fd 100644 --- a/openstack_sdk/src/api/block_storage/v3/snapshot/os_update_snapshot_status.rs +++ b/sdk/block-storage/src/v3/snapshot/os_update_snapshot_status.rs @@ -137,7 +137,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/snapshot/set.rs b/sdk/block-storage/src/v3/snapshot/set.rs new file mode 100644 index 000000000..42e64717d --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot/set.rs @@ -0,0 +1,231 @@ +// 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 a snapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Snapshot<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) display_description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) display_name: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) snapshot: Snapshot<'a>, + + /// id parameter for /v3/snapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("snapshots/{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("snapshot", serde_json::to_value(&self.snapshot)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("snapshot".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .snapshot(SnapshotBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .snapshot(SnapshotBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "snapshot" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/snapshots/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .snapshot(SnapshotBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/snapshots/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .snapshot(SnapshotBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/snapshot_manage.rs b/sdk/block-storage/src/v3/snapshot_manage.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/snapshot_manage.rs rename to sdk/block-storage/src/v3/snapshot_manage.rs diff --git a/sdk/block-storage/src/v3/snapshot_manage/create.rs b/sdk/block-storage/src/v3/snapshot_manage/create.rs new file mode 100644 index 000000000..8a5d81c0f --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot_manage/create.rs @@ -0,0 +1,310 @@ +// 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`. + +//! Instruct Cinder to manage a storage snapshot object. +//! +//! Manages an existing backend storage snapshot object (e.g. a Linux logical +//! volume or a SAN disk) by creating the Cinder objects required to manage it, +//! and possibly renaming the backend storage snapshot object (driver +//! dependent). +//! +//! From an API perspective, this operation behaves very much like a snapshot +//! creation operation. +//! +//! Required HTTP Body: +//! +//! ```text +//! { +//! "snapshot": +//! { +//! "volume_id": "", +//! "ref": +//! "" +//! } +//! } +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_snapshot +//! method to find out the accepted format of 'ref'. For example,in LVM driver, +//! it will be the logic volume name of snapshot which you want to manage. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'volume_id' element refers to a cinder +//! volume that could not be found. +//! +//! The snapshot will later enter the error state if it is discovered that +//! 'ref' is bad. +//! +//! Optional elements to 'snapshot' are: +//! +//! ```text +//! name A name for the new snapshot. +//! description A description for the new snapshot. +//! metadata Key/value pairs to be associated with the new snapshot. +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Snapshot<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +impl<'a> SnapshotBuilder<'a> { + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) snapshot: Snapshot<'a>, + + #[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 Snapshot_Manage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-snapshot-manage".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("snapshot", serde_json::to_value(&self.snapshot)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-snapshot-manage".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-snapshot-manage".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() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot_manage/get.rs b/sdk/block-storage/src/v3/snapshot_manage/get.rs new file mode 100644 index 000000000..f6235d4dc --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot_manage/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`. + +//! Returns a summary list of snapshots available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Snapshot_Manage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-snapshot-manage".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-snapshot-manage".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-snapshot-manage".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/snapshot_manage/list_detailed.rs b/sdk/block-storage/src/v3/snapshot_manage/list_detailed.rs new file mode 100644 index 000000000..e4118f8b8 --- /dev/null +++ b/sdk/block-storage/src/v3/snapshot_manage/list_detailed.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`. + +//! Returns a detailed list of snapshots available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Snapshot_Manage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-snapshot-manage/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-snapshot-manage/detail".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-snapshot-manage/detail".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/type.rs b/sdk/block-storage/src/v3/type.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/type.rs rename to sdk/block-storage/src/v3/type.rs diff --git a/openstack_sdk/src/api/block_storage/v3/type/add_project_access.rs b/sdk/block-storage/src/v3/type/add_project_access.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/type/add_project_access.rs rename to sdk/block-storage/src/v3/type/add_project_access.rs index db89bf0e5..a627492aa 100644 --- a/openstack_sdk/src/api/block_storage/v3/type/add_project_access.rs +++ b/sdk/block-storage/src/v3/type/add_project_access.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/type/create.rs b/sdk/block-storage/src/v3/type/create.rs new file mode 100644 index 000000000..2046d471f --- /dev/null +++ b/sdk/block-storage/src/v3/type/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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct VolumeType<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_extra_specs"))] + pub(crate) extra_specs: Option, Option>>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[serde( + rename = "os-volume-type-access:is_public", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) os_volume_type_access_is_public: Option, +} + +impl<'a> VolumeTypeBuilder<'a> { + pub fn extra_specs(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>>, + { + self.extra_specs + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) volume_type: VolumeType<'a>, + + /// id parameter for /v3/types/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("types/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("volume_type", serde_json::to_value(&self.volume_type)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume_type".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "volume_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/types/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/types/{id}/action", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_type(VolumeTypeBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/delete.rs b/sdk/block-storage/src/v3/type/delete.rs new file mode 100644 index 000000000..80411d124 --- /dev/null +++ b/sdk/block-storage/src/v3/type/delete.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Deletes an existing volume type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/types/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/types/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/type/encryption.rs b/sdk/block-storage/src/v3/type/encryption.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/type/encryption.rs rename to sdk/block-storage/src/v3/type/encryption.rs diff --git a/sdk/block-storage/src/v3/type/encryption/create.rs b/sdk/block-storage/src/v3/type/encryption/create.rs new file mode 100644 index 000000000..45c48cfc4 --- /dev/null +++ b/sdk/block-storage/src/v3/type/encryption/create.rs @@ -0,0 +1,287 @@ +// 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 encryption specs for an existing volume type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum ControlLocation { + #[serde(rename = "back-end")] + BackEnd, + #[serde(rename = "front-end")] + FrontEnd, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Encryption<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cipher: Option>>, + + #[serde()] + #[builder()] + pub(crate) control_location: ControlLocation, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_size: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) provider: Cow<'a, str>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> EncryptionBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) encryption: Encryption<'a>, + + /// type_id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + type_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 Encryption. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "types/{type_id}/encryption", + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("encryption", serde_json::to_value(&self.encryption)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("encryption".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .encryption( + EncryptionBuilder::default() + .control_location(ControlLocation::BackEnd) + .provider("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .encryption( + EncryptionBuilder::default() + .control_location(ControlLocation::BackEnd) + .provider("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "encryption" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/types/{type_id}/encryption", type_id = "type_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "encryption": {} })); + }); + + let endpoint = Request::builder() + .type_id("type_id") + .encryption( + EncryptionBuilder::default() + .control_location(ControlLocation::BackEnd) + .provider("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/types/{type_id}/encryption", type_id = "type_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "encryption": {} })); + }); + + let endpoint = Request::builder() + .type_id("type_id") + .encryption( + EncryptionBuilder::default() + .control_location(ControlLocation::BackEnd) + .provider("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/encryption/delete.rs b/sdk/block-storage/src/v3/type/encryption/delete.rs new file mode 100644 index 000000000..43e4a00c7 --- /dev/null +++ b/sdk/block-storage/src/v3/type/encryption/delete.rs @@ -0,0 +1,202 @@ +// 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 encryption specs for a given volume type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// type_id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + type_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 Encryption. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "types/{type_id}/encryption/{id}", + id = self.id.as_ref(), + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/types/{type_id}/encryption/{id}", + id = "id", + type_id = "type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .type_id("type_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/types/{type_id}/encryption/{id}", + id = "id", + type_id = "type_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") + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/encryption/get.rs b/sdk/block-storage/src/v3/type/encryption/get.rs new file mode 100644 index 000000000..97a5d176c --- /dev/null +++ b/sdk/block-storage/src/v3/type/encryption/get.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Return a single encryption item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// type_id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + type_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 Encryption. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "types/{type_id}/encryption/{id}", + id = self.id.as_ref(), + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/types/{type_id}/encryption/{id}", + id = "id", + type_id = "type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .type_id("type_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/types/{type_id}/encryption/{id}", + id = "id", + type_id = "type_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") + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/encryption/list.rs b/sdk/block-storage/src/v3/type/encryption/list.rs new file mode 100644 index 000000000..b45ccabc2 --- /dev/null +++ b/sdk/block-storage/src/v3/type/encryption/list.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Returns the encryption specs for a given volume type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// type_id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + type_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 Encryption. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "types/{type_id}/encryption", + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/types/{type_id}/encryption", type_id = "type_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().type_id("type_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/types/{type_id}/encryption", type_id = "type_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() + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/encryption/set.rs b/sdk/block-storage/src/v3/type/encryption/set.rs new file mode 100644 index 000000000..45d8e1ba5 --- /dev/null +++ b/sdk/block-storage/src/v3/type/encryption/set.rs @@ -0,0 +1,277 @@ +// 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 encryption specs for a given volume type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum ControlLocation { + #[serde(rename = "back-end")] + BackEnd, + #[serde(rename = "front-end")] + FrontEnd, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Encryption<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cipher: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) control_location: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_size: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) provider: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> EncryptionBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) encryption: Encryption<'a>, + + /// id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// type_id parameter for /v3/types/{type_id}/encryption/{id} API + #[builder(default, setter(into))] + type_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 Encryption. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "types/{type_id}/encryption/{id}", + id = self.id.as_ref(), + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("encryption", serde_json::to_value(&self.encryption)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("encryption".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .encryption(EncryptionBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .encryption(EncryptionBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "encryption" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/types/{type_id}/encryption/{id}", + id = "id", + type_id = "type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "encryption": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .type_id("type_id") + .encryption(EncryptionBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/types/{type_id}/encryption/{id}", + id = "id", + type_id = "type_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "encryption": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .type_id("type_id") + .encryption(EncryptionBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/type/extra_spec.rs b/sdk/block-storage/src/v3/type/extra_spec.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/type/extra_spec.rs rename to sdk/block-storage/src/v3/type/extra_spec.rs diff --git a/sdk/block-storage/src/v3/type/extra_spec/create.rs b/sdk/block-storage/src/v3/type/extra_spec/create.rs new file mode 100644 index 000000000..8856fec13 --- /dev/null +++ b/sdk/block-storage/src/v3/type/extra_spec/create.rs @@ -0,0 +1,240 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_extra_specs"))] + pub(crate) extra_specs: BTreeMap, Option>>, + + /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + type_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> { + pub fn extra_specs(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>>, + { + self.extra_specs + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "types/{type_id}/extra_specs", + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("extra_specs", serde_json::to_value(&self.extra_specs)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("extra_specs".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .extra_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))) + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .extra_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))) + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "extra_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder() + .type_id("type_id") + .extra_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder() + .type_id("type_id") + .extra_specs( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.map(Into::into))), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/extra_spec/delete.rs b/sdk/block-storage/src/v3/type/extra_spec/delete.rs new file mode 100644 index 000000000..e5e9a9a0e --- /dev/null +++ b/sdk/block-storage/src/v3/type/extra_spec/delete.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Deletes an existing extra spec. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + type_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 Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "types/{type_id}/extra_specs/{id}", + id = self.id.as_ref(), + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/types/{type_id}/extra_specs/{id}", + id = "id", + type_id = "type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .type_id("type_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/types/{type_id}/extra_specs/{id}", + id = "id", + type_id = "type_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") + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/extra_spec/get.rs b/sdk/block-storage/src/v3/type/extra_spec/get.rs new file mode 100644 index 000000000..579924fd0 --- /dev/null +++ b/sdk/block-storage/src/v3/type/extra_spec/get.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Return a single extra spec item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + type_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 Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "types/{type_id}/extra_specs/{id}", + id = self.id.as_ref(), + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/types/{type_id}/extra_specs/{id}", + id = "id", + type_id = "type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .type_id("type_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/types/{type_id}/extra_specs/{id}", + id = "id", + type_id = "type_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") + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/extra_spec/list.rs b/sdk/block-storage/src/v3/type/extra_spec/list.rs new file mode 100644 index 000000000..7e77c7bbd --- /dev/null +++ b/sdk/block-storage/src/v3/type/extra_spec/list.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Returns the list of extra specs for a given volume type. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + type_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 Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "types/{type_id}/extra_specs", + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("extra_specs".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "extra_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder().type_id("type_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/types/{type_id}/extra_specs", type_id = "type_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder() + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/extra_spec/set.rs b/sdk/block-storage/src/v3/type/extra_spec/set.rs new file mode 100644 index 000000000..745d277cd --- /dev/null +++ b/sdk/block-storage/src/v3/type/extra_spec/set.rs @@ -0,0 +1,226 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// type_id parameter for /v3/types/{type_id}/extra_specs/{id} API + #[builder(default, setter(into))] + type_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, 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 Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>>, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "types/{type_id}/extra_specs/{id}", + id = self.id.as_ref(), + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), serde_json::Value::from(val.clone())); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/types/{type_id}/extra_specs/{id}", + id = "id", + type_id = "type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .type_id("type_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/types/{type_id}/extra_specs/{id}", + id = "id", + type_id = "type_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") + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/find.rs b/sdk/block-storage/src/v3/type/find.rs new file mode 100644 index 000000000..00e9258e2 --- /dev/null +++ b/sdk/block-storage/src/v3/type/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::r#type::{get as Get, list as List}; + +/// Find for type 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate type in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // type 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/type/get.rs b/sdk/block-storage/src/v3/type/get.rs new file mode 100644 index 000000000..654b1d8cc --- /dev/null +++ b/sdk/block-storage/src/v3/type/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return a single volume type item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume_type".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volume_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/types/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/types/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/type/list.rs b/sdk/block-storage/src/v3/type/list.rs new file mode 100644 index 000000000..3eb961372 --- /dev/null +++ b/sdk/block-storage/src/v3/type/list.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`. + +//! Returns the list of volume types. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume_types".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volume_types" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/types".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_types": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/types".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_types": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/type/remove_project_access.rs b/sdk/block-storage/src/v3/type/remove_project_access.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/type/remove_project_access.rs rename to sdk/block-storage/src/v3/type/remove_project_access.rs index b3afb5ef1..223bceb7f 100644 --- a/openstack_sdk/src/api/block_storage/v3/type/remove_project_access.rs +++ b/sdk/block-storage/src/v3/type/remove_project_access.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/type/set.rs b/sdk/block-storage/src/v3/type/set.rs new file mode 100644 index 000000000..1fbe79d16 --- /dev/null +++ b/sdk/block-storage/src/v3/type/set.rs @@ -0,0 +1,225 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct VolumeType<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_public: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) volume_type: VolumeType<'a>, + + /// id parameter for /v3/types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("types/{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("volume_type", serde_json::to_value(&self.volume_type)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume_type".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume_type(VolumeTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .volume_type(VolumeTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "volume_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/types/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_type(VolumeTypeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/types/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_type(VolumeTypeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/type/volume_type_access.rs b/sdk/block-storage/src/v3/type/volume_type_access.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/type/volume_type_access.rs rename to sdk/block-storage/src/v3/type/volume_type_access.rs diff --git a/sdk/block-storage/src/v3/type/volume_type_access/get.rs b/sdk/block-storage/src/v3/type/volume_type_access/get.rs new file mode 100644 index 000000000..1e9871a10 --- /dev/null +++ b/sdk/block-storage/src/v3/type/volume_type_access/get.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// type_id parameter for /v3/types/{type_id}/os-volume-type-access/{id} + /// API + #[builder(default, setter(into))] + type_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 Volume_Type_Access. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "types/{type_id}/os-volume-type-access", + type_id = self.type_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume_type_access".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volume_type_access" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/types/{type_id}/os-volume-type-access", + type_id = "type_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type_access": {} })); + }); + + let endpoint = Request::builder().type_id("type_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/types/{type_id}/os-volume-type-access", + type_id = "type_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume_type_access": {} })); + }); + + let endpoint = Request::builder() + .type_id("type_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/version.rs b/sdk/block-storage/src/v3/version.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/version.rs rename to sdk/block-storage/src/v3/version.rs diff --git a/sdk/block-storage/src/v3/version/get.rs b/sdk/block-storage/src/v3/version/get.rs new file mode 100644 index 000000000..d938bad8b --- /dev/null +++ b/sdk/block-storage/src/v3/version/get.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`. + +//! Shows details for Block Storage API v3. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume.rs b/sdk/block-storage/src/v3/volume.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/volume.rs rename to sdk/block-storage/src/v3/volume.rs diff --git a/sdk/block-storage/src/v3/volume/create_30.rs b/sdk/block-storage/src/v3/volume/create_30.rs new file mode 100644 index 000000000..b2ea6834e --- /dev/null +++ b/sdk/block-storage/src/v3/volume/create_30.rs @@ -0,0 +1,357 @@ +// 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`. + +//! Creates a new volume. +//! +//! | | | | --- | --- | | param req: | the request | | param body: | the +//! request body | | returns: | dict -- the new volume dictionary | | raises +//! HTTPNotFound, HTTPBadRequest: | | | | | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `volume` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + /// The name of the availability zone. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// The UUID of the consistency group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) consistencygroup_id: Option>>, + + /// The volume description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) display_description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) display_name: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_id: Option>>, + + /// The UUID of the image from which you want to create the volume. + /// Required to create a bootable volume. + /// + /// **New in version 3.46**: Instead of directly consuming a zero-byte + /// image that has been created by the Compute service when an instance + /// snapshot was requested, the Block Storage service will use the + /// `snapshot_id` contained in the `block_device_mapping` image property to + /// locate the volume snapshot, and will use that to create the volume + /// instead. + #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_ref: Option>>, + + /// One or more metadata key and value pairs to be associated with the new + /// volume. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) multiattach: Option>, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The size of the volume, in gibibytes (GiB). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) size: Option>, + + /// The UUID of the consistency group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) snapshot_id: Option>>, + + /// The UUID of the consistency group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) source_volid: Option>>, + + /// The volume type (either name or ID). To create an environment with + /// multiple-storage back ends, you must specify a volume type. Block + /// Storage volume back ends are spawned as children to `cinder- volume`, + /// and they are keyed from a unique queue. They are named + /// `cinder- volume.HOST.BACKEND`. For example, + /// `cinder- volume.ubuntu.lvmdriver`. When a volume is created, the + /// scheduler chooses an appropriate back end to handle the request based + /// on the volume type. Default is `None`. For information about how to use + /// volume types to create multiple- storage back ends, see + /// [Configure multiple-storage back ends](https://docs.openstack.org/cinder/latest/admin/blockstorage-multi-backend.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> VolumeBuilder<'a> { + /// One or more metadata key and value pairs to be associated with the new + /// volume. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The dictionary of data to send to the scheduler. + #[builder(default, private, setter(into, name = "_os_sch_hnt_scheduler_hints"))] + pub(crate) os_sch_hnt_scheduler_hints: Option, Value>>>, + + /// A `volume` object. + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[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> { + /// The dictionary of data to send to the scheduler. + pub fn os_sch_hnt_scheduler_hints(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.os_sch_hnt_scheduler_hints + .get_or_insert(None) + .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 Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.os_sch_hnt_scheduler_hints { + params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); + } + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "volume" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/volumes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/create_313.rs b/sdk/block-storage/src/v3/volume/create_313.rs new file mode 100644 index 000000000..7b865d8f0 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/create_313.rs @@ -0,0 +1,361 @@ +// 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`. + +//! Creates a new volume. +//! +//! | | | | --- | --- | | param req: | the request | | param body: | the +//! request body | | returns: | dict -- the new volume dictionary | | raises +//! HTTPNotFound, HTTPBadRequest: | | | | | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `volume` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + /// The name of the availability zone. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// The UUID of the consistency group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) consistencygroup_id: Option>>, + + /// The volume description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) display_description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) display_name: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group_id: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_id: Option>>, + + /// The UUID of the image from which you want to create the volume. + /// Required to create a bootable volume. + /// + /// **New in version 3.46**: Instead of directly consuming a zero-byte + /// image that has been created by the Compute service when an instance + /// snapshot was requested, the Block Storage service will use the + /// `snapshot_id` contained in the `block_device_mapping` image property to + /// locate the volume snapshot, and will use that to create the volume + /// instead. + #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_ref: Option>>, + + /// One or more metadata key and value pairs to be associated with the new + /// volume. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) multiattach: Option>, + + /// The volume name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The size of the volume, in gibibytes (GiB). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) size: Option>, + + /// The UUID of the consistency group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) snapshot_id: Option>>, + + /// The UUID of the consistency group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) source_volid: Option>>, + + /// The volume type (either name or ID). To create an environment with + /// multiple-storage back ends, you must specify a volume type. Block + /// Storage volume back ends are spawned as children to `cinder- volume`, + /// and they are keyed from a unique queue. They are named + /// `cinder- volume.HOST.BACKEND`. For example, + /// `cinder- volume.ubuntu.lvmdriver`. When a volume is created, the + /// scheduler chooses an appropriate back end to handle the request based + /// on the volume type. Default is `None`. For information about how to use + /// volume types to create multiple- storage back ends, see + /// [Configure multiple-storage back ends](https://docs.openstack.org/cinder/latest/admin/blockstorage-multi-backend.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> VolumeBuilder<'a> { + /// One or more metadata key and value pairs to be associated with the new + /// volume. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The dictionary of data to send to the scheduler. + #[builder(default, private, setter(into, name = "_os_sch_hnt_scheduler_hints"))] + pub(crate) os_sch_hnt_scheduler_hints: Option, Value>>>, + + /// A `volume` object. + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[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> { + /// The dictionary of data to send to the scheduler. + pub fn os_sch_hnt_scheduler_hints(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.os_sch_hnt_scheduler_hints + .get_or_insert(None) + .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 Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.os_sch_hnt_scheduler_hints { + params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); + } + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume".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(3, 13)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "volume" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/volumes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/create_347.rs b/sdk/block-storage/src/v3/volume/create_347.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/create_347.rs rename to sdk/block-storage/src/v3/volume/create_347.rs index 5e90cee49..7b6710816 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/create_347.rs +++ b/sdk/block-storage/src/v3/volume/create_347.rs @@ -283,7 +283,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/create_353.rs b/sdk/block-storage/src/v3/volume/create_353.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/create_353.rs rename to sdk/block-storage/src/v3/volume/create_353.rs index 144363a41..88e9e7145 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/create_353.rs +++ b/sdk/block-storage/src/v3/volume/create_353.rs @@ -267,7 +267,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/volume/delete.rs b/sdk/block-storage/src/v3/volume/delete.rs new file mode 100644 index 000000000..b78f387d6 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/delete.rs @@ -0,0 +1,181 @@ +// 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 volume. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/volumes/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("volumes/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/volumes/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/volumes/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/encryption.rs b/sdk/block-storage/src/v3/volume/encryption.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/volume/encryption.rs rename to sdk/block-storage/src/v3/volume/encryption.rs diff --git a/sdk/block-storage/src/v3/volume/encryption/get.rs b/sdk/block-storage/src/v3/volume/encryption/get.rs new file mode 100644 index 000000000..f7b9e9b97 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/encryption/get.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Return a single encryption item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/volumes/{volume_id}/encryption/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// volume_id parameter for /v3/volumes/{volume_id}/encryption/{id} API + #[builder(default, setter(into))] + volume_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 Encryption. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "volumes/{volume_id}/encryption/{id}", + id = self.id.as_ref(), + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/volumes/{volume_id}/encryption/{id}", + id = "id", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_id("volume_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/volumes/{volume_id}/encryption/{id}", + id = "id", + volume_id = "volume_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") + .volume_id("volume_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/encryption/list.rs b/sdk/block-storage/src/v3/volume/encryption/list.rs new file mode 100644 index 000000000..68f1a1ebd --- /dev/null +++ b/sdk/block-storage/src/v3/volume/encryption/list.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Returns the encryption metadata for a given volume. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// volume_id parameter for /v3/volumes/{volume_id}/encryption/{id} API + #[builder(default, setter(into))] + volume_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 Encryption. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "volumes/{volume_id}/encryption", + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/volumes/{volume_id}/encryption", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().volume_id("volume_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/volumes/{volume_id}/encryption", + volume_id = "volume_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() + .volume_id("volume_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/find.rs b/sdk/block-storage/src/v3/volume/find.rs new file mode 100644 index 000000000..f614a0ebe --- /dev/null +++ b/sdk/block-storage/src/v3/volume/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::volume::{get as Get, list_detailed as List}; + +/// Find for volume 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate volume in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // volume 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/volume/get.rs b/sdk/block-storage/src/v3/volume/get.rs new file mode 100644 index 000000000..87b03ad4f --- /dev/null +++ b/sdk/block-storage/src/v3/volume/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about the given volume. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/volumes/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("volumes/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volume".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volume" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/volumes/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/volumes/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volume": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/list.rs b/sdk/block-storage/src/v3/volume/list.rs new file mode 100644 index 000000000..0052eae03 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/list.rs @@ -0,0 +1,257 @@ +// 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`. + +//! Returns a summary list of volumes. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Filters results by consumes_quota field. Resources that don’t use + /// quotas are usually temporary internal resources created to perform an + /// operation. Default is to not filter by it. Filtering by this option may + /// not be always possible in a cloud, see List Resource Filters to + /// determine whether this filter is available in your cloud. + #[builder(default)] + consumes_quota: Option, + + /// Filters results by a time that resources are created at with time + /// comparison operators: gt/gte/eq/neq/lt/lte. + #[builder(default, setter(into))] + created_at: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filters results by a time that resources are updated at with time + /// comparison operators: gt/gte/eq/neq/lt/lte. + #[builder(default, setter(into))] + updated_at: Option>, + + /// Whether to show count in API response or not, default is False. + #[builder(default)] + with_count: 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> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("consumes_quota", self.consumes_quota); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + params.push_opt("with_count", self.with_count); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volumes".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volumes" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumes": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volumes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumes": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/list_detailed.rs b/sdk/block-storage/src/v3/volume/list_detailed.rs new file mode 100644 index 000000000..96741fc00 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/list_detailed.rs @@ -0,0 +1,257 @@ +// 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`. + +//! Returns a detailed list of volumes. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Filters results by consumes_quota field. Resources that don’t use + /// quotas are usually temporary internal resources created to perform an + /// operation. Default is to not filter by it. Filtering by this option may + /// not be always possible in a cloud, see List Resource Filters to + /// determine whether this filter is available in your cloud. + #[builder(default)] + consumes_quota: Option, + + /// Filters results by a time that resources are created at with time + /// comparison operators: gt/gte/eq/neq/lt/lte. + #[builder(default, setter(into))] + created_at: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filters results by a time that resources are updated at with time + /// comparison operators: gt/gte/eq/neq/lt/lte. + #[builder(default, setter(into))] + updated_at: Option>, + + /// Whether to show count in API response or not, default is False. + #[builder(default)] + with_count: 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> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volumes/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("consumes_quota", self.consumes_quota); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + params.push_opt("with_count", self.with_count); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("volumes".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volumes" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volumes/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumes": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volumes/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumes": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/metadata.rs b/sdk/block-storage/src/v3/volume/metadata.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/volume/metadata.rs rename to sdk/block-storage/src/v3/volume/metadata.rs diff --git a/sdk/block-storage/src/v3/volume/metadata/create.rs b/sdk/block-storage/src/v3/volume/metadata/create.rs new file mode 100644 index 000000000..17c975911 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/metadata/create.rs @@ -0,0 +1,233 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// One or more metadata key and value pairs that are associated with the + /// volume. + #[builder(private, setter(into, name = "_metadata"))] + pub(crate) metadata: BTreeMap, Cow<'a, str>>, + + /// volume_id parameter for /v3/volumes/{volume_id}/metadata API + #[builder(default, setter(into))] + volume_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> { + /// One or more metadata key and value pairs that are associated with the + /// volume. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "volumes/{volume_id}/metadata", + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("metadata", serde_json::to_value(&self.metadata)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("metadata".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/volumes/{volume_id}/metadata", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .volume_id("volume_id") + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/volumes/{volume_id}/metadata", + volume_id = "volume_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .volume_id("volume_id") + .metadata(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/metadata/delete.rs b/sdk/block-storage/src/v3/volume/metadata/delete.rs new file mode 100644 index 000000000..12bacaefb --- /dev/null +++ b/sdk/block-storage/src/v3/volume/metadata/delete.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Deletes an existing metadata. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/volumes/{volume_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// volume_id parameter for /v3/volumes/{volume_id}/metadata API + #[builder(default, setter(into))] + volume_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "volumes/{volume_id}/metadata/{id}", + id = self.id.as_ref(), + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/volumes/{volume_id}/metadata/{id}", + id = "id", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_id("volume_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/volumes/{volume_id}/metadata/{id}", + id = "id", + volume_id = "volume_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") + .volume_id("volume_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/metadata/get.rs b/sdk/block-storage/src/v3/volume/metadata/get.rs new file mode 100644 index 000000000..c9d78f523 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/metadata/get.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Return a single metadata item. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/volumes/{volume_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// volume_id parameter for /v3/volumes/{volume_id}/metadata API + #[builder(default, setter(into))] + volume_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "volumes/{volume_id}/metadata/{id}", + id = self.id.as_ref(), + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("meta".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "meta" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/volumes/{volume_id}/metadata/{id}", + id = "id", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_id("volume_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/volumes/{volume_id}/metadata/{id}", + id = "id", + volume_id = "volume_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_id("volume_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/metadata/list.rs b/sdk/block-storage/src/v3/volume/metadata/list.rs new file mode 100644 index 000000000..806389a56 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/metadata/list.rs @@ -0,0 +1,191 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// volume_id parameter for /v3/volumes/{volume_id}/metadata API + #[builder(default, setter(into))] + volume_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "volumes/{volume_id}/metadata", + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("metadata".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/volumes/{volume_id}/metadata", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder().volume_id("volume_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/volumes/{volume_id}/metadata", + volume_id = "volume_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .volume_id("volume_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/metadata/replace.rs b/sdk/block-storage/src/v3/volume/metadata/replace.rs new file mode 100644 index 000000000..64302b9cb --- /dev/null +++ b/sdk/block-storage/src/v3/volume/metadata/replace.rs @@ -0,0 +1,233 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// One or more metadata key and value pairs that are associated with the + /// volume. + #[builder(private, setter(into, name = "_metadata"))] + pub(crate) metadata: BTreeMap, Cow<'a, str>>, + + /// volume_id parameter for /v3/volumes/{volume_id}/metadata API + #[builder(default, setter(into))] + volume_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> { + /// One or more metadata key and value pairs that are associated with the + /// volume. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "volumes/{volume_id}/metadata", + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("metadata", serde_json::to_value(&self.metadata)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("metadata".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/volumes/{volume_id}/metadata", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .volume_id("volume_id") + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/volumes/{volume_id}/metadata", + volume_id = "volume_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .volume_id("volume_id") + .metadata(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume/metadata/set.rs b/sdk/block-storage/src/v3/volume/metadata/set.rs new file mode 100644 index 000000000..4d92d9909 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/metadata/set.rs @@ -0,0 +1,238 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_meta"))] + pub(crate) meta: BTreeMap, Cow<'a, str>>, + + /// id parameter for /v3/volumes/{volume_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// volume_id parameter for /v3/volumes/{volume_id}/metadata API + #[builder(default, setter(into))] + volume_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> { + pub fn meta(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.meta + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "volumes/{volume_id}/metadata/{id}", + id = self.id.as_ref(), + volume_id = self.volume_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("meta", serde_json::to_value(&self.meta)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("meta".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "meta" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/volumes/{volume_id}/metadata/{id}", + id = "id", + volume_id = "volume_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_id("volume_id") + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/volumes/{volume_id}/metadata/{id}", + id = "id", + volume_id = "volume_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .volume_id("volume_id") + .meta(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_attach.rs b/sdk/block-storage/src/v3/volume/os_attach.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_attach.rs rename to sdk/block-storage/src/v3/volume/os_attach.rs index a9a91f6a4..466e01967 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_attach.rs +++ b/sdk/block-storage/src/v3/volume/os_attach.rs @@ -150,7 +150,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_begin_detaching.rs b/sdk/block-storage/src/v3/volume/os_begin_detaching.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/volume/os_begin_detaching.rs rename to sdk/block-storage/src/v3/volume/os_begin_detaching.rs index 5802f2e35..bad3b6945 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_begin_detaching.rs +++ b/sdk/block-storage/src/v3/volume/os_begin_detaching.rs @@ -125,7 +125,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_detach.rs b/sdk/block-storage/src/v3/volume/os_detach.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_detach.rs rename to sdk/block-storage/src/v3/volume/os_detach.rs index aad1f8d06..cc9341d45 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_detach.rs +++ b/sdk/block-storage/src/v3/volume/os_detach.rs @@ -130,7 +130,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_extend.rs b/sdk/block-storage/src/v3/volume/os_extend.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_extend.rs rename to sdk/block-storage/src/v3/volume/os_extend.rs index c50591eac..905607007 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_extend.rs +++ b/sdk/block-storage/src/v3/volume/os_extend.rs @@ -130,7 +130,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_extend_volume_completion.rs b/sdk/block-storage/src/v3/volume/os_extend_volume_completion.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_extend_volume_completion.rs rename to sdk/block-storage/src/v3/volume/os_extend_volume_completion.rs index de846f5e3..8310569d9 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_extend_volume_completion.rs +++ b/sdk/block-storage/src/v3/volume/os_extend_volume_completion.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/volume/os_force_delete.rs b/sdk/block-storage/src/v3/volume/os_force_delete.rs new file mode 100644 index 000000000..9829eedd9 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/os_force_delete.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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// OpenAPI specifies the field as '{}'. + #[builder(setter(into))] + pub(crate) os_force_delete: Value, + + /// id parameter for /v3/volumes/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("volumes/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "os-force_delete", + serde_json::to_value(&self.os_force_delete)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_force_delete(json!({})) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_force_delete(json!({})) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volumes/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_force_delete(json!({})) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volumes/{id}/action", 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") + .os_force_delete(json!({})) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_force_detach.rs b/sdk/block-storage/src/v3/volume/os_force_detach.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_force_detach.rs rename to sdk/block-storage/src/v3/volume/os_force_detach.rs index 47f0b0db2..1b990d40a 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_force_detach.rs +++ b/sdk/block-storage/src/v3/volume/os_force_detach.rs @@ -138,7 +138,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_initialize_connection.rs b/sdk/block-storage/src/v3/volume/os_initialize_connection.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_initialize_connection.rs rename to sdk/block-storage/src/v3/volume/os_initialize_connection.rs index 47d1a0a9e..0f1504286 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_initialize_connection.rs +++ b/sdk/block-storage/src/v3/volume/os_initialize_connection.rs @@ -134,7 +134,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_30.rs b/sdk/block-storage/src/v3/volume/os_migrate_volume_30.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_30.rs rename to sdk/block-storage/src/v3/volume/os_migrate_volume_30.rs index ef5cb1a41..9d7dad39a 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_30.rs +++ b/sdk/block-storage/src/v3/volume/os_migrate_volume_30.rs @@ -141,7 +141,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_316.rs b/sdk/block-storage/src/v3/volume/os_migrate_volume_316.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_316.rs rename to sdk/block-storage/src/v3/volume/os_migrate_volume_316.rs index d5fdcc9b3..08c46bd50 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_316.rs +++ b/sdk/block-storage/src/v3/volume/os_migrate_volume_316.rs @@ -145,7 +145,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_completion.rs b/sdk/block-storage/src/v3/volume/os_migrate_volume_completion.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_completion.rs rename to sdk/block-storage/src/v3/volume/os_migrate_volume_completion.rs index 57fd3805a..8c94989d8 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_migrate_volume_completion.rs +++ b/sdk/block-storage/src/v3/volume/os_migrate_volume_completion.rs @@ -137,7 +137,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_reimage_368.rs b/sdk/block-storage/src/v3/volume/os_reimage_368.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_reimage_368.rs rename to sdk/block-storage/src/v3/volume/os_reimage_368.rs index 3d65f0cd0..9e4b00d0b 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_reimage_368.rs +++ b/sdk/block-storage/src/v3/volume/os_reimage_368.rs @@ -134,7 +134,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_reserve.rs b/sdk/block-storage/src/v3/volume/os_reserve.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/volume/os_reserve.rs rename to sdk/block-storage/src/v3/volume/os_reserve.rs index e086cae5c..d432c03bb 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_reserve.rs +++ b/sdk/block-storage/src/v3/volume/os_reserve.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/volume/os_reset_status.rs b/sdk/block-storage/src/v3/volume/os_reset_status.rs new file mode 100644 index 000000000..117751b15 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/os_reset_status.rs @@ -0,0 +1,227 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsResetStatus<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) attach_status: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) migration_status: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) status: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) os_reset_status: OsResetStatus<'a>, + + /// id parameter for /v3/volumes/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("volumes/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "os-reset_status", + serde_json::to_value(&self.os_reset_status)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volumes/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volumes/{id}/action", 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") + .os_reset_status(OsResetStatusBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_retype.rs b/sdk/block-storage/src/v3/volume/os_retype.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_retype.rs rename to sdk/block-storage/src/v3/volume/os_retype.rs index 106d1d7b1..9696046da 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_retype.rs +++ b/sdk/block-storage/src/v3/volume/os_retype.rs @@ -142,7 +142,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_roll_detaching.rs b/sdk/block-storage/src/v3/volume/os_roll_detaching.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/volume/os_roll_detaching.rs rename to sdk/block-storage/src/v3/volume/os_roll_detaching.rs index edbbce3bb..82ecade84 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_roll_detaching.rs +++ b/sdk/block-storage/src/v3/volume/os_roll_detaching.rs @@ -125,7 +125,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_set_bootable.rs b/sdk/block-storage/src/v3/volume/os_set_bootable.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_set_bootable.rs rename to sdk/block-storage/src/v3/volume/os_set_bootable.rs index a9a366618..70db128e1 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_set_bootable.rs +++ b/sdk/block-storage/src/v3/volume/os_set_bootable.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_set_image_metadata.rs b/sdk/block-storage/src/v3/volume/os_set_image_metadata.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_set_image_metadata.rs rename to sdk/block-storage/src/v3/volume/os_set_image_metadata.rs index a5f28d198..8ee37d042 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_set_image_metadata.rs +++ b/sdk/block-storage/src/v3/volume/os_set_image_metadata.rs @@ -148,7 +148,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_show_image_metadata.rs b/sdk/block-storage/src/v3/volume/os_show_image_metadata.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/volume/os_show_image_metadata.rs rename to sdk/block-storage/src/v3/volume/os_show_image_metadata.rs index 19eeab168..433958930 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_show_image_metadata.rs +++ b/sdk/block-storage/src/v3/volume/os_show_image_metadata.rs @@ -125,7 +125,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_terminate_connection.rs b/sdk/block-storage/src/v3/volume/os_terminate_connection.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_terminate_connection.rs rename to sdk/block-storage/src/v3/volume/os_terminate_connection.rs index 43816bbd8..a821b17f2 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_terminate_connection.rs +++ b/sdk/block-storage/src/v3/volume/os_terminate_connection.rs @@ -134,7 +134,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/volume/os_unmanage.rs b/sdk/block-storage/src/v3/volume/os_unmanage.rs new file mode 100644 index 000000000..37f0a7f94 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/os_unmanage.rs @@ -0,0 +1,208 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// OpenAPI specifies the field as '{}'. + #[builder(setter(into))] + pub(crate) os_unmanage: Value, + + /// id parameter for /v3/volumes/{id}/action 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("volumes/{id}/action", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("os-unmanage", serde_json::to_value(&self.os_unmanage)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .os_unmanage(json!({})) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .os_unmanage(json!({})) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volumes/{id}/action", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .os_unmanage(json!({})) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volumes/{id}/action", 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") + .os_unmanage(json!({})) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_unreserve.rs b/sdk/block-storage/src/v3/volume/os_unreserve.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/volume/os_unreserve.rs rename to sdk/block-storage/src/v3/volume/os_unreserve.rs index c03717f3f..a52e2b275 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_unreserve.rs +++ b/sdk/block-storage/src/v3/volume/os_unreserve.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_unset_image_metadata.rs b/sdk/block-storage/src/v3/volume/os_unset_image_metadata.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_unset_image_metadata.rs rename to sdk/block-storage/src/v3/volume/os_unset_image_metadata.rs index 8bd484198..9e4b4c473 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_unset_image_metadata.rs +++ b/sdk/block-storage/src/v3/volume/os_unset_image_metadata.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_update_readonly_flag.rs b/sdk/block-storage/src/v3/volume/os_update_readonly_flag.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_update_readonly_flag.rs rename to sdk/block-storage/src/v3/volume/os_update_readonly_flag.rs index ed28c4c4e..ce08f5d0d 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_update_readonly_flag.rs +++ b/sdk/block-storage/src/v3/volume/os_update_readonly_flag.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_volume_upload_image_30.rs b/sdk/block-storage/src/v3/volume/os_volume_upload_image_30.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_volume_upload_image_30.rs rename to sdk/block-storage/src/v3/volume/os_volume_upload_image_30.rs index 6a34bc6fd..25f7ffd73 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_volume_upload_image_30.rs +++ b/sdk/block-storage/src/v3/volume/os_volume_upload_image_30.rs @@ -163,7 +163,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/os_volume_upload_image_31.rs b/sdk/block-storage/src/v3/volume/os_volume_upload_image_31.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/os_volume_upload_image_31.rs rename to sdk/block-storage/src/v3/volume/os_volume_upload_image_31.rs index a66a30e59..0c83bff0d 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/os_volume_upload_image_31.rs +++ b/sdk/block-storage/src/v3/volume/os_volume_upload_image_31.rs @@ -183,7 +183,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/revert.rs b/sdk/block-storage/src/v3/volume/revert.rs similarity index 98% rename from openstack_sdk/src/api/block_storage/v3/volume/revert.rs rename to sdk/block-storage/src/v3/volume/revert.rs index 134d1f2e4..294514dfe 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/revert.rs +++ b/sdk/block-storage/src/v3/volume/revert.rs @@ -113,7 +113,7 @@ mod tests { use super::*; #[cfg(feature = "sync")] use crate::api::Query; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; use crate::types::ServiceType; use http::{HeaderName, HeaderValue}; use httpmock::MockServer; diff --git a/openstack_sdk/src/api/block_storage/v3/volume/revert_340.rs b/sdk/block-storage/src/v3/volume/revert_340.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/revert_340.rs rename to sdk/block-storage/src/v3/volume/revert_340.rs index 1153e1a4f..73b6ff5df 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/revert_340.rs +++ b/sdk/block-storage/src/v3/volume/revert_340.rs @@ -150,7 +150,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/set_30.rs b/sdk/block-storage/src/v3/volume/set_30.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/set_30.rs rename to sdk/block-storage/src/v3/volume/set_30.rs index 01b9ba91d..2ddfce71b 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/set_30.rs +++ b/sdk/block-storage/src/v3/volume/set_30.rs @@ -164,7 +164,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/set_353.rs b/sdk/block-storage/src/v3/volume/set_353.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume/set_353.rs rename to sdk/block-storage/src/v3/volume/set_353.rs index c21d905fd..c80839a5a 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume/set_353.rs +++ b/sdk/block-storage/src/v3/volume/set_353.rs @@ -164,7 +164,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/block_storage/v3/volume/summary.rs b/sdk/block-storage/src/v3/volume/summary.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/volume/summary.rs rename to sdk/block-storage/src/v3/volume/summary.rs diff --git a/sdk/block-storage/src/v3/volume/summary/get.rs b/sdk/block-storage/src/v3/volume/summary/get.rs new file mode 100644 index 000000000..16cdab6d6 --- /dev/null +++ b/sdk/block-storage/src/v3/volume/summary/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`. + +//! Return summary of volumes. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Summary. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volumes/summary".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volumes/summary".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volumes/summary".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_manage.rs b/sdk/block-storage/src/v3/volume_manage.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/volume_manage.rs rename to sdk/block-storage/src/v3/volume_manage.rs diff --git a/sdk/block-storage/src/v3/volume_manage/create_30.rs b/sdk/block-storage/src/v3/volume_manage/create_30.rs new file mode 100644 index 000000000..677497d8f --- /dev/null +++ b/sdk/block-storage/src/v3/volume_manage/create_30.rs @@ -0,0 +1,308 @@ +// 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`. + +//! Instruct Cinder to manage a storage object. +//! +//! Manages an existing backend storage object (e.g. a Linux logical volume or +//! a SAN disk) by creating the Cinder objects required to manage it, and +//! possibly renaming the backend storage object (driver dependent) +//! +//! From an API perspective, this operation behaves very much like a volume +//! creation operation, except that properties such as image, snapshot and +//! volume references don't make sense, because we are taking an existing +//! storage object into Cinder management. +//! +//! Required HTTP Body: +//! +//! ```text +//! { +//! "volume": { +//! "host": "", +//! "cluster": "", +//! "ref": "" +//! } +//! } +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_volume +//! method to find out the accepted format of 'ref'. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'host' element refers to a cinder host +//! that is not registered. +//! +//! The volume will later enter the error state if it is discovered that 'ref' +//! is bad. +//! +//! Optional elements to 'volume' are: +//! +//! ```text +//! name A name for the new volume. +//! description A description for the new volume. +//! volume_type ID or name of a volume type to associate with +//! the new Cinder volume. Does not necessarily +//! guarantee that the managed volume will have the +//! properties described in the volume_type. The +//! driver may choose to fail if it identifies that +//! the specified volume_type is not compatible with +//! the backend storage object. +//! metadata Key/value pairs to be associated with the new +//! volume. +//! availability_zone The availability zone to associate with the new +//! volume. +//! bootable If set to True, marks the volume as bootable. +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bootable: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Value, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, +} + +impl<'a> VolumeBuilder<'a> { + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[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 Volume_Manage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-volume-manage".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-volume-manage".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-volume-manage".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() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume_manage/create_316.rs b/sdk/block-storage/src/v3/volume_manage/create_316.rs new file mode 100644 index 000000000..31c2d085d --- /dev/null +++ b/sdk/block-storage/src/v3/volume_manage/create_316.rs @@ -0,0 +1,312 @@ +// 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`. + +//! Instruct Cinder to manage a storage object. +//! +//! Manages an existing backend storage object (e.g. a Linux logical volume or +//! a SAN disk) by creating the Cinder objects required to manage it, and +//! possibly renaming the backend storage object (driver dependent) +//! +//! From an API perspective, this operation behaves very much like a volume +//! creation operation, except that properties such as image, snapshot and +//! volume references don't make sense, because we are taking an existing +//! storage object into Cinder management. +//! +//! Required HTTP Body: +//! +//! ```text +//! { +//! "volume": { +//! "host": "", +//! "cluster": "", +//! "ref": "" +//! } +//! } +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_volume +//! method to find out the accepted format of 'ref'. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'host' element refers to a cinder host +//! that is not registered. +//! +//! The volume will later enter the error state if it is discovered that 'ref' +//! is bad. +//! +//! Optional elements to 'volume' are: +//! +//! ```text +//! name A name for the new volume. +//! description A description for the new volume. +//! volume_type ID or name of a volume type to associate with +//! the new Cinder volume. Does not necessarily +//! guarantee that the managed volume will have the +//! properties described in the volume_type. The +//! driver may choose to fail if it identifies that +//! the specified volume_type is not compatible with +//! the backend storage object. +//! metadata Key/value pairs to be associated with the new +//! volume. +//! availability_zone The availability zone to associate with the new +//! volume. +//! bootable If set to True, marks the volume as bootable. +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bootable: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cluster: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Value, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, +} + +impl<'a> VolumeBuilder<'a> { + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[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 Volume_Manage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-volume-manage".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 16)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-volume-manage".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-volume-manage".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() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume_manage/get.rs b/sdk/block-storage/src/v3/volume_manage/get.rs new file mode 100644 index 000000000..78c3a3ec4 --- /dev/null +++ b/sdk/block-storage/src/v3/volume_manage/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`. + +//! Returns a summary list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Volume_Manage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-volume-manage".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-manage".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-manage".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume_manage/list_detailed.rs b/sdk/block-storage/src/v3/volume_manage/list_detailed.rs new file mode 100644 index 000000000..d0814e1b8 --- /dev/null +++ b/sdk/block-storage/src/v3/volume_manage/list_detailed.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`. + +//! Returns a detailed list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Volume_Manage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-volume-manage/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-manage/detail".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-volume-manage/detail".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer.rs b/sdk/block-storage/src/v3/volume_transfer.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/volume_transfer.rs rename to sdk/block-storage/src/v3/volume_transfer.rs diff --git a/sdk/block-storage/src/v3/volume_transfer/accept.rs b/sdk/block-storage/src/v3/volume_transfer/accept.rs new file mode 100644 index 000000000..d308eb74d --- /dev/null +++ b/sdk/block-storage/src/v3/volume_transfer/accept.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`. + +//! Accept a new volume transfer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Accept<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) auth_key: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) accept: Accept<'a>, + + /// id parameter for /v3/volume-transfers/{id}/accept 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("volume-transfers/{id}/accept", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("accept", serde_json::to_value(&self.accept)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfer".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "transfer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volume-transfers/{id}/accept", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/volume-transfers/{id}/accept", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .accept(AcceptBuilder::default().auth_key("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume_transfer/create_30.rs b/sdk/block-storage/src/v3/volume_transfer/create_30.rs new file mode 100644 index 000000000..b076d0cd8 --- /dev/null +++ b/sdk/block-storage/src/v3/volume_transfer/create_30.rs @@ -0,0 +1,221 @@ +// 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 volume transfer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The volume transfer object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Transfer<'a> { + /// The name of the object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The UUID of the volume. + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The volume transfer object. + #[builder(setter(into))] + pub(crate) transfer: Transfer<'a>, + + #[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 Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volume-transfers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("transfer", serde_json::to_value(&self.transfer)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfer".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "transfer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/volume-transfers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/volume-transfers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .transfer(TransferBuilder::default().volume_id("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/volume_transfer/create_355.rs b/sdk/block-storage/src/v3/volume_transfer/create_355.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/volume_transfer/create_355.rs rename to sdk/block-storage/src/v3/volume_transfer/create_355.rs index 7c7e0310d..6cbc715f1 100644 --- a/openstack_sdk/src/api/block_storage/v3/volume_transfer/create_355.rs +++ b/sdk/block-storage/src/v3/volume_transfer/create_355.rs @@ -143,7 +143,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/block-storage/src/v3/volume_transfer/delete.rs b/sdk/block-storage/src/v3/volume_transfer/delete.rs new file mode 100644 index 000000000..420faa529 --- /dev/null +++ b/sdk/block-storage/src/v3/volume_transfer/delete.rs @@ -0,0 +1,181 @@ +// 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 transfer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/volume-transfers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("volume-transfers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/volume-transfers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/volume-transfers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume_transfer/find.rs b/sdk/block-storage/src/v3/volume_transfer/find.rs new file mode 100644 index 000000000..5dfa0c693 --- /dev/null +++ b/sdk/block-storage/src/v3/volume_transfer/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::volume_transfer::{get as Get, list_detailed as List}; + +/// Find for volume_transfer 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate volume_transfer in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // volume_transfer 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/block-storage/src/v3/volume_transfer/get.rs b/sdk/block-storage/src/v3/volume_transfer/get.rs new file mode 100644 index 000000000..bc81df54f --- /dev/null +++ b/sdk/block-storage/src/v3/volume_transfer/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Return data about active transfers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/volume-transfers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("volume-transfers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfer".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "transfer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/volume-transfers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/volume-transfers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume_transfer/list.rs b/sdk/block-storage/src/v3/volume_transfer/list.rs new file mode 100644 index 000000000..37710d75a --- /dev/null +++ b/sdk/block-storage/src/v3/volume_transfer/list.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`. + +//! Returns a summary list of transfers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volume-transfers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfers".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "transfers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volume-transfers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volume-transfers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/block-storage/src/v3/volume_transfer/list_detailed.rs b/sdk/block-storage/src/v3/volume_transfer/list_detailed.rs new file mode 100644 index 000000000..5159e2ba1 --- /dev/null +++ b/sdk/block-storage/src/v3/volume_transfer/list_detailed.rs @@ -0,0 +1,236 @@ +// 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`. + +//! Returns a detailed list of transfers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Shows details for all project. Admin only. + #[builder(default)] + all_tenants: Option, + + /// Filter the volume transfer by public visibility. + #[builder(default)] + is_public: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of < key > [: < direction > ]. A valid direction is asc + /// (ascending) or desc (descending). + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Volume_Transfer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "volume-transfers/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_tenants", self.all_tenants); + params.push_opt("is_public", self.is_public); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("offset", self.offset); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("transfers".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "transfers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volume-transfers/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/volume-transfers/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "transfers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/worker.rs b/sdk/block-storage/src/v3/worker.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/worker.rs rename to sdk/block-storage/src/v3/worker.rs diff --git a/openstack_sdk/src/api/block_storage/v3/worker/cleanup.rs b/sdk/block-storage/src/v3/worker/cleanup.rs similarity index 100% rename from openstack_sdk/src/api/block_storage/v3/worker/cleanup.rs rename to sdk/block-storage/src/v3/worker/cleanup.rs diff --git a/openstack_sdk/src/api/block_storage/v3/worker/cleanup/create_324.rs b/sdk/block-storage/src/v3/worker/cleanup/create_324.rs similarity index 99% rename from openstack_sdk/src/api/block_storage/v3/worker/cleanup/create_324.rs rename to sdk/block-storage/src/v3/worker/cleanup/create_324.rs index 0f1117dd1..08e9d2362 100644 --- a/openstack_sdk/src/api/block_storage/v3/worker/cleanup/create_324.rs +++ b/sdk/block-storage/src/v3/worker/cleanup/create_324.rs @@ -172,7 +172,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/Cargo.toml b/sdk/compute/Cargo.toml new file mode 100644 index 000000000..d466a36d4 --- /dev/null +++ b/sdk/compute/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "openstack-sdk-compute" +description = "OpenStack SDK Compute service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/compute/src/lib.rs b/sdk/compute/src/lib.rs new file mode 100644 index 000000000..8f8ec90e7 --- /dev/null +++ b/sdk/compute/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Compute` Service bindings +pub mod v2; diff --git a/openstack_sdk/src/api/compute/v2.rs b/sdk/compute/src/v2.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2.rs rename to sdk/compute/src/v2.rs diff --git a/openstack_sdk/src/api/compute/v2/aggregate.rs b/sdk/compute/src/v2/aggregate.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/aggregate.rs rename to sdk/compute/src/v2/aggregate.rs diff --git a/openstack_sdk/src/api/compute/v2/aggregate/add_host.rs b/sdk/compute/src/v2/aggregate/add_host.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/aggregate/add_host.rs rename to sdk/compute/src/v2/aggregate/add_host.rs index 316fbd1f5..fb386b15f 100644 --- a/openstack_sdk/src/api/compute/v2/aggregate/add_host.rs +++ b/sdk/compute/src/v2/aggregate/add_host.rs @@ -130,7 +130,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/aggregate/create_20.rs b/sdk/compute/src/v2/aggregate/create_20.rs new file mode 100644 index 000000000..3727d29e8 --- /dev/null +++ b/sdk/compute/src/v2/aggregate/create_20.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Creates an aggregate. If specifying an option availability_zone, the +//! aggregate is created as an availability zone and the availability zone is +//! visible to normal users. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The host aggregate object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Aggregate<'a> { + /// The availability zone of the host aggregate. You should use a custom + /// availability zone rather than the default returned by the + /// os-availability-zone API. The availability zone must not include ‘:’ in + /// its name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// The name of the host aggregate. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The host aggregate object. + #[builder(setter(into))] + pub(crate) aggregate: Aggregate<'a>, + + #[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 Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-aggregates".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("aggregate", serde_json::to_value(&self.aggregate)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("aggregate".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "aggregate" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-aggregates".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-aggregates".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/aggregate/create_21.rs b/sdk/compute/src/v2/aggregate/create_21.rs new file mode 100644 index 000000000..fe101c338 --- /dev/null +++ b/sdk/compute/src/v2/aggregate/create_21.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Creates an aggregate. If specifying an option availability_zone, the +//! aggregate is created as an availability zone and the availability zone is +//! visible to normal users. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The host aggregate object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Aggregate<'a> { + /// The availability zone of the host aggregate. You should use a custom + /// availability zone rather than the default returned by the + /// os-availability-zone API. The availability zone must not include ‘:’ in + /// its name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// The name of the host aggregate. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The host aggregate object. + #[builder(setter(into))] + pub(crate) aggregate: Aggregate<'a>, + + #[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 Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-aggregates".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("aggregate", serde_json::to_value(&self.aggregate)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("aggregate".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "aggregate" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-aggregates".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-aggregates".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .aggregate(AggregateBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/aggregate/delete.rs b/sdk/compute/src/v2/aggregate/delete.rs new file mode 100644 index 000000000..3f58cc754 --- /dev/null +++ b/sdk/compute/src/v2/aggregate/delete.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Deletes an aggregate. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-aggregates/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-aggregates/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-aggregates/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/aggregate/find.rs b/sdk/compute/src/v2/aggregate/find.rs new file mode 100644 index 000000000..f4e0da4dc --- /dev/null +++ b/sdk/compute/src/v2/aggregate/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::aggregate::{get as Get, list as List}; + +/// Find for aggregate 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate aggregate in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // aggregate 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/compute/src/v2/aggregate/get.rs b/sdk/compute/src/v2/aggregate/get.rs new file mode 100644 index 000000000..646ed42f1 --- /dev/null +++ b/sdk/compute/src/v2/aggregate/get.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Shows details for an aggregate. Details include hosts and metadata. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-aggregates/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("aggregate".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "aggregate" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-aggregates/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-aggregates/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/image.rs b/sdk/compute/src/v2/aggregate/image.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/aggregate/image.rs rename to sdk/compute/src/v2/aggregate/image.rs diff --git a/openstack_sdk/src/api/compute/v2/aggregate/image/cache_281.rs b/sdk/compute/src/v2/aggregate/image/cache_281.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/aggregate/image/cache_281.rs rename to sdk/compute/src/v2/aggregate/image/cache_281.rs index 96059cecd..892ecdfb1 100644 --- a/openstack_sdk/src/api/compute/v2/aggregate/image/cache_281.rs +++ b/sdk/compute/src/v2/aggregate/image/cache_281.rs @@ -141,7 +141,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/aggregate/list.rs b/sdk/compute/src/v2/aggregate/list.rs new file mode 100644 index 000000000..04ec0d13e --- /dev/null +++ b/sdk/compute/src/v2/aggregate/list.rs @@ -0,0 +1,182 @@ +// 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`. + +//! Lists all aggregates. Includes the ID, name, and availability zone for each +//! aggregate. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-aggregates".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("aggregates".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "aggregates" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-aggregates".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregates": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-aggregates".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregates": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/remove_host.rs b/sdk/compute/src/v2/aggregate/remove_host.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/aggregate/remove_host.rs rename to sdk/compute/src/v2/aggregate/remove_host.rs index a0a55dbf5..cd7d66fb8 100644 --- a/openstack_sdk/src/api/compute/v2/aggregate/remove_host.rs +++ b/sdk/compute/src/v2/aggregate/remove_host.rs @@ -130,7 +130,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/aggregate/set_20.rs b/sdk/compute/src/v2/aggregate/set_20.rs new file mode 100644 index 000000000..64dcabd09 --- /dev/null +++ b/sdk/compute/src/v2/aggregate/set_20.rs @@ -0,0 +1,243 @@ +// 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`. + +//! Updates either or both the name and availability zone for an aggregate. If +//! the aggregate to be updated has host that already in the given availability +//! zone, the request will fail with 400 error. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The host aggregate object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Aggregate<'a> { + /// The availability zone of the host aggregate. You should use a custom + /// availability zone rather than the default returned by the + /// os-availability-zone API. The availability zone must not include ‘:’ in + /// its name. + /// + /// Warning + /// + /// You should not change or unset the availability zone of an aggregate + /// when that aggregate has hosts which contain servers in it since that + /// may impact the ability for those servers to move to another host. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// The name of the host aggregate. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The host aggregate object. + #[builder(setter(into))] + pub(crate) aggregate: Aggregate<'a>, + + /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-aggregates/{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("aggregate", serde_json::to_value(&self.aggregate)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("aggregate".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "aggregate" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-aggregates/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .aggregate(AggregateBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-aggregates/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .aggregate(AggregateBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/aggregate/set_21.rs b/sdk/compute/src/v2/aggregate/set_21.rs new file mode 100644 index 000000000..11d7a1186 --- /dev/null +++ b/sdk/compute/src/v2/aggregate/set_21.rs @@ -0,0 +1,243 @@ +// 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`. + +//! Updates either or both the name and availability zone for an aggregate. If +//! the aggregate to be updated has host that already in the given availability +//! zone, the request will fail with 400 error. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The host aggregate object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Aggregate<'a> { + /// The availability zone of the host aggregate. You should use a custom + /// availability zone rather than the default returned by the + /// os-availability-zone API. The availability zone must not include ‘:’ in + /// its name. + /// + /// Warning + /// + /// You should not change or unset the availability zone of an aggregate + /// when that aggregate has hosts which contain servers in it since that + /// may impact the ability for those servers to move to another host. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// The name of the host aggregate. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The host aggregate object. + #[builder(setter(into))] + pub(crate) aggregate: Aggregate<'a>, + + /// id parameter for /v2.1/os-aggregates/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-aggregates/{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("aggregate", serde_json::to_value(&self.aggregate)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("aggregate".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .aggregate(AggregateBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "aggregate" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-aggregates/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .aggregate(AggregateBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-aggregates/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregate": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .aggregate(AggregateBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/aggregate/set_metadata.rs b/sdk/compute/src/v2/aggregate/set_metadata.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/aggregate/set_metadata.rs rename to sdk/compute/src/v2/aggregate/set_metadata.rs index 657c78d7d..4075939c9 100644 --- a/openstack_sdk/src/api/compute/v2/aggregate/set_metadata.rs +++ b/sdk/compute/src/v2/aggregate/set_metadata.rs @@ -145,7 +145,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/assisted_volume_snapshot.rs b/sdk/compute/src/v2/assisted_volume_snapshot.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/assisted_volume_snapshot.rs rename to sdk/compute/src/v2/assisted_volume_snapshot.rs diff --git a/sdk/compute/src/v2/assisted_volume_snapshot/create.rs b/sdk/compute/src/v2/assisted_volume_snapshot/create.rs new file mode 100644 index 000000000..5da86a340 --- /dev/null +++ b/sdk/compute/src/v2/assisted_volume_snapshot/create.rs @@ -0,0 +1,310 @@ +// 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`. + +//! Creates an assisted volume snapshot. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400),unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "qcow2")] + Qcow2, +} + +/// Information for snapshot creation. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct CreateInfo<'a> { + /// Its an arbitrary string that gets passed back to the user. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The name of the qcow2 file that Block Storage creates, which becomes + /// the active image for the VM. + #[serde()] + #[builder(setter(into))] + pub(crate) new_file: Cow<'a, str>, + + /// The UUID for a snapshot. + #[serde()] + #[builder(setter(into))] + pub(crate) snapshot_id: Cow<'a, str>, + + /// The snapshot type. A valid value is `qcow2`. + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, +} + +/// A partial representation of a snapshot that is used to create a snapshot. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Snapshot<'a> { + /// Information for snapshot creation. + #[serde()] + #[builder(setter(into))] + pub(crate) create_info: CreateInfo<'a>, + + /// The source volume ID. + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A partial representation of a snapshot that is used to create a + /// snapshot. + #[builder(setter(into))] + pub(crate) snapshot: Snapshot<'a>, + + #[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 Assisted_Volume_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-assisted-volume-snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("snapshot", serde_json::to_value(&self.snapshot)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("snapshot".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + .create_info( + CreateInfoBuilder::default() + ._type(Type::Qcow2) + .new_file("foo") + .snapshot_id("foo") + .build() + .unwrap() + ) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + .create_info( + CreateInfoBuilder::default() + ._type(Type::Qcow2) + .new_file("foo") + .snapshot_id("foo") + .build() + .unwrap() + ) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "snapshot" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-assisted-volume-snapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot( + SnapshotBuilder::default() + .create_info( + CreateInfoBuilder::default() + ._type(Type::Qcow2) + .new_file("foo") + .snapshot_id("foo") + .build() + .unwrap(), + ) + .volume_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-assisted-volume-snapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot( + SnapshotBuilder::default() + .create_info( + CreateInfoBuilder::default() + ._type(Type::Qcow2) + .new_file("foo") + .snapshot_id("foo") + .build() + .unwrap(), + ) + .volume_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/assisted_volume_snapshot/delete.rs b/sdk/compute/src/v2/assisted_volume_snapshot/delete.rs new file mode 100644 index 000000000..43ddf7512 --- /dev/null +++ b/sdk/compute/src/v2/assisted_volume_snapshot/delete.rs @@ -0,0 +1,199 @@ +// 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`. + +//! Deletes an assisted volume snapshot. +//! +//! To make this request, add the `delete_info` query parameter to the URI, as +//! follows: +//! +//! DELETE +//! /os-assisted-volume-snapshots/421752a6-acf6-4b2d-bc7a-119f9148cd8c?delete_info=’{“volume_id”: +//! “521752a6-acf6-4b2d-bc7a-119f9148cd8c”}’ +//! +//! Normal response codes: 204 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + delete_info: Option>, + + /// id parameter for /v2.1/os-assisted-volume-snapshots/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Assisted_Volume_Snapshot. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-assisted-volume-snapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("delete_info", self.delete_info.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-assisted-volume-snapshots/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-assisted-volume-snapshots/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/availability_zone.rs b/sdk/compute/src/v2/availability_zone.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/availability_zone.rs rename to sdk/compute/src/v2/availability_zone.rs diff --git a/sdk/compute/src/v2/availability_zone/list.rs b/sdk/compute/src/v2/availability_zone/list.rs new file mode 100644 index 000000000..7c069c08a --- /dev/null +++ b/sdk/compute/src/v2/availability_zone/list.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Lists availability zone information. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-availability-zone".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("availabilityZoneInfo".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availabilityZoneInfo" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-availability-zone".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availabilityZoneInfo": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-availability-zone".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availabilityZoneInfo": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/availability_zone/list_detail.rs b/sdk/compute/src/v2/availability_zone/list_detail.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/availability_zone/list_detail.rs rename to sdk/compute/src/v2/availability_zone/list_detail.rs index 5cf7a7622..0d91ba1d0 100644 --- a/openstack_sdk/src/api/compute/v2/availability_zone/list_detail.rs +++ b/sdk/compute/src/v2/availability_zone/list_detail.rs @@ -111,7 +111,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/console_auth_token.rs b/sdk/compute/src/v2/console_auth_token.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/console_auth_token.rs rename to sdk/compute/src/v2/console_auth_token.rs diff --git a/sdk/compute/src/v2/console_auth_token/get.rs b/sdk/compute/src/v2/console_auth_token/get.rs new file mode 100644 index 000000000..ef66d5c75 --- /dev/null +++ b/sdk/compute/src/v2/console_auth_token/get.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Given the console authentication token for a server, shows the related +//! connection information. +//! +//! Nova HyperV driver has been removed therefore requests for RDP console +//! connection information will always return an http 400 error. Starting from +//! microversion 2.31 it’s available for all other console types. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-console-auth-tokens/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Console_Auth_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-console-auth-tokens/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("console".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "console" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-console-auth-tokens/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "console": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-console-auth-tokens/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "console": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/extension.rs b/sdk/compute/src/v2/extension.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/extension.rs rename to sdk/compute/src/v2/extension.rs diff --git a/sdk/compute/src/v2/extension/get.rs b/sdk/compute/src/v2/extension/get.rs new file mode 100644 index 000000000..f2de640dc --- /dev/null +++ b/sdk/compute/src/v2/extension/get.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Shows details for an extension, by alias. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/extensions/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Extension. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("extensions/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("extension".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "extension" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/extensions/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extension": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/extensions/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extension": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/extension/list.rs b/sdk/compute/src/v2/extension/list.rs new file mode 100644 index 000000000..91562d860 --- /dev/null +++ b/sdk/compute/src/v2/extension/list.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Lists all extensions to the API. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Extension. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "extensions".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("extensions".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "extensions" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/extensions".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extensions": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/extensions".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extensions": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/flavor.rs b/sdk/compute/src/v2/flavor.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/flavor.rs rename to sdk/compute/src/v2/flavor.rs diff --git a/openstack_sdk/src/api/compute/v2/flavor/add_tenant_access.rs b/sdk/compute/src/v2/flavor/add_tenant_access.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/flavor/add_tenant_access.rs rename to sdk/compute/src/v2/flavor/add_tenant_access.rs index 00522c538..6951e65a0 100644 --- a/openstack_sdk/src/api/compute/v2/flavor/add_tenant_access.rs +++ b/sdk/compute/src/v2/flavor/add_tenant_access.rs @@ -136,7 +136,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/flavor/create_20.rs b/sdk/compute/src/v2/flavor/create_20.rs new file mode 100644 index 000000000..d411bef12 --- /dev/null +++ b/sdk/compute/src/v2/flavor/create_20.rs @@ -0,0 +1,314 @@ +// 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`. + +//! Creates a flavor. +//! +//! Creating a flavor is typically only available to administrators of a cloud +//! because this has implications for scheduling efficiently in the cloud. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The ID and links for the flavor for your server instance. A flavor is a +/// combination of memory, disk size, and CPUs. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavor<'a> { + /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 + /// (the default), no dedicated swap disk will be created. + #[serde()] + #[builder(setter(into))] + pub(crate) disk: i32, + + /// Only alphanumeric characters with hyphen ‘-’, underscore ‘\_’, spaces + /// and dots ‘.’ are permitted. If an ID is not provided, then a default + /// UUID will be assigned. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>>, + + /// The display name of a flavor. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// Whether the flavor is public (available to all projects) or scoped to a + /// set of projects. Default is True if not specified. + #[serde( + rename = "os-flavor-access:is_public", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) os_flavor_access_is_public: Option, + + /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 + /// (the default), no dedicated swap disk will be created. + #[serde( + rename = "OS-FLV-EXT-DATA:ephemeral", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) os_flv_ext_data_ephemeral: Option, + + /// The number of virtual CPUs that will be allocated to the server. + #[serde()] + #[builder(setter(into))] + pub(crate) ram: i32, + + /// The receive / transmit factor (as a float) that will be set on ports if + /// the network backend supports the QOS extension. Otherwise it will be + /// ignored. It defaults to 1.0. + /// + /// **Available until version 2.101** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rxtx_factor: Option>, + + /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 + /// (the default), no dedicated swap disk will be created. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) swap: Option, + + /// The number of virtual CPUs that will be allocated to the server. + #[serde()] + #[builder(setter(into))] + pub(crate) vcpus: i32, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID and links for the flavor for your server instance. A flavor is a + /// combination of memory, disk size, and CPUs. + #[builder(setter(into))] + pub(crate) flavor: Flavor<'a>, + + #[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 Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "flavors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("flavor", serde_json::to_value(&self.flavor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/flavors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/flavors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/create_21.rs b/sdk/compute/src/v2/flavor/create_21.rs new file mode 100644 index 000000000..dc0cc55df --- /dev/null +++ b/sdk/compute/src/v2/flavor/create_21.rs @@ -0,0 +1,314 @@ +// 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`. + +//! Creates a flavor. +//! +//! Creating a flavor is typically only available to administrators of a cloud +//! because this has implications for scheduling efficiently in the cloud. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The ID and links for the flavor for your server instance. A flavor is a +/// combination of memory, disk size, and CPUs. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavor<'a> { + /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 + /// (the default), no dedicated swap disk will be created. + #[serde()] + #[builder(setter(into))] + pub(crate) disk: i32, + + /// Only alphanumeric characters with hyphen ‘-’, underscore ‘\_’, spaces + /// and dots ‘.’ are permitted. If an ID is not provided, then a default + /// UUID will be assigned. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>>, + + /// The display name of a flavor. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// Whether the flavor is public (available to all projects) or scoped to a + /// set of projects. Default is True if not specified. + #[serde( + rename = "os-flavor-access:is_public", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) os_flavor_access_is_public: Option, + + /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 + /// (the default), no dedicated swap disk will be created. + #[serde( + rename = "OS-FLV-EXT-DATA:ephemeral", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) os_flv_ext_data_ephemeral: Option, + + /// The number of virtual CPUs that will be allocated to the server. + #[serde()] + #[builder(setter(into))] + pub(crate) ram: i32, + + /// The receive / transmit factor (as a float) that will be set on ports if + /// the network backend supports the QOS extension. Otherwise it will be + /// ignored. It defaults to 1.0. + /// + /// **Available until version 2.101** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rxtx_factor: Option>, + + /// The size of a dedicated swap disk that will be allocated, in MiB. If 0 + /// (the default), no dedicated swap disk will be created. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) swap: Option, + + /// The number of virtual CPUs that will be allocated to the server. + #[serde()] + #[builder(setter(into))] + pub(crate) vcpus: i32, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID and links for the flavor for your server instance. A flavor is a + /// combination of memory, disk size, and CPUs. + #[builder(setter(into))] + pub(crate) flavor: Flavor<'a>, + + #[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 Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "flavors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("flavor", serde_json::to_value(&self.flavor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/flavors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/flavors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor( + FlavorBuilder::default() + .disk(123) + .name("foo") + .ram(123) + .vcpus(123) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/flavor/create_2102.rs b/sdk/compute/src/v2/flavor/create_2102.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/flavor/create_2102.rs rename to sdk/compute/src/v2/flavor/create_2102.rs index 09a8e86cc..1b35f62b6 100644 --- a/openstack_sdk/src/api/compute/v2/flavor/create_2102.rs +++ b/sdk/compute/src/v2/flavor/create_2102.rs @@ -196,7 +196,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/flavor/create_255.rs b/sdk/compute/src/v2/flavor/create_255.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/flavor/create_255.rs rename to sdk/compute/src/v2/flavor/create_255.rs index 7ffdec199..324c1c0e1 100644 --- a/openstack_sdk/src/api/compute/v2/flavor/create_255.rs +++ b/sdk/compute/src/v2/flavor/create_255.rs @@ -205,7 +205,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/flavor/delete.rs b/sdk/compute/src/v2/flavor/delete.rs new file mode 100644 index 000000000..2157b06fb --- /dev/null +++ b/sdk/compute/src/v2/flavor/delete.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Deletes a flavor. +//! +//! This is typically an admin only action. Deleting a flavor that is in use by +//! existing servers is not recommended as it can cause incorrect data to be +//! returned to the user under some operations. +//! +//! Normal response codes: 202 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/flavors/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("flavors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/flavors/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/flavors/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/flavor/extra_spec.rs b/sdk/compute/src/v2/flavor/extra_spec.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/flavor/extra_spec.rs rename to sdk/compute/src/v2/flavor/extra_spec.rs diff --git a/sdk/compute/src/v2/flavor/extra_spec/create.rs b/sdk/compute/src/v2/flavor/extra_spec/create.rs new file mode 100644 index 000000000..c28e3c4a7 --- /dev/null +++ b/sdk/compute/src/v2/flavor/extra_spec/create.rs @@ -0,0 +1,243 @@ +// 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`. + +//! Creates extra specs for a flavor, by ID. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary of the flavor’s extra-specs key-and-value pairs. It + /// appears in the os-extra-specs’ “create” REQUEST body, as well as the + /// os-extra-specs’ “create” and “list” RESPONSE body. + #[builder(private, setter(into, name = "_extra_specs"))] + pub(crate) extra_specs: BTreeMap, Cow<'a, str>>, + + /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} + /// API + #[builder(default, setter(into))] + flavor_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> { + /// A dictionary of the flavor’s extra-specs key-and-value pairs. It + /// appears in the os-extra-specs’ “create” REQUEST body, as well as the + /// os-extra-specs’ “create” and “list” RESPONSE body. + pub fn extra_specs(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.extra_specs + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "flavors/{flavor_id}/os-extra_specs", + flavor_id = self.flavor_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("extra_specs", serde_json::to_value(&self.extra_specs)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("extra_specs".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .extra_specs(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .extra_specs(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "extra_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/flavors/{flavor_id}/os-extra_specs", + flavor_id = "flavor_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .extra_specs(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/flavors/{flavor_id}/os-extra_specs", + flavor_id = "flavor_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .extra_specs(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/extra_spec/delete.rs b/sdk/compute/src/v2/flavor/extra_spec/delete.rs new file mode 100644 index 000000000..0b4cc6d43 --- /dev/null +++ b/sdk/compute/src/v2/flavor/extra_spec/delete.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`. + +//! Deletes an extra spec, by key, for a flavor, by ID. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = "flavor_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() + .flavor_id("flavor_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/extra_spec/get.rs b/sdk/compute/src/v2/flavor/extra_spec/get.rs new file mode 100644 index 000000000..2bfb1e6e3 --- /dev/null +++ b/sdk/compute/src/v2/flavor/extra_spec/get.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`. + +//! Shows an extra spec, by key, for a flavor, by ID. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = "flavor_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() + .flavor_id("flavor_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/extra_spec/list.rs b/sdk/compute/src/v2/flavor/extra_spec/list.rs new file mode 100644 index 000000000..117c4f4b7 --- /dev/null +++ b/sdk/compute/src/v2/flavor/extra_spec/list.rs @@ -0,0 +1,198 @@ +// 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`. + +//! Lists all extra specs for a flavor, by ID. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} + /// API + #[builder(default, setter(into))] + flavor_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 Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/os-extra_specs", + flavor_id = self.flavor_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("extra_specs".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "extra_specs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/flavors/{flavor_id}/os-extra_specs", + flavor_id = "flavor_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/flavors/{flavor_id}/os-extra_specs", + flavor_id = "flavor_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extra_specs": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/extra_spec/set.rs b/sdk/compute/src/v2/flavor/extra_spec/set.rs new file mode 100644 index 000000000..5010b7541 --- /dev/null +++ b/sdk/compute/src/v2/flavor/extra_spec/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`. + +//! Updates an extra spec, by key, for a flavor, by ID. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.1/flavors/{flavor_id}/os-extra_specs/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Cow<'a, str>>, +} +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 Extra_Spec. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), serde_json::Value::from(val.clone())); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/flavors/{flavor_id}/os-extra_specs/{id}", + flavor_id = "flavor_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() + .flavor_id("flavor_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/find.rs b/sdk/compute/src/v2/flavor/find.rs new file mode 100644 index 000000000..15496c6c0 --- /dev/null +++ b/sdk/compute/src/v2/flavor/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::flavor::{get as Get, list_detailed as List}; + +/// Find for flavor 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate flavor in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // flavor 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") + && let Some(name) = name_as_val.as_str() + && 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/compute/v2/flavor/flavor_access.rs b/sdk/compute/src/v2/flavor/flavor_access.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/flavor/flavor_access.rs rename to sdk/compute/src/v2/flavor/flavor_access.rs diff --git a/sdk/compute/src/v2/flavor/flavor_access/list.rs b/sdk/compute/src/v2/flavor/flavor_access/list.rs new file mode 100644 index 000000000..8e632dfb5 --- /dev/null +++ b/sdk/compute/src/v2/flavor/flavor_access/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`. + +//! Lists flavor access information. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.1/flavors/{flavor_id}/os-flavor-access API + #[builder(default, setter(into))] + flavor_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 Flavor_Access. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/os-flavor-access", + flavor_id = self.flavor_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("flavor_access".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavor_access" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/flavors/{flavor_id}/os-flavor-access", + flavor_id = "flavor_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor_access": {} })); + }); + + let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/flavors/{flavor_id}/os-flavor-access", + flavor_id = "flavor_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor_access": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/get.rs b/sdk/compute/src/v2/flavor/get.rs new file mode 100644 index 000000000..be09c131b --- /dev/null +++ b/sdk/compute/src/v2/flavor/get.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Shows details for a flavor. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/flavors/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("flavors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/flavors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/flavors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/list.rs b/sdk/compute/src/v2/flavor/list.rs new file mode 100644 index 000000000..0eb5482ba --- /dev/null +++ b/sdk/compute/src/v2/flavor/list.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`. + +//! Lists all flavors accessible to your project. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + is_public: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + min_disk: Option>, + + #[builder(default, setter(into))] + min_ram: Option>, + + #[builder(default, setter(into))] + name: Option>, + + #[builder(default, setter(into))] + sort_dir: Option>, + + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "flavors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("is_public", self.is_public.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("minDisk", self.min_disk.as_ref()); + params.push_opt("minRam", self.min_ram.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("flavors".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavors" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/flavors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/flavors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/flavor/list_detailed.rs b/sdk/compute/src/v2/flavor/list_detailed.rs new file mode 100644 index 000000000..253a5d632 --- /dev/null +++ b/sdk/compute/src/v2/flavor/list_detailed.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`. + +//! Lists flavors with details. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + is_public: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + min_disk: Option>, + + #[builder(default, setter(into))] + min_ram: Option>, + + #[builder(default, setter(into))] + name: Option>, + + #[builder(default, setter(into))] + sort_dir: Option>, + + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "flavors/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("is_public", self.is_public.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("minDisk", self.min_disk.as_ref()); + params.push_opt("minRam", self.min_ram.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("flavors".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavors" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/flavors/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/flavors/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/flavor/remove_tenant_access.rs b/sdk/compute/src/v2/flavor/remove_tenant_access.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/flavor/remove_tenant_access.rs rename to sdk/compute/src/v2/flavor/remove_tenant_access.rs index ddaaf14a0..f70c799ff 100644 --- a/openstack_sdk/src/api/compute/v2/flavor/remove_tenant_access.rs +++ b/sdk/compute/src/v2/flavor/remove_tenant_access.rs @@ -136,7 +136,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/flavor/set_255.rs b/sdk/compute/src/v2/flavor/set_255.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/flavor/set_255.rs rename to sdk/compute/src/v2/flavor/set_255.rs index 4894ec83e..90a627a13 100644 --- a/openstack_sdk/src/api/compute/v2/flavor/set_255.rs +++ b/sdk/compute/src/v2/flavor/set_255.rs @@ -149,7 +149,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/floating_ip.rs b/sdk/compute/src/v2/floating_ip.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/floating_ip.rs rename to sdk/compute/src/v2/floating_ip.rs diff --git a/sdk/compute/src/v2/floating_ip/create.rs b/sdk/compute/src/v2/floating_ip/create.rs new file mode 100644 index 000000000..4fee10405 --- /dev/null +++ b/sdk/compute/src/v2/floating_ip/create.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Creates, or allocates, a floating IP address for the current project. By +//! default, the floating IP address is allocated from the public pool. +//! +//! If more than one floating IP address pool is available, use the `pool` +//! parameter to specify from which pool to allocate the IP address. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Floating_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-floating-ips".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("floating_ip".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floating_ip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-floating-ips".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floating_ip": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-floating-ips".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floating_ip": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/floating_ip/delete.rs b/sdk/compute/src/v2/floating_ip/delete.rs new file mode 100644 index 000000000..2e19e0900 --- /dev/null +++ b/sdk/compute/src/v2/floating_ip/delete.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Deletes, or deallocates, a floating IP address from the current project and +//! returns it to the pool from which it was allocated. +//! +//! If the IP address is still associated with a running instance, it is +//! automatically disassociated from that instance. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 202 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-floating-ips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floating_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-floating-ips/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-floating-ips/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-floating-ips/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/floating_ip/get.rs b/sdk/compute/src/v2/floating_ip/get.rs new file mode 100644 index 000000000..084327631 --- /dev/null +++ b/sdk/compute/src/v2/floating_ip/get.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Shows details for a floating IP address, by ID, that is associated with the +//! tenant or account. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-floating-ips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floating_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-floating-ips/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("floating_ip".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floating_ip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-floating-ips/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floating_ip": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-floating-ips/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floating_ip": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/floating_ip/list.rs b/sdk/compute/src/v2/floating_ip/list.rs new file mode 100644 index 000000000..3f65175b6 --- /dev/null +++ b/sdk/compute/src/v2/floating_ip/list.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Lists floating IP addresses associated with the tenant or account. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Floating_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-floating-ips".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("floating_ips".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floating_ips" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-floating-ips".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floating_ips": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-floating-ips".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floating_ips": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/floating_ips_bulk.rs b/sdk/compute/src/v2/floating_ips_bulk.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/floating_ips_bulk.rs rename to sdk/compute/src/v2/floating_ips_bulk.rs diff --git a/sdk/compute/src/v2/floating_ips_bulk/create.rs b/sdk/compute/src/v2/floating_ips_bulk/create.rs new file mode 100644 index 000000000..2b6150661 --- /dev/null +++ b/sdk/compute/src/v2/floating_ips_bulk/create.rs @@ -0,0 +1,179 @@ +// 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`. + +//! Bulk-creates floating IPs. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409), gone(410) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Floating_Ips_Bulk. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-floating-ips-bulk".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-floating-ips-bulk".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-floating-ips-bulk".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/floating_ips_bulk/get.rs b/sdk/compute/src/v2/floating_ips_bulk/get.rs new file mode 100644 index 000000000..7dc93731d --- /dev/null +++ b/sdk/compute/src/v2/floating_ips_bulk/get.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Lists all floating IPs for a host. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), +//! gone(410) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-floating-ips-bulk/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floating_Ips_Bulk. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-floating-ips-bulk/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-floating-ips-bulk/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-floating-ips-bulk/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/floating_ips_bulk/list.rs b/sdk/compute/src/v2/floating_ips_bulk/list.rs new file mode 100644 index 000000000..e4c70038d --- /dev/null +++ b/sdk/compute/src/v2/floating_ips_bulk/list.rs @@ -0,0 +1,179 @@ +// 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`. + +//! Lists all floating IPs. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), +//! gone(410) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Floating_Ips_Bulk. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-floating-ips-bulk".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-floating-ips-bulk".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-floating-ips-bulk".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/floating_ips_bulk/set.rs b/sdk/compute/src/v2/floating_ips_bulk/set.rs new file mode 100644 index 000000000..a0b032819 --- /dev/null +++ b/sdk/compute/src/v2/floating_ips_bulk/set.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-floating-ips-bulk/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floating_Ips_Bulk. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-floating-ips-bulk/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-floating-ips-bulk/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-floating-ips-bulk/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor.rs b/sdk/compute/src/v2/hypervisor.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/hypervisor.rs rename to sdk/compute/src/v2/hypervisor.rs diff --git a/sdk/compute/src/v2/hypervisor/find.rs b/sdk/compute/src/v2/hypervisor/find.rs new file mode 100644 index 000000000..e101f2a77 --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/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 tracing::trace; + +use crate::api::find::Findable; +use crate::api::rest_endpoint_prelude::*; + +use crate::api::{ApiError, RestClient}; + +use crate::v2::hypervisor::{get as Get, list_detailed as List}; + +/// Find for hypervisor 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<'a> RequestBuilder<'a> { + /// 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<'a>; + 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<'a> { + 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 hypervisor in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // hypervisor 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/sdk/compute/src/v2/hypervisor/get.rs b/sdk/compute/src/v2/hypervisor/get.rs new file mode 100644 index 000000000..1ee67609c --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/get.rs @@ -0,0 +1,199 @@ +// 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`. + +//! Shows details for a given hypervisor. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-hypervisors/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(default)] + with_servers: 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> { + /// Add a single header to the Hypervisor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-hypervisors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("with_servers", self.with_servers); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("hypervisor".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "hypervisor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisor": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/hypervisor/list.rs b/sdk/compute/src/v2/hypervisor/list.rs new file mode 100644 index 000000000..ae7dea13a --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/list.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Lists hypervisors. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + hypervisor_hostname_pattern: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default)] + with_servers: 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> { + /// Add a single header to the Hypervisor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-hypervisors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt( + "hypervisor_hostname_pattern", + self.hypervisor_hostname_pattern.as_ref(), + ); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("with_servers", self.with_servers); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("hypervisors".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "hypervisors" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hypervisors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisors": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hypervisors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisors": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/hypervisor/list_detailed.rs b/sdk/compute/src/v2/hypervisor/list_detailed.rs new file mode 100644 index 000000000..64f0448f4 --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/list_detailed.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Lists hypervisors details. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + hypervisor_hostname_pattern: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default)] + with_servers: 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> { + /// Add a single header to the Hypervisor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-hypervisors/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt( + "hypervisor_hostname_pattern", + self.hypervisor_hostname_pattern.as_ref(), + ); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("with_servers", self.with_servers); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("hypervisors".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "hypervisors" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hypervisors/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisors": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hypervisors/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisors": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/search.rs b/sdk/compute/src/v2/hypervisor/search.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/hypervisor/search.rs rename to sdk/compute/src/v2/hypervisor/search.rs diff --git a/sdk/compute/src/v2/hypervisor/search/get.rs b/sdk/compute/src/v2/hypervisor/search/get.rs new file mode 100644 index 000000000..934368e3e --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/search/get.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Search hypervisor by a given hypervisor host name or portion of it. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response code: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-hypervisors/{id}/search 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<'a> RequestBuilder<'a> { + /// Add a single header to the Search. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-hypervisors/{id}/search", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}/search", 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}/search", 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/server.rs b/sdk/compute/src/v2/hypervisor/server.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/hypervisor/server.rs rename to sdk/compute/src/v2/hypervisor/server.rs diff --git a/sdk/compute/src/v2/hypervisor/server/get.rs b/sdk/compute/src/v2/hypervisor/server/get.rs new file mode 100644 index 000000000..d55772b78 --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/server/get.rs @@ -0,0 +1,193 @@ +// 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 servers belong to each hypervisor whose host name is matching a +//! given hypervisor host name or portion of it. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response code: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-hypervisors/{id}/servers 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<'a> RequestBuilder<'a> { + /// Add a single header to the Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-hypervisors/{id}/servers", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("servers".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "servers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}/servers", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "servers": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}/servers", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "servers": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/statistic.rs b/sdk/compute/src/v2/hypervisor/statistic.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/hypervisor/statistic.rs rename to sdk/compute/src/v2/hypervisor/statistic.rs diff --git a/sdk/compute/src/v2/hypervisor/statistic/get.rs b/sdk/compute/src/v2/hypervisor/statistic/get.rs new file mode 100644 index 000000000..d55404d54 --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/statistic/get.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Shows summary statistics for all enabled hypervisors over all compute +//! nodes. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Statistic. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-hypervisors/statistics".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("hypervisor_statistics".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "hypervisor_statistics" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hypervisors/statistics".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisor_statistics": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-hypervisors/statistics".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisor_statistics": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/hypervisor/uptime.rs b/sdk/compute/src/v2/hypervisor/uptime.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/hypervisor/uptime.rs rename to sdk/compute/src/v2/hypervisor/uptime.rs diff --git a/sdk/compute/src/v2/hypervisor/uptime/get.rs b/sdk/compute/src/v2/hypervisor/uptime/get.rs new file mode 100644 index 000000000..fb4acbbeb --- /dev/null +++ b/sdk/compute/src/v2/hypervisor/uptime/get.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows the uptime for a given hypervisor. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), NotImplemented(501) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-hypervisors/{id}/uptime 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<'a> RequestBuilder<'a> { + /// Add a single header to the Uptime. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-hypervisors/{id}/uptime", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("hypervisor".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "hypervisor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}/uptime", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisor": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-hypervisors/{id}/uptime", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "hypervisor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/instance_usage_audit_log.rs b/sdk/compute/src/v2/instance_usage_audit_log.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/instance_usage_audit_log.rs rename to sdk/compute/src/v2/instance_usage_audit_log.rs diff --git a/sdk/compute/src/v2/instance_usage_audit_log/get.rs b/sdk/compute/src/v2/instance_usage_audit_log/get.rs new file mode 100644 index 000000000..b864939b9 --- /dev/null +++ b/sdk/compute/src/v2/instance_usage_audit_log/get.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Lists usage audits that occurred before a specified time. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filters the response by the date and time before which to list usage + /// audits. + #[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<'a> RequestBuilder<'a> { + /// Add a single header to the Instance_Usage_Audit_Log. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-instance_usage_audit_log/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-instance_usage_audit_log/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-instance_usage_audit_log/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/instance_usage_audit_log/list.rs b/sdk/compute/src/v2/instance_usage_audit_log/list.rs new file mode 100644 index 000000000..a5c07dab0 --- /dev/null +++ b/sdk/compute/src/v2/instance_usage_audit_log/list.rs @@ -0,0 +1,179 @@ +// 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`. + +//! Lists usage audits for all servers on all compute hosts where usage +//! auditing is configured. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Instance_Usage_Audit_Log. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-instance_usage_audit_log".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-instance_usage_audit_log".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-instance_usage_audit_log".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/keypair.rs b/sdk/compute/src/v2/keypair.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/keypair.rs rename to sdk/compute/src/v2/keypair.rs diff --git a/sdk/compute/src/v2/keypair/create_20.rs b/sdk/compute/src/v2/keypair/create_20.rs new file mode 100644 index 000000000..b99466237 --- /dev/null +++ b/sdk/compute/src/v2/keypair/create_20.rs @@ -0,0 +1,233 @@ +// 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`. + +//! Imports (or generates) a keypair. +//! +//! Normal response codes: 200, 201 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Keypair object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Keypair<'a> { + /// A name for the keypair which will be used to reference it later. + /// + /// Note + /// + /// Since microversion 2.92, allowed characters are ASCII letters + /// `[a-zA-Z]`, digits `[0-9]` and the following special characters: + /// `[@._- ]`. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The public ssh key to import. Was optional before microversion 2.92 : + /// if you were omitting this value, a keypair was generated for you. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) public_key: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Keypair object + #[builder(setter(into))] + pub(crate) keypair: Keypair<'a>, + + #[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 Keypair. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-keypairs".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("keypair", serde_json::to_value(&self.keypair)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("keypair".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "keypair" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-keypairs".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypair": {} })); + }); + + let endpoint = Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-keypairs".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypair": {} })); + }); + + let endpoint = Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/keypair/create_21.rs b/sdk/compute/src/v2/keypair/create_21.rs new file mode 100644 index 000000000..252cd1a22 --- /dev/null +++ b/sdk/compute/src/v2/keypair/create_21.rs @@ -0,0 +1,233 @@ +// 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`. + +//! Imports (or generates) a keypair. +//! +//! Normal response codes: 200, 201 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Keypair object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Keypair<'a> { + /// A name for the keypair which will be used to reference it later. + /// + /// Note + /// + /// Since microversion 2.92, allowed characters are ASCII letters + /// `[a-zA-Z]`, digits `[0-9]` and the following special characters: + /// `[@._- ]`. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The public ssh key to import. Was optional before microversion 2.92 : + /// if you were omitting this value, a keypair was generated for you. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) public_key: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Keypair object + #[builder(setter(into))] + pub(crate) keypair: Keypair<'a>, + + #[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 Keypair. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-keypairs".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("keypair", serde_json::to_value(&self.keypair)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("keypair".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "keypair" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-keypairs".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypair": {} })); + }); + + let endpoint = Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-keypairs".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypair": {} })); + }); + + let endpoint = Request::builder() + .keypair(KeypairBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/keypair/create_210.rs b/sdk/compute/src/v2/keypair/create_210.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/keypair/create_210.rs rename to sdk/compute/src/v2/keypair/create_210.rs index fe20aa723..2490707b7 100644 --- a/openstack_sdk/src/api/compute/v2/keypair/create_210.rs +++ b/sdk/compute/src/v2/keypair/create_210.rs @@ -171,7 +171,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/keypair/create_22.rs b/sdk/compute/src/v2/keypair/create_22.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/keypair/create_22.rs rename to sdk/compute/src/v2/keypair/create_22.rs index fd3ea1fbd..cf7c76faa 100644 --- a/openstack_sdk/src/api/compute/v2/keypair/create_22.rs +++ b/sdk/compute/src/v2/keypair/create_22.rs @@ -163,7 +163,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/keypair/create_292.rs b/sdk/compute/src/v2/keypair/create_292.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/keypair/create_292.rs rename to sdk/compute/src/v2/keypair/create_292.rs index 0f59657d1..4a0458216 100644 --- a/openstack_sdk/src/api/compute/v2/keypair/create_292.rs +++ b/sdk/compute/src/v2/keypair/create_292.rs @@ -171,7 +171,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/keypair/delete.rs b/sdk/compute/src/v2/keypair/delete.rs new file mode 100644 index 000000000..733750a79 --- /dev/null +++ b/sdk/compute/src/v2/keypair/delete.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Deletes a keypair. +//! +//! Normal response codes: 202, 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-keypairs/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Keypair. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-keypairs/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-keypairs/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-keypairs/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/keypair/find.rs b/sdk/compute/src/v2/keypair/find.rs new file mode 100644 index 000000000..7a5a6d4ed --- /dev/null +++ b/sdk/compute/src/v2/keypair/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::keypair::{get as Get, list as List}; + +/// Find for keypair 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate keypair in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // keypair 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/compute/src/v2/keypair/get.rs b/sdk/compute/src/v2/keypair/get.rs new file mode 100644 index 000000000..676828fab --- /dev/null +++ b/sdk/compute/src/v2/keypair/get.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Shows details for a keypair that is associated with the account. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-keypairs/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Keypair. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-keypairs/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("keypair".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "keypair" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-keypairs/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypair": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-keypairs/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypair": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/keypair/list.rs b/sdk/compute/src/v2/keypair/list.rs new file mode 100644 index 000000000..ed14da289 --- /dev/null +++ b/sdk/compute/src/v2/keypair/list.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`. + +//! Lists keypairs that are associated with the account. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Keypair. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-keypairs".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("keypairs".into()) + } + + fn response_list_item_key(&self) -> Option> { + Some("keypair".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "keypairs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-keypairs".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypairs": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-keypairs".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "keypairs": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/limit.rs b/sdk/compute/src/v2/limit.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/limit.rs rename to sdk/compute/src/v2/limit.rs diff --git a/sdk/compute/src/v2/limit/list.rs b/sdk/compute/src/v2/limit/list.rs new file mode 100644 index 000000000..cb5e3e7bd --- /dev/null +++ b/sdk/compute/src/v2/limit/list.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Shows rate and absolute limits for the project. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + tenant_id: 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> { + /// Add a single header to the Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "limits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("limits".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "limits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/migration.rs b/sdk/compute/src/v2/migration.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/migration.rs rename to sdk/compute/src/v2/migration.rs diff --git a/sdk/compute/src/v2/migration/get.rs b/sdk/compute/src/v2/migration/get.rs new file mode 100644 index 000000000..2b62038f6 --- /dev/null +++ b/sdk/compute/src/v2/migration/get.rs @@ -0,0 +1,242 @@ +// 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`. + +//! Lists migrations. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Starting from microversion 2.59, the response is sorted by `created_at` and +//! `id` in descending order. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + changes_before: Option>, + + #[builder(default, setter(into))] + changes_since: Option>, + + #[builder(default, setter(into))] + hidden: Option>, + + #[builder(default, setter(into))] + host: Option>, + + #[builder(default, setter(into))] + instance_uuid: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + migration_type: Option>, + + #[builder(default, setter(into))] + project_id: Option>, + + #[builder(default, setter(into))] + source_compute: Option>, + + #[builder(default, setter(into))] + status: Option>, + + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Migration. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-migrations".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("changes-before", self.changes_before.as_ref()); + params.push_opt("changes-since", self.changes_since.as_ref()); + params.push_opt("hidden", self.hidden.as_ref()); + params.push_opt("host", self.host.as_ref()); + params.push_opt("instance_uuid", self.instance_uuid.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("migration_type", self.migration_type.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("source_compute", self.source_compute.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("migrations".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "migrations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-migrations".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "migrations": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-migrations".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "migrations": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/quota_class_set.rs b/sdk/compute/src/v2/quota_class_set.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/quota_class_set.rs rename to sdk/compute/src/v2/quota_class_set.rs diff --git a/sdk/compute/src/v2/quota_class_set/get.rs b/sdk/compute/src/v2/quota_class_set/get.rs new file mode 100644 index 000000000..8095653cf --- /dev/null +++ b/sdk/compute/src/v2/quota_class_set/get.rs @@ -0,0 +1,188 @@ +// 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 quota for the Quota Class. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-quota-class-sets/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota_Class_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-quota-class-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_class_set".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota_class_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-class-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-class-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/quota_class_set/set_21.rs b/sdk/compute/src/v2/quota_class_set/set_21.rs new file mode 100644 index 000000000..fee47ac78 --- /dev/null +++ b/sdk/compute/src/v2/quota_class_set/set_21.rs @@ -0,0 +1,326 @@ +// 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 the quotas for the Quota Class. +//! +//! If the requested Quota Class is not found in the DB, then the API will +//! create the one. Only ‘default’ quota class is valid and used to set the +//! default quotas, all other quota class would not be used anywhere. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `quota_class_set` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct QuotaClassSet { + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cores: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ips: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) floating_ips: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) injected_file_content_bytes: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) injected_file_path_bytes: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) injected_files: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) instances: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_pairs: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) metadata_items: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ram: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_group_rules: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_groups: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_group_members: Option, + + /// The number of allowed injected files for the quota class. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_groups: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `quota_class_set` object. + #[builder(setter(into))] + pub(crate) quota_class_set: QuotaClassSet, + + /// id parameter for /v2.1/os-quota-class-sets/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota_Class_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-class-sets/{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( + "quota_class_set", + serde_json::to_value(&self.quota_class_set)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_class_set".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota_class_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/quota_class_set/set_250.rs b/sdk/compute/src/v2/quota_class_set/set_250.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/quota_class_set/set_250.rs rename to sdk/compute/src/v2/quota_class_set/set_250.rs index c12088d8e..4a89364de 100644 --- a/openstack_sdk/src/api/compute/v2/quota_class_set/set_250.rs +++ b/sdk/compute/src/v2/quota_class_set/set_250.rs @@ -211,7 +211,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/quota_class_set/set_257.rs b/sdk/compute/src/v2/quota_class_set/set_257.rs new file mode 100644 index 000000000..3a1ffc78c --- /dev/null +++ b/sdk/compute/src/v2/quota_class_set/set_257.rs @@ -0,0 +1,263 @@ +// 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 the quotas for the Quota Class. +//! +//! If the requested Quota Class is not found in the DB, then the API will +//! create the one. Only ‘default’ quota class is valid and used to set the +//! default quotas, all other quota class would not be used anywhere. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `quota_class_set` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct QuotaClassSet { + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cores: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) instances: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_pairs: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) metadata_items: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ram: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_group_members: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_groups: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `quota_class_set` object. + #[builder(setter(into))] + pub(crate) quota_class_set: QuotaClassSet, + + /// id parameter for /v2.1/os-quota-class-sets/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota_Class_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-class-sets/{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( + "quota_class_set", + serde_json::to_value(&self.quota_class_set)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_class_set".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(2, 57)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota_class_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_class_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_class_set(QuotaClassSetBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/quota_set.rs b/sdk/compute/src/v2/quota_set.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/quota_set.rs rename to sdk/compute/src/v2/quota_set.rs diff --git a/sdk/compute/src/v2/quota_set/defaults.rs b/sdk/compute/src/v2/quota_set/defaults.rs new file mode 100644 index 000000000..aca067213 --- /dev/null +++ b/sdk/compute/src/v2/quota_set/defaults.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Lists the default quotas for a project. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badrequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-quota-sets/{id}/defaults 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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-quota-sets/{id}/defaults", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}/defaults", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}/defaults", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/quota_set/delete.rs b/sdk/compute/src/v2/quota_set/delete.rs new file mode 100644 index 000000000..c7b445684 --- /dev/null +++ b/sdk/compute/src/v2/quota_set/delete.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Reverts the quotas to default values for a project or a project and a user. +//! +//! To revert quotas for a project and a user, specify the `user_id` query +//! parameter. +//! +//! Normal response codes: 202 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-quota-sets/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// ID of user to set the quotas for. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-quota-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-quota-sets/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-quota-sets/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/quota_set/details.rs b/sdk/compute/src/v2/quota_set/details.rs new file mode 100644 index 000000000..a5fcf2f7c --- /dev/null +++ b/sdk/compute/src/v2/quota_set/details.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`. + +//! Show the detail of quota for a project or a project and a user. +//! +//! To show a quota for a project and a user, specify the `user_id` query +//! parameter. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badrequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-quota-sets/{id}/detail API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-quota-sets/{id}/detail", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}/detail", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}/detail", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/quota_set/get.rs b/sdk/compute/src/v2/quota_set/get.rs new file mode 100644 index 000000000..fd84895f2 --- /dev/null +++ b/sdk/compute/src/v2/quota_set/get.rs @@ -0,0 +1,195 @@ +// 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 quota for a project or a project and a user. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-quota-sets/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// ID of user to set the quotas for. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-quota-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/quota_set/set_20.rs b/sdk/compute/src/v2/quota_set/set_20.rs new file mode 100644 index 000000000..5a076b586 --- /dev/null +++ b/sdk/compute/src/v2/quota_set/set_20.rs @@ -0,0 +1,338 @@ +// 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 the quotas for a project or a project and a user. +//! +//! Users can force the update even if the quota has already been used and the +//! reserved quota exceeds the new quota. To force the update, specify the +//! `"force": True` attribute in the request body, the default value is +//! `false`. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `quota_set` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct QuotaSet { + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cores: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ips: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) floating_ips: Option, + + /// You can force the update even if the quota has already been used and + /// the reserved quota exceeds the new quota. To force the update, specify + /// the `"force": "True"`. Default is `False`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) force: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) injected_file_content_bytes: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) injected_file_path_bytes: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) injected_files: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) instances: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_pairs: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) metadata_items: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ram: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_group_rules: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_groups: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_group_members: Option, + + /// The number of allowed injected files for each tenant. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_groups: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `quota_set` object. + #[builder(setter(into))] + pub(crate) quota_set: QuotaSet, + + /// id parameter for /v2.1/os-quota-sets/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// ID of user to set the quotas for. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("quota_set", serde_json::to_value(&self.quota_set)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/quota_set/set_236.rs b/sdk/compute/src/v2/quota_set/set_236.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/quota_set/set_236.rs rename to sdk/compute/src/v2/quota_set/set_236.rs index c0a29ed54..85d096d5a 100644 --- a/openstack_sdk/src/api/compute/v2/quota_set/set_236.rs +++ b/sdk/compute/src/v2/quota_set/set_236.rs @@ -223,7 +223,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/quota_set/set_257.rs b/sdk/compute/src/v2/quota_set/set_257.rs new file mode 100644 index 000000000..5a4c42605 --- /dev/null +++ b/sdk/compute/src/v2/quota_set/set_257.rs @@ -0,0 +1,275 @@ +// 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 the quotas for a project or a project and a user. +//! +//! Users can force the update even if the quota has already been used and the +//! reserved quota exceeds the new quota. To force the update, specify the +//! `"force": True` attribute in the request body, the default value is +//! `false`. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `quota_set` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct QuotaSet { + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cores: Option, + + /// You can force the update even if the quota has already been used and + /// the reserved quota exceeds the new quota. To force the update, specify + /// the `"force": "True"`. Default is `False`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) force: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) instances: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_pairs: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) metadata_items: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ram: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_group_members: Option, + + /// The number of allowed members for each server group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) server_groups: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `quota_set` object. + #[builder(setter(into))] + pub(crate) quota_set: QuotaSet, + + /// id parameter for /v2.1/os-quota-sets/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// ID of user to set the quotas for. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("quota_set", serde_json::to_value(&self.quota_set)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("quota_set".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(2, 57)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota_set" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota_set": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_set(QuotaSetBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server.rs b/sdk/compute/src/v2/server.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server.rs rename to sdk/compute/src/v2/server.rs diff --git a/openstack_sdk/src/api/compute/v2/server/add_fixed_ip_21.rs b/sdk/compute/src/v2/server/add_fixed_ip_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/add_fixed_ip_21.rs rename to sdk/compute/src/v2/server/add_fixed_ip_21.rs index 35698e2f9..616c6c630 100644 --- a/openstack_sdk/src/api/compute/v2/server/add_fixed_ip_21.rs +++ b/sdk/compute/src/v2/server/add_fixed_ip_21.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/add_floating_ip_21.rs b/sdk/compute/src/v2/server/add_floating_ip_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/add_floating_ip_21.rs rename to sdk/compute/src/v2/server/add_floating_ip_21.rs index d628345e2..ebfae2c35 100644 --- a/openstack_sdk/src/api/compute/v2/server/add_floating_ip_21.rs +++ b/sdk/compute/src/v2/server/add_floating_ip_21.rs @@ -145,7 +145,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/add_security_group.rs b/sdk/compute/src/v2/server/add_security_group.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/add_security_group.rs rename to sdk/compute/src/v2/server/add_security_group.rs index 4dba8c454..fdfb621ad 100644 --- a/openstack_sdk/src/api/compute/v2/server/add_security_group.rs +++ b/sdk/compute/src/v2/server/add_security_group.rs @@ -155,7 +155,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/change_password.rs b/sdk/compute/src/v2/server/change_password.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/change_password.rs rename to sdk/compute/src/v2/server/change_password.rs index 0985ad4c2..209dcde51 100644 --- a/openstack_sdk/src/api/compute/v2/server/change_password.rs +++ b/sdk/compute/src/v2/server/change_password.rs @@ -136,7 +136,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/confirm_resize.rs b/sdk/compute/src/v2/server/confirm_resize.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/confirm_resize.rs rename to sdk/compute/src/v2/server/confirm_resize.rs index daa22ed8c..dde35a9b9 100644 --- a/openstack_sdk/src/api/compute/v2/server/confirm_resize.rs +++ b/sdk/compute/src/v2/server/confirm_resize.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/create_20.rs b/sdk/compute/src/v2/server/create_20.rs new file mode 100644 index 000000000..1d55999ce --- /dev/null +++ b/sdk/compute/src/v2/server/create_20.rs @@ -0,0 +1,916 @@ +// 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`. + +//! Creates a server. +//! +//! The progress of this operation depends on the location of the requested +//! image, network I/O, host load, selected flavor, and other factors. +//! +//! To check the progress of the request, make a `GET /servers/{id}` request. +//! This call returns a progress attribute, which is a percentage value from 0 +//! to 100. +//! +//! The `Location` header returns the full URL to the newly created server and +//! is available as a `self` and `bookmark` link in the server representation. +//! +//! When you create a server, the response shows only the server ID, its links, +//! and the admin password. You can get additional attributes through +//! subsequent `GET` requests on the server. +//! +//! Include the `block_device_mapping_v2` parameter in the create request body +//! to boot a server from a volume. +//! +//! Include the `key_name` parameter in the create request body to add a +//! keypair to the server when you create it. To create a keypair, make a +//! [create keypair](https://docs.openstack.org/api-ref/compute/#create-or-import-keypair) +//! request. +//! +//! **Preconditions** +//! +//! **Asynchronous postconditions** +//! +//! **Troubleshooting** +//! +//! Normal response codes: 202 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsSchHntSchedulerHints<'a> { + /// Schedule the server on a host in the network specified with this + /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) build_near_host_ip: Option>, + + /// Schedule the server on a host in the network specified with an IP + /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. + /// If `os:scheduler_hints:build_near_host_ip` is specified and this + /// parameter is omitted, `/24` is used. It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cidr: Option>, + + /// A list of cell routes or a cell route (string). Schedule the server in + /// a cell that is not specified. It is available when + /// `DifferentCellFilter` is available on cloud side that is cell v1 + /// environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_cell: Option>>, + + /// A list of server UUIDs or a server UUID. Schedule the server on a + /// different host from a set of servers. It is available when + /// `DifferentHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_host: Option>>, + + /// The server group UUID. Schedule the server according to a policy of the + /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or + /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, + /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, + /// `ServerGroupSoftAffinityWeigher` are available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group: Option>>, + + /// Schedule the server by using a custom filter in JSON format. For + /// example: + /// + /// ```text + /// "query": "[\">=\",\"$free_ram_mb\",1024]" + /// ``` + /// + /// It is available when `JsonFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) query: Option, + + /// A list of server UUIDs or a server UUID. Schedule the server on the + /// same host as another server in a set of servers. It is available when + /// `SameHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) same_host: Option>>, + + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) target_cell: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> OsSchHntSchedulerHintsBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +/// The dictionary of data to send to the scheduler. Alternatively, you can +/// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. +/// +/// Note +/// +/// This is a top-level key in the request body, not part of the server portion +/// of the request body. +/// +/// There are a few caveats with scheduler hints: +/// +/// - The request validation schema is per hint. For example, some require a +/// single string value, and some accept a list of values. +/// - Hints are only used based on the cloud scheduler configuration, which +/// varies per deployment. +/// - Hints are pluggable per deployment, meaning that a cloud can have custom +/// hints which may not be available in another cloud. +/// +/// For these reasons, it is important to consult each cloud’s user +/// documentation to know what is available for scheduler hints. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsSchedulerHints<'a> { + /// Schedule the server on a host in the network specified with this + /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) build_near_host_ip: Option>, + + /// Schedule the server on a host in the network specified with an IP + /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. + /// If `os:scheduler_hints:build_near_host_ip` is specified and this + /// parameter is omitted, `/24` is used. It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cidr: Option>, + + /// A list of cell routes or a cell route (string). Schedule the server in + /// a cell that is not specified. It is available when + /// `DifferentCellFilter` is available on cloud side that is cell v1 + /// environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_cell: Option>>, + + /// A list of server UUIDs or a server UUID. Schedule the server on a + /// different host from a set of servers. It is available when + /// `DifferentHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_host: Option>>, + + /// The server group UUID. Schedule the server according to a policy of the + /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or + /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, + /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, + /// `ServerGroupSoftAffinityWeigher` are available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group: Option>>, + + /// Schedule the server by using a custom filter in JSON format. For + /// example: + /// + /// ```text + /// "query": "[\">=\",\"$free_ram_mb\",1024]" + /// ``` + /// + /// It is available when `JsonFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) query: Option, + + /// A list of server UUIDs or a server UUID. Schedule the server on the + /// same host as another server in a set of servers. It is available when + /// `SameHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) same_host: Option>>, + + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) target_cell: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> OsSchedulerHintsBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum OsDcfDiskConfig { + #[serde(rename = "AUTO")] + Auto, + #[serde(rename = "MANUAL")] + Manual, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct BlockDeviceMapping<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) connection_info: Option>, + + /// Indicates whether a config drive enables metadata injection. The + /// config_drive setting provides information about a drive that the + /// instance can mount at boot time. The instance reads files from the + /// drive to get information that is normally available through the + /// metadata service. This metadata is different from the user data. Not + /// all cloud providers enable the `config_drive`. Read more in the + /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) delete_on_termination: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_name: Option>, + + /// OpenAPI specifies the field as '{}'. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) no_device: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) snapshot_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) virtual_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_size: Option, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum DestinationType { + #[serde(rename = "local")] + Local, + #[serde(rename = "volume")] + Volume, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum SourceType { + #[serde(rename = "blank")] + Blank, + #[serde(rename = "image")] + Image, + #[serde(rename = "snapshot")] + Snapshot, + #[serde(rename = "volume")] + Volume, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct BlockDeviceMappingV2<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) boot_index: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) connection_info: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) delete_on_termination: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) destination_type: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_type: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) disk_bus: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) guest_format: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_id: Option>, + + /// OpenAPI specifies the field as '{}'. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) no_device: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) snapshot_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) source_type: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) uuid: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) virtual_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_size: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Networks<'a> { + /// Schedule the server on a host in the network specified with this + /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ip: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) uuid: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Personality<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) contents: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) path: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SecurityGroups<'a> { + /// Key pair name. + /// + /// Note + /// + /// The `null` value was allowed in the Nova legacy v2 API, but due to + /// strict input validation, it is not allowed in the Nova v2.1 API. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// A `server` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Server<'a> { + /// IPv4 address that should be used to access this server. + #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv4: Option>, + + /// IPv6 address that should be used to access this server. + #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv6: Option>, + + /// The administrative password of the server. If you omit this parameter, + /// the operation generates a new password. + #[serde(rename = "adminPass", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_pass: Option>, + + /// Key pair name. + /// + /// Note + /// + /// The `null` value was allowed in the Nova legacy v2 API, but due to + /// strict input validation, it is not allowed in the Nova v2.1 API. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) block_device_mapping: Option>>, + + /// Enables fine grained control of the block device mapping for an + /// instance. This is typically used for booting servers from volumes. An + /// example format would look as follows: + /// + /// > ```text + /// > "block_device_mapping_v2": [{ + /// > "boot_index": "0", + /// > "uuid": "ac408821-c95a-448f-9292-73986c790911", + /// > "source_type": "image", + /// > "volume_size": "25", + /// > "destination_type": "volume", + /// > "delete_on_termination": true, + /// > "tag": "disk1", + /// > "disk_bus": "scsi"}] + /// > ``` + /// + /// In microversion 2.32, `tag` is an optional string attribute that can be + /// used to assign a tag to the block device. This tag is then exposed to + /// the guest in the metadata API and the config drive and is associated to + /// hardware metadata for that block device, such as bus (ex: SCSI), bus + /// address (ex: 1:0:2:0), and serial. + /// + /// A bug has caused the `tag` attribute to no longer be accepted starting + /// with version 2.33. It has been restored in version 2.42. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) block_device_mapping_v2: Option>>, + + /// Indicates whether a config drive enables metadata injection. The + /// config_drive setting provides information about a drive that the + /// instance can mount at boot time. The instance reads files from the + /// drive to get information that is normally available through the + /// metadata service. This metadata is different from the user data. Not + /// all cloud providers enable the `config_drive`. Read more in the + /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) config_drive: Option, + + /// The flavor reference, as an ID (including a UUID) or full URL, for the + /// flavor for your server instance. + #[serde(rename = "flavorRef")] + #[builder(setter(into))] + pub(crate) flavor_ref: Cow<'a, str>, + + /// The UUID of the image to use for your server instance. This is not + /// required in case of boot from volume. In all other cases it is required + /// and must be a valid UUID otherwise API will return 400. + #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_ref: Option>, + + /// Key pair name. + /// + /// Note + /// + /// The `null` value was allowed in the Nova legacy v2 API, but due to + /// strict input validation, it is not allowed in the Nova v2.1 API. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_count: Option, + + /// Metadata key and value pairs. The maximum size of the metadata key and + /// value is 255 bytes each. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_count: Option, + + /// Key pair name. + /// + /// Note + /// + /// The `null` value was allowed in the Nova legacy v2 API, but due to + /// strict input validation, it is not allowed in the Nova v2.1 API. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// A list of `network` object. Required parameter when there are multiple + /// networks defined for the tenant. When you do not specify the networks + /// parameter, the server attaches to the only network created for the + /// current tenant. Optionally, you can create one or more NICs on the + /// server. To provision the server instance with a NIC for a network, + /// specify the UUID of the network in the `uuid` attribute in a `networks` + /// object. To provision the server instance with a NIC for an already + /// existing port, specify the port-id in the `port` attribute in a + /// `networks` object. + /// + /// If multiple networks are defined, the order in which they appear in the + /// guest operating system will not necessarily reflect the order in which + /// they are given in the server boot request. Guests should therefore not + /// depend on device order to deduce any information about their network + /// devices. Instead, device role tags should be used: introduced in 2.32, + /// broken in 2.37, and re-introduced and fixed in 2.42, the `tag` is an + /// optional, string attribute that can be used to assign a tag to a + /// virtual network interface. This tag is then exposed to the guest in the + /// metadata API and the config drive and is associated to hardware + /// metadata for that network interface, such as bus (ex: PCI), bus address + /// (ex: 0000:00:02.0), and MAC address. + /// + /// A bug has caused the `tag` attribute to no longer be accepted starting + /// with version 2.37. Therefore, network interfaces could only be tagged + /// in versions 2.32 to 2.36 inclusively. Version 2.42 has restored the + /// `tag` attribute. + /// + /// Starting with microversion 2.37, this field is required and the special + /// string values *auto* and *none* can be specified for networks. *auto* + /// tells the Compute service to use a network that is available to the + /// project, if one exists. If one does not exist, the Compute service will + /// attempt to automatically allocate a network for the project (if + /// possible). *none* tells the Compute service to not allocate a network + /// for the instance. The *auto* and *none* values cannot be used with any + /// other network values, including other network uuids, ports, fixed IPs + /// or device tags. These are requested as strings for the networks value, + /// not in a list. See the associated example. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) networks: Option>>, + + /// Controls how the API partitions the disk when you create, rebuild, or + /// resize servers. A server inherits the `OS-DCF:diskConfig` value from + /// the image from which it was created, and an image inherits the + /// `OS-DCF:diskConfig` value from the server from which it was created. To + /// override the inherited setting, you can include this attribute in the + /// request body of a server create, rebuild, or resize request. If the + /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a + /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. + /// A valid value is: + /// + /// - `AUTO`. The API builds the server with a single partition the size of + /// the target flavor disk. The API automatically adjusts the file system + /// to fit the entire partition. + /// - `MANUAL`. The API builds the server by using whatever partition + /// scheme and file system is in the source image. If the target flavor + /// disk is larger, the API does not partition the remaining disk space. + #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) os_dcf_disk_config: Option, + + /// The file path and contents, text only, to inject into the server at + /// launch. The maximum size of the file path data is 255 bytes. The + /// maximum limit is the number of allowed bytes in the decoded, rather + /// than encoded, data. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) personality: Option>>, + + /// Indicates whether a config drive enables metadata injection. The + /// config_drive setting provides information about a drive that the + /// instance can mount at boot time. The instance reads files from the + /// drive to get information that is normally available through the + /// metadata service. This metadata is different from the user data. Not + /// all cloud providers enable the `config_drive`. Read more in the + /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) return_reservation_id: Option, + + /// One or more security groups. Specify the name of the security group in + /// the `name` attribute. If you omit this attribute, the API creates the + /// server in the `default` security group. Requested security groups are + /// not applied to pre-existing ports. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_groups: Option>>, + + /// Configuration information or scripts to use upon launch. Must be Base64 + /// encoded. Restricted to 65535 bytes. + /// + /// Note + /// + /// The `null` value allowed in Nova legacy v2 API, but due to the strict + /// input validation, it isn’t allowed in Nova v2.1 API. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user_data: Option>>, +} + +impl<'a> ServerBuilder<'a> { + /// Metadata key and value pairs. The maximum size of the metadata key and + /// value is 255 bytes each. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) os_sch_hnt_scheduler_hints: Option>, + + /// The dictionary of data to send to the scheduler. Alternatively, you can + /// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. + /// + /// Note + /// + /// This is a top-level key in the request body, not part of the server + /// portion of the request body. + /// + /// There are a few caveats with scheduler hints: + /// + /// - The request validation schema is per hint. For example, some require + /// a single string value, and some accept a list of values. + /// - Hints are only used based on the cloud scheduler configuration, which + /// varies per deployment. + /// - Hints are pluggable per deployment, meaning that a cloud can have + /// custom hints which may not be available in another cloud. + /// + /// For these reasons, it is important to consult each cloud’s user + /// documentation to know what is available for scheduler hints. + #[builder(default, setter(into))] + pub(crate) os_scheduler_hints: Option>, + + /// A `server` object. + #[builder(setter(into))] + pub(crate) server: Server<'a>, + + #[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 Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "servers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.os_sch_hnt_scheduler_hints { + params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); + } + if let Some(val) = &self.os_scheduler_hints { + params.push("os:scheduler_hints", serde_json::to_value(val)?); + } + params.push("server", serde_json::to_value(&self.server)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "server" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/servers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/servers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/create_21.rs b/sdk/compute/src/v2/server/create_21.rs new file mode 100644 index 000000000..6cb6be410 --- /dev/null +++ b/sdk/compute/src/v2/server/create_21.rs @@ -0,0 +1,904 @@ +// 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`. + +//! Creates a server. +//! +//! The progress of this operation depends on the location of the requested +//! image, network I/O, host load, selected flavor, and other factors. +//! +//! To check the progress of the request, make a `GET /servers/{id}` request. +//! This call returns a progress attribute, which is a percentage value from 0 +//! to 100. +//! +//! The `Location` header returns the full URL to the newly created server and +//! is available as a `self` and `bookmark` link in the server representation. +//! +//! When you create a server, the response shows only the server ID, its links, +//! and the admin password. You can get additional attributes through +//! subsequent `GET` requests on the server. +//! +//! Include the `block_device_mapping_v2` parameter in the create request body +//! to boot a server from a volume. +//! +//! Include the `key_name` parameter in the create request body to add a +//! keypair to the server when you create it. To create a keypair, make a +//! [create keypair](https://docs.openstack.org/api-ref/compute/#create-or-import-keypair) +//! request. +//! +//! **Preconditions** +//! +//! **Asynchronous postconditions** +//! +//! **Troubleshooting** +//! +//! Normal response codes: 202 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsSchHntSchedulerHints<'a> { + /// Schedule the server on a host in the network specified with this + /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) build_near_host_ip: Option>, + + /// Schedule the server on a host in the network specified with an IP + /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. + /// If `os:scheduler_hints:build_near_host_ip` is specified and this + /// parameter is omitted, `/24` is used. It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cidr: Option>, + + /// A list of cell routes or a cell route (string). Schedule the server in + /// a cell that is not specified. It is available when + /// `DifferentCellFilter` is available on cloud side that is cell v1 + /// environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_cell: Option>>, + + /// A list of server UUIDs or a server UUID. Schedule the server on a + /// different host from a set of servers. It is available when + /// `DifferentHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_host: Option>>, + + /// The server group UUID. Schedule the server according to a policy of the + /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or + /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, + /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, + /// `ServerGroupSoftAffinityWeigher` are available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group: Option>>, + + /// Schedule the server by using a custom filter in JSON format. For + /// example: + /// + /// ```text + /// "query": "[\">=\",\"$free_ram_mb\",1024]" + /// ``` + /// + /// It is available when `JsonFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) query: Option, + + /// A list of server UUIDs or a server UUID. Schedule the server on the + /// same host as another server in a set of servers. It is available when + /// `SameHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) same_host: Option>>, + + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) target_cell: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> OsSchHntSchedulerHintsBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +/// The dictionary of data to send to the scheduler. Alternatively, you can +/// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. +/// +/// Note +/// +/// This is a top-level key in the request body, not part of the server portion +/// of the request body. +/// +/// There are a few caveats with scheduler hints: +/// +/// - The request validation schema is per hint. For example, some require a +/// single string value, and some accept a list of values. +/// - Hints are only used based on the cloud scheduler configuration, which +/// varies per deployment. +/// - Hints are pluggable per deployment, meaning that a cloud can have custom +/// hints which may not be available in another cloud. +/// +/// For these reasons, it is important to consult each cloud’s user +/// documentation to know what is available for scheduler hints. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsSchedulerHints<'a> { + /// Schedule the server on a host in the network specified with this + /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) build_near_host_ip: Option>, + + /// Schedule the server on a host in the network specified with an IP + /// address (`os:scheduler_hints:build_near_host_ip`) and this parameter. + /// If `os:scheduler_hints:build_near_host_ip` is specified and this + /// parameter is omitted, `/24` is used. It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cidr: Option>, + + /// A list of cell routes or a cell route (string). Schedule the server in + /// a cell that is not specified. It is available when + /// `DifferentCellFilter` is available on cloud side that is cell v1 + /// environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_cell: Option>>, + + /// A list of server UUIDs or a server UUID. Schedule the server on a + /// different host from a set of servers. It is available when + /// `DifferentHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) different_host: Option>>, + + /// The server group UUID. Schedule the server according to a policy of the + /// server group (`anti-affinity`, `affinity`, `soft-anti-affinity` or + /// `soft-affinity`). It is available when `ServerGroupAffinityFilter`, + /// `ServerGroupAntiAffinityFilter`, `ServerGroupSoftAntiAffinityWeigher`, + /// `ServerGroupSoftAffinityWeigher` are available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group: Option>>, + + /// Schedule the server by using a custom filter in JSON format. For + /// example: + /// + /// ```text + /// "query": "[\">=\",\"$free_ram_mb\",1024]" + /// ``` + /// + /// It is available when `JsonFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) query: Option, + + /// A list of server UUIDs or a server UUID. Schedule the server on the + /// same host as another server in a set of servers. It is available when + /// `SameHostFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) same_host: Option>>, + + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) target_cell: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> OsSchedulerHintsBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum OsDcfDiskConfig { + #[serde(rename = "AUTO")] + Auto, + #[serde(rename = "MANUAL")] + Manual, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct BlockDeviceMapping<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) connection_info: Option>, + + /// Indicates whether a config drive enables metadata injection. The + /// config_drive setting provides information about a drive that the + /// instance can mount at boot time. The instance reads files from the + /// drive to get information that is normally available through the + /// metadata service. This metadata is different from the user data. Not + /// all cloud providers enable the `config_drive`. Read more in the + /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) delete_on_termination: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_name: Option>, + + /// OpenAPI specifies the field as '{}'. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) no_device: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) snapshot_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) virtual_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_size: Option, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum DestinationType { + #[serde(rename = "local")] + Local, + #[serde(rename = "volume")] + Volume, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum SourceType { + #[serde(rename = "blank")] + Blank, + #[serde(rename = "image")] + Image, + #[serde(rename = "snapshot")] + Snapshot, + #[serde(rename = "volume")] + Volume, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct BlockDeviceMappingV2<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) boot_index: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) connection_info: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) delete_on_termination: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) destination_type: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_type: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) disk_bus: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) guest_format: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_id: Option>, + + /// OpenAPI specifies the field as '{}'. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) no_device: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) snapshot_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) source_type: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) uuid: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) virtual_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_size: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Networks<'a> { + /// Schedule the server on a host in the network specified with this + /// parameter and a cidr (`os:scheduler_hints.cidr`). It is available when + /// `SimpleCIDRAffinityFilter` is available on cloud side. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ip: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) uuid: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Personality<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) contents: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) path: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SecurityGroups<'a> { + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// A `server` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Server<'a> { + /// IPv4 address that should be used to access this server. + #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv4: Option>, + + /// IPv6 address that should be used to access this server. + #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv6: Option>, + + /// The administrative password of the server. If you omit this parameter, + /// the operation generates a new password. + #[serde(rename = "adminPass", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_pass: Option>, + + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) block_device_mapping: Option>>, + + /// Enables fine grained control of the block device mapping for an + /// instance. This is typically used for booting servers from volumes. An + /// example format would look as follows: + /// + /// > ```text + /// > "block_device_mapping_v2": [{ + /// > "boot_index": "0", + /// > "uuid": "ac408821-c95a-448f-9292-73986c790911", + /// > "source_type": "image", + /// > "volume_size": "25", + /// > "destination_type": "volume", + /// > "delete_on_termination": true, + /// > "tag": "disk1", + /// > "disk_bus": "scsi"}] + /// > ``` + /// + /// In microversion 2.32, `tag` is an optional string attribute that can be + /// used to assign a tag to the block device. This tag is then exposed to + /// the guest in the metadata API and the config drive and is associated to + /// hardware metadata for that block device, such as bus (ex: SCSI), bus + /// address (ex: 1:0:2:0), and serial. + /// + /// A bug has caused the `tag` attribute to no longer be accepted starting + /// with version 2.33. It has been restored in version 2.42. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) block_device_mapping_v2: Option>>, + + /// Indicates whether a config drive enables metadata injection. The + /// config_drive setting provides information about a drive that the + /// instance can mount at boot time. The instance reads files from the + /// drive to get information that is normally available through the + /// metadata service. This metadata is different from the user data. Not + /// all cloud providers enable the `config_drive`. Read more in the + /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) config_drive: Option, + + /// The flavor reference, as an ID (including a UUID) or full URL, for the + /// flavor for your server instance. + #[serde(rename = "flavorRef")] + #[builder(setter(into))] + pub(crate) flavor_ref: Cow<'a, str>, + + /// The UUID of the image to use for your server instance. This is not + /// required in case of boot from volume. In all other cases it is required + /// and must be a valid UUID otherwise API will return 400. + #[serde(rename = "imageRef", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) image_ref: Option>, + + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_count: Option, + + /// Metadata key and value pairs. The maximum size of the metadata key and + /// value is 255 bytes each. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_count: Option, + + /// A target cell name. Schedule the server in a host in the cell + /// specified. It is available when `TargetCellFilter` is available on + /// cloud side that is cell v1 environment. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// A list of `network` object. Required parameter when there are multiple + /// networks defined for the tenant. When you do not specify the networks + /// parameter, the server attaches to the only network created for the + /// current tenant. Optionally, you can create one or more NICs on the + /// server. To provision the server instance with a NIC for a network, + /// specify the UUID of the network in the `uuid` attribute in a `networks` + /// object. To provision the server instance with a NIC for an already + /// existing port, specify the port-id in the `port` attribute in a + /// `networks` object. + /// + /// If multiple networks are defined, the order in which they appear in the + /// guest operating system will not necessarily reflect the order in which + /// they are given in the server boot request. Guests should therefore not + /// depend on device order to deduce any information about their network + /// devices. Instead, device role tags should be used: introduced in 2.32, + /// broken in 2.37, and re-introduced and fixed in 2.42, the `tag` is an + /// optional, string attribute that can be used to assign a tag to a + /// virtual network interface. This tag is then exposed to the guest in the + /// metadata API and the config drive and is associated to hardware + /// metadata for that network interface, such as bus (ex: PCI), bus address + /// (ex: 0000:00:02.0), and MAC address. + /// + /// A bug has caused the `tag` attribute to no longer be accepted starting + /// with version 2.37. Therefore, network interfaces could only be tagged + /// in versions 2.32 to 2.36 inclusively. Version 2.42 has restored the + /// `tag` attribute. + /// + /// Starting with microversion 2.37, this field is required and the special + /// string values *auto* and *none* can be specified for networks. *auto* + /// tells the Compute service to use a network that is available to the + /// project, if one exists. If one does not exist, the Compute service will + /// attempt to automatically allocate a network for the project (if + /// possible). *none* tells the Compute service to not allocate a network + /// for the instance. The *auto* and *none* values cannot be used with any + /// other network values, including other network uuids, ports, fixed IPs + /// or device tags. These are requested as strings for the networks value, + /// not in a list. See the associated example. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) networks: Option>>, + + /// Controls how the API partitions the disk when you create, rebuild, or + /// resize servers. A server inherits the `OS-DCF:diskConfig` value from + /// the image from which it was created, and an image inherits the + /// `OS-DCF:diskConfig` value from the server from which it was created. To + /// override the inherited setting, you can include this attribute in the + /// request body of a server create, rebuild, or resize request. If the + /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a + /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. + /// A valid value is: + /// + /// - `AUTO`. The API builds the server with a single partition the size of + /// the target flavor disk. The API automatically adjusts the file system + /// to fit the entire partition. + /// - `MANUAL`. The API builds the server by using whatever partition + /// scheme and file system is in the source image. If the target flavor + /// disk is larger, the API does not partition the remaining disk space. + #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) os_dcf_disk_config: Option, + + /// The file path and contents, text only, to inject into the server at + /// launch. The maximum size of the file path data is 255 bytes. The + /// maximum limit is the number of allowed bytes in the decoded, rather + /// than encoded, data. + /// + /// **Available until version 2.56** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) personality: Option>>, + + /// Indicates whether a config drive enables metadata injection. The + /// config_drive setting provides information about a drive that the + /// instance can mount at boot time. The instance reads files from the + /// drive to get information that is normally available through the + /// metadata service. This metadata is different from the user data. Not + /// all cloud providers enable the `config_drive`. Read more in the + /// [OpenStack End User Guide](https://docs.openstack.org/nova/latest/user/config-drive.html). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) return_reservation_id: Option, + + /// One or more security groups. Specify the name of the security group in + /// the `name` attribute. If you omit this attribute, the API creates the + /// server in the `default` security group. Requested security groups are + /// not applied to pre-existing ports. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_groups: Option>>, + + /// Configuration information or scripts to use upon launch. Must be Base64 + /// encoded. Restricted to 65535 bytes. + /// + /// Note + /// + /// The `null` value allowed in Nova legacy v2 API, but due to the strict + /// input validation, it isn’t allowed in Nova v2.1 API. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user_data: Option>, +} + +impl<'a> ServerBuilder<'a> { + /// Metadata key and value pairs. The maximum size of the metadata key and + /// value is 255 bytes each. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) os_sch_hnt_scheduler_hints: Option>, + + /// The dictionary of data to send to the scheduler. Alternatively, you can + /// specify `OS-SCH-HNT:scheduler_hints` as the key in the request body. + /// + /// Note + /// + /// This is a top-level key in the request body, not part of the server + /// portion of the request body. + /// + /// There are a few caveats with scheduler hints: + /// + /// - The request validation schema is per hint. For example, some require + /// a single string value, and some accept a list of values. + /// - Hints are only used based on the cloud scheduler configuration, which + /// varies per deployment. + /// - Hints are pluggable per deployment, meaning that a cloud can have + /// custom hints which may not be available in another cloud. + /// + /// For these reasons, it is important to consult each cloud’s user + /// documentation to know what is available for scheduler hints. + #[builder(default, setter(into))] + pub(crate) os_scheduler_hints: Option>, + + /// A `server` object. + #[builder(setter(into))] + pub(crate) server: Server<'a>, + + #[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 Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "servers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.os_sch_hnt_scheduler_hints { + params.push("OS-SCH-HNT:scheduler_hints", serde_json::to_value(val)?); + } + if let Some(val) = &self.os_scheduler_hints { + params.push("os:scheduler_hints", serde_json::to_value(val)?); + } + params.push("server", serde_json::to_value(&self.server)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "server" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/servers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/servers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .server( + ServerBuilder::default() + .flavor_ref("foo") + .name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/create_219.rs b/sdk/compute/src/v2/server/create_219.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_219.rs rename to sdk/compute/src/v2/server/create_219.rs index c7c5d108e..fb39eb3b0 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_219.rs +++ b/sdk/compute/src/v2/server/create_219.rs @@ -803,7 +803,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_232.rs b/sdk/compute/src/v2/server/create_232.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_232.rs rename to sdk/compute/src/v2/server/create_232.rs index f95898689..ec80c1ff0 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_232.rs +++ b/sdk/compute/src/v2/server/create_232.rs @@ -811,7 +811,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_233.rs b/sdk/compute/src/v2/server/create_233.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_233.rs rename to sdk/compute/src/v2/server/create_233.rs index 72b31f11d..751c58194 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_233.rs +++ b/sdk/compute/src/v2/server/create_233.rs @@ -807,7 +807,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_237.rs b/sdk/compute/src/v2/server/create_237.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_237.rs rename to sdk/compute/src/v2/server/create_237.rs index 70884c9dc..c30ad2f4d 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_237.rs +++ b/sdk/compute/src/v2/server/create_237.rs @@ -815,7 +815,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_242.rs b/sdk/compute/src/v2/server/create_242.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_242.rs rename to sdk/compute/src/v2/server/create_242.rs index 03d45b985..84bba641b 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_242.rs +++ b/sdk/compute/src/v2/server/create_242.rs @@ -823,7 +823,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_252.rs b/sdk/compute/src/v2/server/create_252.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_252.rs rename to sdk/compute/src/v2/server/create_252.rs index 315f1732a..61041a4f1 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_252.rs +++ b/sdk/compute/src/v2/server/create_252.rs @@ -838,7 +838,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_257.rs b/sdk/compute/src/v2/server/create_257.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_257.rs rename to sdk/compute/src/v2/server/create_257.rs index b276f55b8..e790ef83e 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_257.rs +++ b/sdk/compute/src/v2/server/create_257.rs @@ -816,7 +816,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_263.rs b/sdk/compute/src/v2/server/create_263.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_263.rs rename to sdk/compute/src/v2/server/create_263.rs index 2f3926f3f..f2ff97123 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_263.rs +++ b/sdk/compute/src/v2/server/create_263.rs @@ -827,7 +827,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_267.rs b/sdk/compute/src/v2/server/create_267.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_267.rs rename to sdk/compute/src/v2/server/create_267.rs index 939c8ce20..11eed32ba 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_267.rs +++ b/sdk/compute/src/v2/server/create_267.rs @@ -831,7 +831,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_274.rs b/sdk/compute/src/v2/server/create_274.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_274.rs rename to sdk/compute/src/v2/server/create_274.rs index b72dad9a4..18e04fe7e 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_274.rs +++ b/sdk/compute/src/v2/server/create_274.rs @@ -849,7 +849,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_290.rs b/sdk/compute/src/v2/server/create_290.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_290.rs rename to sdk/compute/src/v2/server/create_290.rs index a6476bec9..b08d82de3 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_290.rs +++ b/sdk/compute/src/v2/server/create_290.rs @@ -865,7 +865,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_294.rs b/sdk/compute/src/v2/server/create_294.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_294.rs rename to sdk/compute/src/v2/server/create_294.rs index f89443e72..be8485654 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_294.rs +++ b/sdk/compute/src/v2/server/create_294.rs @@ -865,7 +865,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_backup_20.rs b/sdk/compute/src/v2/server/create_backup_20.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_backup_20.rs rename to sdk/compute/src/v2/server/create_backup_20.rs index b8e59bfe1..9f2fedb45 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_backup_20.rs +++ b/sdk/compute/src/v2/server/create_backup_20.rs @@ -168,7 +168,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_backup_21.rs b/sdk/compute/src/v2/server/create_backup_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_backup_21.rs rename to sdk/compute/src/v2/server/create_backup_21.rs index b03b9fc2c..6b75bb216 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_backup_21.rs +++ b/sdk/compute/src/v2/server/create_backup_21.rs @@ -168,7 +168,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_image_20.rs b/sdk/compute/src/v2/server/create_image_20.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_image_20.rs rename to sdk/compute/src/v2/server/create_image_20.rs index 8f9df7128..3efaee751 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_image_20.rs +++ b/sdk/compute/src/v2/server/create_image_20.rs @@ -159,7 +159,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/create_image_21.rs b/sdk/compute/src/v2/server/create_image_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/create_image_21.rs rename to sdk/compute/src/v2/server/create_image_21.rs index bc9cfc0e0..dffb00c1f 100644 --- a/openstack_sdk/src/api/compute/v2/server/create_image_21.rs +++ b/sdk/compute/src/v2/server/create_image_21.rs @@ -159,7 +159,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/delete.rs b/sdk/compute/src/v2/server/delete.rs new file mode 100644 index 000000000..b340b8dd1 --- /dev/null +++ b/sdk/compute/src/v2/server/delete.rs @@ -0,0 +1,199 @@ +// 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`. + +//! Deletes a server. +//! +//! By default, the instance is going to be (hard) deleted immediately from the +//! system, but you can set `reclaim_instance_interval` > 0 to make the API +//! soft delete the instance, so that the instance won’t be deleted until the +//! `reclaim_instance_interval` has expired since the instance was soft +//! deleted. The instance marked as `SOFT_DELETED` can be recovered via +//! `restore` action before it’s really deleted from the system. +//! +//! **Preconditions** +//! +//! **Asynchronous postconditions** +//! +//! **Troubleshooting** +//! +//! Normal response codes: 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("servers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/servers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/servers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/diagnostic.rs b/sdk/compute/src/v2/server/diagnostic.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/diagnostic.rs rename to sdk/compute/src/v2/server/diagnostic.rs diff --git a/sdk/compute/src/v2/server/diagnostic/get.rs b/sdk/compute/src/v2/server/diagnostic/get.rs new file mode 100644 index 000000000..df2c35663 --- /dev/null +++ b/sdk/compute/src/v2/server/diagnostic/get.rs @@ -0,0 +1,198 @@ +// 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`. + +//! Shows basic usage data for a server. +//! +//! Policy defaults enable only users with the administrative role. Cloud +//! providers can change these permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), notfound(404), +//! conflict(409), notimplemented(501) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/diagnostics API + #[builder(default, setter(into))] + server_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 Diagnostic. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/diagnostics", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/diagnostics", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/diagnostics", + server_id = "server_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() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/evacuate_20.rs b/sdk/compute/src/v2/server/evacuate_20.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/evacuate_20.rs rename to sdk/compute/src/v2/server/evacuate_20.rs index 9b2d7e186..b44295e42 100644 --- a/openstack_sdk/src/api/compute/v2/server/evacuate_20.rs +++ b/sdk/compute/src/v2/server/evacuate_20.rs @@ -164,7 +164,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/evacuate_214.rs b/sdk/compute/src/v2/server/evacuate_214.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/evacuate_214.rs rename to sdk/compute/src/v2/server/evacuate_214.rs index 3e4ef244c..ed2605c92 100644 --- a/openstack_sdk/src/api/compute/v2/server/evacuate_214.rs +++ b/sdk/compute/src/v2/server/evacuate_214.rs @@ -151,7 +151,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/evacuate_229.rs b/sdk/compute/src/v2/server/evacuate_229.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/evacuate_229.rs rename to sdk/compute/src/v2/server/evacuate_229.rs index 8ec3cf134..dc5bcc3e6 100644 --- a/openstack_sdk/src/api/compute/v2/server/evacuate_229.rs +++ b/sdk/compute/src/v2/server/evacuate_229.rs @@ -173,7 +173,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/evacuate_268.rs b/sdk/compute/src/v2/server/evacuate_268.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/evacuate_268.rs rename to sdk/compute/src/v2/server/evacuate_268.rs index 83c85bb00..4e5ce7458 100644 --- a/openstack_sdk/src/api/compute/v2/server/evacuate_268.rs +++ b/sdk/compute/src/v2/server/evacuate_268.rs @@ -151,7 +151,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/evacuate_295.rs b/sdk/compute/src/v2/server/evacuate_295.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/evacuate_295.rs rename to sdk/compute/src/v2/server/evacuate_295.rs index 0c3be59a5..92a27ece6 100644 --- a/openstack_sdk/src/api/compute/v2/server/evacuate_295.rs +++ b/sdk/compute/src/v2/server/evacuate_295.rs @@ -151,7 +151,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/find.rs b/sdk/compute/src/v2/server/find.rs new file mode 100644 index 000000000..8f344b8c9 --- /dev/null +++ b/sdk/compute/src/v2/server/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::server::{get as Get, list_detailed as List}; + +/// Find for server 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/force_delete.rs b/sdk/compute/src/v2/server/force_delete.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/force_delete.rs rename to sdk/compute/src/v2/server/force_delete.rs index 9f51cee83..6a354d7d5 100644 --- a/openstack_sdk/src/api/compute/v2/server/force_delete.rs +++ b/sdk/compute/src/v2/server/force_delete.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/get.rs b/sdk/compute/src/v2/server/get.rs new file mode 100644 index 000000000..aa2c7e114 --- /dev/null +++ b/sdk/compute/src/v2/server/get.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`. + +//! Shows details for a server. +//! +//! Includes server details including configuration drive, extended status, and +//! server usage information. +//! +//! The extended status information appears in the `OS-EXT-STS:vm_state`, +//! `OS-EXT-STS:power_state`, and `OS-EXT-STS:task_state` attributes. +//! +//! The server usage information appears in the `OS-SRV-USG:launched_at` and +//! `OS-SRV-USG:terminated_at` attributes. +//! +//! HostId is unique per account and is not globally unique. +//! +//! **Preconditions** +//! +//! The server must exist. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("servers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "server" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/servers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/servers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/inject_network_info.rs b/sdk/compute/src/v2/server/inject_network_info.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/inject_network_info.rs rename to sdk/compute/src/v2/server/inject_network_info.rs index 3f09d0938..9e324ef05 100644 --- a/openstack_sdk/src/api/compute/v2/server/inject_network_info.rs +++ b/sdk/compute/src/v2/server/inject_network_info.rs @@ -125,7 +125,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/instance_action.rs b/sdk/compute/src/v2/server/instance_action.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/instance_action.rs rename to sdk/compute/src/v2/server/instance_action.rs diff --git a/sdk/compute/src/v2/server/instance_action/get.rs b/sdk/compute/src/v2/server/instance_action/get.rs new file mode 100644 index 000000000..4354f8f8d --- /dev/null +++ b/sdk/compute/src/v2/server/instance_action/get.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Shows details for a server action. +//! +//! Action details of deleted instances can be returned for requests later than +//! microversion 2.21. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/os-instance-actions/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-instance-actions/{id} API + #[builder(default, setter(into))] + server_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 Instance_Action. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-instance-actions/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("instanceAction".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "instanceAction" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-instance-actions/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "instanceAction": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-instance-actions/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "instanceAction": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/instance_action/list.rs b/sdk/compute/src/v2/server/instance_action/list.rs new file mode 100644 index 000000000..d0acc0612 --- /dev/null +++ b/sdk/compute/src/v2/server/instance_action/list.rs @@ -0,0 +1,226 @@ +// 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`. + +//! Lists actions for a server. +//! +//! Action information of deleted instances can be returned for requests +//! starting with microversion 2.21. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + changes_before: Option>, + + #[builder(default, setter(into))] + changes_since: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-instance-actions/{id} API + #[builder(default, setter(into))] + server_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 Instance_Action. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-instance-actions", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("changes-before", self.changes_before.as_ref()); + params.push_opt("changes-since", self.changes_since.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("instanceActions".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "instanceActions" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-instance-actions", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "instanceActions": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-instance-actions", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "instanceActions": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/interface.rs b/sdk/compute/src/v2/server/interface.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/interface.rs rename to sdk/compute/src/v2/server/interface.rs diff --git a/sdk/compute/src/v2/server/interface/create_20.rs b/sdk/compute/src/v2/server/interface/create_20.rs new file mode 100644 index 000000000..1713443a2 --- /dev/null +++ b/sdk/compute/src/v2/server/interface/create_20.rs @@ -0,0 +1,266 @@ +// 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`. + +//! Creates a port interface and uses it to attach a port to a server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409), computeFault(500), NotImplemented(501) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct FixedIps<'a> { + /// The IP address. It is required when `fixed_ips` is specified. + #[serde()] + #[builder(setter(into))] + pub(crate) ip_address: Cow<'a, str>, +} + +/// Specify the `interfaceAttachment` action in the request body. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InterfaceAttachment<'a> { + /// Fixed IP addresses. If you request a specific fixed IP address without + /// a `net_id`, the request returns a `Bad Request (400)` response code. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ips: Option>>, + + /// The ID of the network for which you want to create a port interface. + /// The `net_id` and `port_id` parameters are mutually exclusive. If you do + /// not specify the `net_id` parameter, the OpenStack Networking API v2.0 + /// uses the network information cache that is associated with the + /// instance. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) net_id: Option>, + + /// The ID of the port for which you want to create an interface. The + /// `net_id` and `port_id` parameters are mutually exclusive. If you do not + /// specify the `port_id` parameter, the OpenStack Networking API v2.0 + /// allocates a port and creates an interface for it on the network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Specify the `interfaceAttachment` action in the request body. + #[builder(setter(into))] + pub(crate) interface_attachment: InterfaceAttachment<'a>, + + /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API + #[builder(default, setter(into))] + server_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 Interface. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "servers/{server_id}/os-interface", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "interfaceAttachment", + serde_json::to_value(&self.interface_attachment)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("interfaceAttachment".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "interfaceAttachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/servers/{server_id}/os-interface", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "interfaceAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/servers/{server_id}/os-interface", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "interfaceAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/interface/create_249.rs b/sdk/compute/src/v2/server/interface/create_249.rs new file mode 100644 index 000000000..f8ddadb5f --- /dev/null +++ b/sdk/compute/src/v2/server/interface/create_249.rs @@ -0,0 +1,276 @@ +// 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`. + +//! Creates a port interface and uses it to attach a port to a server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409), computeFault(500), NotImplemented(501) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct FixedIps<'a> { + /// The IP address. It is required when `fixed_ips` is specified. + #[serde()] + #[builder(setter(into))] + pub(crate) ip_address: Cow<'a, str>, +} + +/// Specify the `interfaceAttachment` action in the request body. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InterfaceAttachment<'a> { + /// Fixed IP addresses. If you request a specific fixed IP address without + /// a `net_id`, the request returns a `Bad Request (400)` response code. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ips: Option>>, + + /// The ID of the network for which you want to create a port interface. + /// The `net_id` and `port_id` parameters are mutually exclusive. If you do + /// not specify the `net_id` parameter, the OpenStack Networking API v2.0 + /// uses the network information cache that is associated with the + /// instance. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) net_id: Option>, + + /// The ID of the port for which you want to create an interface. The + /// `net_id` and `port_id` parameters are mutually exclusive. If you do not + /// specify the `port_id` parameter, the OpenStack Networking API v2.0 + /// allocates a port and creates an interface for it on the network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_id: Option>, + + /// A device role tag that can be applied to a network interface when + /// attaching it to the VM. The guest OS of a server that has devices + /// tagged in this manner can access hardware metadata about the tagged + /// devices from the metadata API and on the config drive, if enabled. + /// + /// **New in version 2.49** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tag: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Specify the `interfaceAttachment` action in the request body. + #[builder(setter(into))] + pub(crate) interface_attachment: InterfaceAttachment<'a>, + + /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API + #[builder(default, setter(into))] + server_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 Interface. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "servers/{server_id}/os-interface", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "interfaceAttachment", + serde_json::to_value(&self.interface_attachment)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("interfaceAttachment".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(2, 49)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "interfaceAttachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/servers/{server_id}/os-interface", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "interfaceAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/servers/{server_id}/os-interface", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "interfaceAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .interface_attachment(InterfaceAttachmentBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/interface/delete.rs b/sdk/compute/src/v2/server/interface/delete.rs new file mode 100644 index 000000000..8b0db18ca --- /dev/null +++ b/sdk/compute/src/v2/server/interface/delete.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`. + +//! Detaches a port interface from a server. +//! +//! Normal response codes: 202 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), +//! conflict(409), NotImplemented(501) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/os-interface/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API + #[builder(default, setter(into))] + server_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 Interface. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-interface/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/os-interface/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/os-interface/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/interface/get.rs b/sdk/compute/src/v2/server/interface/get.rs new file mode 100644 index 000000000..eaa65c2cf --- /dev/null +++ b/sdk/compute/src/v2/server/interface/get.rs @@ -0,0 +1,209 @@ +// 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`. + +//! Shows details for a port interface that is attached to a server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/os-interface/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API + #[builder(default, setter(into))] + server_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 Interface. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-interface/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("interfaceAttachment".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "interfaceAttachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-interface/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "interfaceAttachment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-interface/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "interfaceAttachment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/interface/list.rs b/sdk/compute/src/v2/server/interface/list.rs new file mode 100644 index 000000000..69d942f6b --- /dev/null +++ b/sdk/compute/src/v2/server/interface/list.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Lists port interfaces that are attached to a server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), +//! NotImplemented(501) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/os-interface/{id} API + #[builder(default, setter(into))] + server_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 Interface. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-interface", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-interface", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-interface", + server_id = "server_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() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/ip.rs b/sdk/compute/src/v2/server/ip.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/ip.rs rename to sdk/compute/src/v2/server/ip.rs diff --git a/sdk/compute/src/v2/server/ip/get.rs b/sdk/compute/src/v2/server/ip/get.rs new file mode 100644 index 000000000..0093f25e4 --- /dev/null +++ b/sdk/compute/src/v2/server/ip/get.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Shows IP addresses details for a network label of a server instance. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/ips/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/ips/{id} API + #[builder(default, setter(into))] + server_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 Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/ips/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/ips/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/ips/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/ip/list.rs b/sdk/compute/src/v2/server/ip/list.rs new file mode 100644 index 000000000..eaf551c7b --- /dev/null +++ b/sdk/compute/src/v2/server/ip/list.rs @@ -0,0 +1,196 @@ +// 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`. + +//! Lists IP addresses that are assigned to an instance. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/ips/{id} API + #[builder(default, setter(into))] + server_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 Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/ips", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("addresses".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "addresses" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/servers/{server_id}/ips", server_id = "server_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "addresses": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/servers/{server_id}/ips", server_id = "server_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "addresses": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/list.rs b/sdk/compute/src/v2/server/list.rs new file mode 100644 index 000000000..fa1008d84 --- /dev/null +++ b/sdk/compute/src/v2/server/list.rs @@ -0,0 +1,426 @@ +// 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`. + +//! Lists IDs, names, and links for servers. +//! +//! By default the servers are filtered using the project ID associated with +//! the authenticated request. +//! +//! Servers contain a status attribute that indicates the current server state. +//! You can filter on the server status when you complete a list servers +//! request. The server status is returned in the response body. The possible +//! server status values are: +//! +//! There is whitelist for valid filter keys. Any filter key other than from +//! whitelist will be silently ignored. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + access_ip_v4: Option>, + + #[builder(default, setter(into))] + access_ip_v6: Option>, + + #[builder(default, setter(into))] + all_tenants: Option>, + + #[builder(default, setter(into))] + auto_disk_config: Option>, + + #[builder(default, setter(into))] + availability_zone: Option>, + + #[builder(default, setter(into))] + block_device_mapping: Option>, + + #[builder(default, setter(into))] + changes_before: Option>, + + #[builder(default, setter(into))] + changes_since: Option>, + + #[builder(default, setter(into))] + config_drive: Option>, + + #[builder(default, setter(into))] + created_at: Option>, + + #[builder(default, setter(into))] + deleted: Option>, + + #[builder(default, setter(into))] + description: Option>, + + #[builder(default, setter(into))] + display_description: Option>, + + #[builder(default, setter(into))] + display_name: Option>, + + #[builder(default, setter(into))] + flavor: Option>, + + #[builder(default, setter(into))] + host: Option>, + + #[builder(default, setter(into))] + hostname: Option>, + + #[builder(default, setter(into))] + image: Option>, + + #[builder(default, setter(into))] + image_ref: Option>, + + #[builder(default, setter(into))] + info_cache: Option>, + + #[builder(default, setter(into))] + ip: Option>, + + #[builder(default, setter(into))] + ip6: Option>, + + #[builder(default, setter(into))] + kernel_id: Option>, + + #[builder(default, setter(into))] + key_name: Option>, + + #[builder(default, setter(into))] + launch_index: Option>, + + #[builder(default, setter(into))] + launched_at: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + locked: Option>, + + #[builder(default, setter(into))] + locked_by: Option>, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + metadata: Option>, + + #[builder(default, setter(into))] + name: Option>, + + #[builder(default, setter(into))] + node: Option>, + + #[builder(default, setter(into))] + not_tags: Option>, + + #[builder(default, setter(into))] + not_tags_any: Option>, + + #[builder(default, setter(into))] + pci_devices: Option>, + + #[builder(default, setter(into))] + power_state: Option>, + + #[builder(default, setter(into))] + progress: Option>, + + #[builder(default, setter(into))] + project_id: Option>, + + #[builder(default, setter(into))] + ramdisk_id: Option>, + + #[builder(default, setter(into))] + reservation_id: Option>, + + #[builder(default, setter(into))] + root_device_name: Option>, + + #[builder(default, setter(into))] + security_groups: Option>, + + #[builder(default, setter(into))] + services: Option>, + + #[builder(default, setter(into))] + soft_deleted: Option>, + + #[builder(default, setter(into))] + sort_dir: Option>, + + #[builder(default, setter(into))] + sort_key: Option>, + + #[builder(default, setter(into))] + status: Option>, + + #[builder(default, setter(into))] + system_metadata: Option>, + + #[builder(default, setter(into))] + tags: Option>, + + #[builder(default, setter(into))] + tags_any: Option>, + + #[builder(default, setter(into))] + task_state: Option>, + + #[builder(default, setter(into))] + tenant_id: Option>, + + #[builder(default, setter(into))] + terminated_at: Option>, + + #[builder(default, setter(into))] + user_id: Option>, + + #[builder(default, setter(into))] + uuid: Option>, + + #[builder(default, setter(into))] + vm_state: 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> { + /// Add a single header to the Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "servers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("access_ip_v4", self.access_ip_v4.as_ref()); + params.push_opt("access_ip_v6", self.access_ip_v6.as_ref()); + params.push_opt("all_tenants", self.all_tenants.as_ref()); + params.push_opt("auto_disk_config", self.auto_disk_config.as_ref()); + params.push_opt("availability_zone", self.availability_zone.as_ref()); + params.push_opt("block_device_mapping", self.block_device_mapping.as_ref()); + params.push_opt("changes-before", self.changes_before.as_ref()); + params.push_opt("changes-since", self.changes_since.as_ref()); + params.push_opt("config_drive", self.config_drive.as_ref()); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("deleted", self.deleted.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("display_description", self.display_description.as_ref()); + params.push_opt("display_name", self.display_name.as_ref()); + params.push_opt("flavor", self.flavor.as_ref()); + params.push_opt("host", self.host.as_ref()); + params.push_opt("hostname", self.hostname.as_ref()); + params.push_opt("image", self.image.as_ref()); + params.push_opt("image_ref", self.image_ref.as_ref()); + params.push_opt("info_cache", self.info_cache.as_ref()); + params.push_opt("ip", self.ip.as_ref()); + params.push_opt("ip6", self.ip6.as_ref()); + params.push_opt("kernel_id", self.kernel_id.as_ref()); + params.push_opt("key_name", self.key_name.as_ref()); + params.push_opt("launch_index", self.launch_index.as_ref()); + params.push_opt("launched_at", self.launched_at.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("locked", self.locked.as_ref()); + params.push_opt("locked_by", self.locked_by.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("metadata", self.metadata.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("node", self.node.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("pci_devices", self.pci_devices.as_ref()); + params.push_opt("power_state", self.power_state.as_ref()); + params.push_opt("progress", self.progress.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("ramdisk_id", self.ramdisk_id.as_ref()); + params.push_opt("reservation_id", self.reservation_id.as_ref()); + params.push_opt("root_device_name", self.root_device_name.as_ref()); + params.push_opt("security_groups", self.security_groups.as_ref()); + params.push_opt("services", self.services.as_ref()); + params.push_opt("soft_deleted", self.soft_deleted.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("system_metadata", self.system_metadata.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("task_state", self.task_state.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + params.push_opt("terminated_at", self.terminated_at.as_ref()); + params.push_opt("user_id", self.user_id.as_ref()); + params.push_opt("uuid", self.uuid.as_ref()); + params.push_opt("vm_state", self.vm_state.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("servers".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "servers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/servers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "servers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/servers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "servers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/list_detailed.rs b/sdk/compute/src/v2/server/list_detailed.rs new file mode 100644 index 000000000..8c2dad19b --- /dev/null +++ b/sdk/compute/src/v2/server/list_detailed.rs @@ -0,0 +1,424 @@ +// 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`. + +//! For each server, shows server details including config drive, extended +//! status, and server usage information. +//! +//! The extended status information appears in the OS-EXT-STS:vm_state, +//! OS-EXT-STS:power_state, and OS-EXT-STS:task_state attributes. +//! +//! The server usage information appears in the OS-SRV-USG:launched_at and +//! OS-SRV-USG:terminated_at attributes. +//! +//! HostId is unique per account and is not globally unique. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + access_ip_v4: Option>, + + #[builder(default, setter(into))] + access_ip_v6: Option>, + + #[builder(default, setter(into))] + all_tenants: Option>, + + #[builder(default, setter(into))] + auto_disk_config: Option>, + + #[builder(default, setter(into))] + availability_zone: Option>, + + #[builder(default, setter(into))] + block_device_mapping: Option>, + + #[builder(default, setter(into))] + changes_before: Option>, + + #[builder(default, setter(into))] + changes_since: Option>, + + #[builder(default, setter(into))] + config_drive: Option>, + + #[builder(default, setter(into))] + created_at: Option>, + + #[builder(default, setter(into))] + deleted: Option>, + + #[builder(default, setter(into))] + description: Option>, + + #[builder(default, setter(into))] + display_description: Option>, + + #[builder(default, setter(into))] + display_name: Option>, + + #[builder(default, setter(into))] + flavor: Option>, + + #[builder(default, setter(into))] + host: Option>, + + #[builder(default, setter(into))] + hostname: Option>, + + #[builder(default, setter(into))] + image: Option>, + + #[builder(default, setter(into))] + image_ref: Option>, + + #[builder(default, setter(into))] + info_cache: Option>, + + #[builder(default, setter(into))] + ip: Option>, + + #[builder(default, setter(into))] + ip6: Option>, + + #[builder(default, setter(into))] + kernel_id: Option>, + + #[builder(default, setter(into))] + key_name: Option>, + + #[builder(default, setter(into))] + launch_index: Option>, + + #[builder(default, setter(into))] + launched_at: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + locked: Option>, + + #[builder(default, setter(into))] + locked_by: Option>, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + metadata: Option>, + + #[builder(default, setter(into))] + name: Option>, + + #[builder(default, setter(into))] + node: Option>, + + #[builder(default, setter(into))] + not_tags: Option>, + + #[builder(default, setter(into))] + not_tags_any: Option>, + + #[builder(default, setter(into))] + pci_devices: Option>, + + #[builder(default, setter(into))] + power_state: Option>, + + #[builder(default, setter(into))] + progress: Option>, + + #[builder(default, setter(into))] + project_id: Option>, + + #[builder(default, setter(into))] + ramdisk_id: Option>, + + #[builder(default, setter(into))] + reservation_id: Option>, + + #[builder(default, setter(into))] + root_device_name: Option>, + + #[builder(default, setter(into))] + security_groups: Option>, + + #[builder(default, setter(into))] + services: Option>, + + #[builder(default, setter(into))] + soft_deleted: Option>, + + #[builder(default, setter(into))] + sort_dir: Option>, + + #[builder(default, setter(into))] + sort_key: Option>, + + #[builder(default, setter(into))] + status: Option>, + + #[builder(default, setter(into))] + system_metadata: Option>, + + #[builder(default, setter(into))] + tags: Option>, + + #[builder(default, setter(into))] + tags_any: Option>, + + #[builder(default, setter(into))] + task_state: Option>, + + #[builder(default, setter(into))] + tenant_id: Option>, + + #[builder(default, setter(into))] + terminated_at: Option>, + + #[builder(default, setter(into))] + user_id: Option>, + + #[builder(default, setter(into))] + uuid: Option>, + + #[builder(default, setter(into))] + vm_state: 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> { + /// Add a single header to the Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "servers/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("access_ip_v4", self.access_ip_v4.as_ref()); + params.push_opt("access_ip_v6", self.access_ip_v6.as_ref()); + params.push_opt("all_tenants", self.all_tenants.as_ref()); + params.push_opt("auto_disk_config", self.auto_disk_config.as_ref()); + params.push_opt("availability_zone", self.availability_zone.as_ref()); + params.push_opt("block_device_mapping", self.block_device_mapping.as_ref()); + params.push_opt("changes-before", self.changes_before.as_ref()); + params.push_opt("changes-since", self.changes_since.as_ref()); + params.push_opt("config_drive", self.config_drive.as_ref()); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("deleted", self.deleted.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("display_description", self.display_description.as_ref()); + params.push_opt("display_name", self.display_name.as_ref()); + params.push_opt("flavor", self.flavor.as_ref()); + params.push_opt("host", self.host.as_ref()); + params.push_opt("hostname", self.hostname.as_ref()); + params.push_opt("image", self.image.as_ref()); + params.push_opt("image_ref", self.image_ref.as_ref()); + params.push_opt("info_cache", self.info_cache.as_ref()); + params.push_opt("ip", self.ip.as_ref()); + params.push_opt("ip6", self.ip6.as_ref()); + params.push_opt("kernel_id", self.kernel_id.as_ref()); + params.push_opt("key_name", self.key_name.as_ref()); + params.push_opt("launch_index", self.launch_index.as_ref()); + params.push_opt("launched_at", self.launched_at.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("locked", self.locked.as_ref()); + params.push_opt("locked_by", self.locked_by.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("metadata", self.metadata.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("node", self.node.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("pci_devices", self.pci_devices.as_ref()); + params.push_opt("power_state", self.power_state.as_ref()); + params.push_opt("progress", self.progress.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("ramdisk_id", self.ramdisk_id.as_ref()); + params.push_opt("reservation_id", self.reservation_id.as_ref()); + params.push_opt("root_device_name", self.root_device_name.as_ref()); + params.push_opt("security_groups", self.security_groups.as_ref()); + params.push_opt("services", self.services.as_ref()); + params.push_opt("soft_deleted", self.soft_deleted.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("system_metadata", self.system_metadata.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("task_state", self.task_state.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + params.push_opt("terminated_at", self.terminated_at.as_ref()); + params.push_opt("user_id", self.user_id.as_ref()); + params.push_opt("uuid", self.uuid.as_ref()); + params.push_opt("vm_state", self.vm_state.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("servers".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "servers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/servers/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "servers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/servers/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "servers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/lock_21.rs b/sdk/compute/src/v2/server/lock_21.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/lock_21.rs rename to sdk/compute/src/v2/server/lock_21.rs index a58d46b4e..f662c1c90 100644 --- a/openstack_sdk/src/api/compute/v2/server/lock_21.rs +++ b/sdk/compute/src/v2/server/lock_21.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/lock_273.rs b/sdk/compute/src/v2/server/lock_273.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/lock_273.rs rename to sdk/compute/src/v2/server/lock_273.rs index 7bc2b96d9..883bd0f4a 100644 --- a/openstack_sdk/src/api/compute/v2/server/lock_273.rs +++ b/sdk/compute/src/v2/server/lock_273.rs @@ -134,7 +134,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/metadata.rs b/sdk/compute/src/v2/server/metadata.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/metadata.rs rename to sdk/compute/src/v2/server/metadata.rs diff --git a/sdk/compute/src/v2/server/metadata/create.rs b/sdk/compute/src/v2/server/metadata/create.rs new file mode 100644 index 000000000..2023c96f3 --- /dev/null +++ b/sdk/compute/src/v2/server/metadata/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`. + +//! Create or update one or more metadata items for a server. +//! +//! Creates any metadata items that do not already exist in the server, +//! replaces exists metadata items that match keys. Does not modify items that +//! are not in the request. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Metadata key and value pairs. The maximum size for each metadata key + /// and value pair is 255 bytes. + #[builder(private, setter(into, name = "_metadata"))] + pub(crate) metadata: BTreeMap, Cow<'a, str>>, + + /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + server_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> { + /// Metadata key and value pairs. The maximum size for each metadata key + /// and value pair is 255 bytes. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "servers/{server_id}/metadata", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("metadata", serde_json::to_value(&self.metadata)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("metadata".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/servers/{server_id}/metadata", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/servers/{server_id}/metadata", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .metadata(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/metadata/delete.rs b/sdk/compute/src/v2/server/metadata/delete.rs new file mode 100644 index 000000000..ed647cf2e --- /dev/null +++ b/sdk/compute/src/v2/server/metadata/delete.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`. + +//! Deletes a metadata item, by key, from a server. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + server_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/metadata/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/metadata/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/metadata/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/metadata/get.rs b/sdk/compute/src/v2/server/metadata/get.rs new file mode 100644 index 000000000..45be5c910 --- /dev/null +++ b/sdk/compute/src/v2/server/metadata/get.rs @@ -0,0 +1,213 @@ +// 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`. + +//! Shows details for a metadata item, by key, for a server. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + server_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/metadata/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("meta".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "meta" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/metadata/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/metadata/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/metadata/list.rs b/sdk/compute/src/v2/server/metadata/list.rs new file mode 100644 index 000000000..d96f8b7c3 --- /dev/null +++ b/sdk/compute/src/v2/server/metadata/list.rs @@ -0,0 +1,201 @@ +// 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`. + +//! Lists all metadata for a server. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + server_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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/metadata", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("metadata".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/metadata", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/metadata", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/metadata/replace.rs b/sdk/compute/src/v2/server/metadata/replace.rs new file mode 100644 index 000000000..1adea9dad --- /dev/null +++ b/sdk/compute/src/v2/server/metadata/replace.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`. + +//! Replaces one or more metadata items for a server. +//! +//! Creates any metadata items that do not already exist in the server. Removes +//! and completely replaces any metadata items that already exist in the server +//! with the metadata items in the request. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Metadata key and value pairs. The maximum size for each metadata key + /// and value pair is 255 bytes. + #[builder(private, setter(into, name = "_metadata"))] + pub(crate) metadata: BTreeMap, Cow<'a, str>>, + + /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + server_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> { + /// Metadata key and value pairs. The maximum size for each metadata key + /// and value pair is 255 bytes. + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "servers/{server_id}/metadata", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("metadata", serde_json::to_value(&self.metadata)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("metadata".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metadata" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/servers/{server_id}/metadata", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .metadata(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/servers/{server_id}/metadata", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metadata": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .metadata(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/metadata/set.rs b/sdk/compute/src/v2/server/metadata/set.rs new file mode 100644 index 000000000..4a2c76db0 --- /dev/null +++ b/sdk/compute/src/v2/server/metadata/set.rs @@ -0,0 +1,253 @@ +// 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`. + +//! Creates or replaces a metadata item, by key, for a server. +//! +//! Creates a metadata item that does not already exist in the server. Replaces +//! existing metadata items that match keys with the metadata item in the +//! request. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_meta"))] + pub(crate) meta: BTreeMap, Cow<'a, str>>, + + /// id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/metadata/{id} API + #[builder(default, setter(into))] + server_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> { + pub fn meta(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.meta + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "servers/{server_id}/metadata/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("meta", serde_json::to_value(&self.meta)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("meta".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "meta" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/servers/{server_id}/metadata/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .meta(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/servers/{server_id}/metadata/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "meta": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .meta(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/migrate_256.rs b/sdk/compute/src/v2/server/migrate_256.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/migrate_256.rs rename to sdk/compute/src/v2/server/migrate_256.rs index a477df2a9..f7efc3303 100644 --- a/openstack_sdk/src/api/compute/v2/server/migrate_256.rs +++ b/sdk/compute/src/v2/server/migrate_256.rs @@ -134,7 +134,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/migration.rs b/sdk/compute/src/v2/server/migration.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/migration.rs rename to sdk/compute/src/v2/server/migration.rs diff --git a/sdk/compute/src/v2/server/migration/delete.rs b/sdk/compute/src/v2/server/migration/delete.rs new file mode 100644 index 000000000..305b856f7 --- /dev/null +++ b/sdk/compute/src/v2/server/migration/delete.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`. + +//! Abort an in-progress live migration. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! **Preconditions** +//! +//! The server OS-EXT-STS:task_state value must be `migrating`. +//! +//! If the server is locked, you must have administrator privileges to force +//! the completion of the server migration. +//! +//! For microversions from 2.24 to 2.64 the migration status must be `running`, +//! for microversion 2.65 and greater, the migration status can also be +//! `queued` and `preparing`. +//! +//! **Asynchronous Postconditions** +//! +//! After you make this request, you typically must keep polling the server +//! status to determine whether the request succeeded. You may also monitor the +//! migration using: +//! +//! **Troubleshooting** +//! +//! If the server status remains `MIGRATING` for an inordinate amount of time, +//! the request may have failed. Ensure you meet the preconditions and run the +//! request again. If the request fails again, investigate the compute back +//! end. +//! +//! Normal response codes: 202 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/migrations/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/migrations/{id} API + #[builder(default, setter(into))] + server_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 Migration. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/migrations/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/migrations/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/migrations/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/migration/find.rs b/sdk/compute/src/v2/server/migration/find.rs new file mode 100644 index 000000000..95d06f399 --- /dev/null +++ b/sdk/compute/src/v2/server/migration/find.rs @@ -0,0 +1,118 @@ +// 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 tracing::trace; + +use crate::api::find::Findable; +use crate::api::rest_endpoint_prelude::*; + +use crate::api::{ApiError, RestClient}; + +use crate::v2::server::migration::{get as Get, list as List}; + +/// Find for server/migration by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[builder(default, setter(into))] + server_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 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<'a>; + fn get_ep(&self) -> Get::Request<'a> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.server_id(self.server_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<'a> { + let mut ep = List::Request::builder(); + ep.server_id(self.server_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().unwrap() + } + /// Locate server/migration in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // server/migration 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/compute/v2/server/migration/force_complete_222.rs b/sdk/compute/src/v2/server/migration/force_complete_222.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/migration/force_complete_222.rs rename to sdk/compute/src/v2/server/migration/force_complete_222.rs index d1e1478f3..af03bcf39 100644 --- a/openstack_sdk/src/api/compute/v2/server/migration/force_complete_222.rs +++ b/sdk/compute/src/v2/server/migration/force_complete_222.rs @@ -128,7 +128,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/migration/get.rs b/sdk/compute/src/v2/server/migration/get.rs new file mode 100644 index 000000000..d040307cb --- /dev/null +++ b/sdk/compute/src/v2/server/migration/get.rs @@ -0,0 +1,213 @@ +// 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 details for an in-progress live migration for a given server. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/migrations/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/migrations/{id} API + #[builder(default, setter(into))] + server_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 Migration. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/migrations/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("migration".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "migration" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/migrations/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "migration": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/migrations/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "migration": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/migration/list.rs b/sdk/compute/src/v2/server/migration/list.rs new file mode 100644 index 000000000..2fb2fccad --- /dev/null +++ b/sdk/compute/src/v2/server/migration/list.rs @@ -0,0 +1,201 @@ +// 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`. + +//! Lists in-progress live migrations for a given server. +//! +//! Policy defaults enable only users with the administrative role to perform +//! this operation. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/migrations/{id} API + #[builder(default, setter(into))] + server_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 Migration. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/migrations", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("migrations".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "migrations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/migrations", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "migrations": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/migrations", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "migrations": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_console_output.rs b/sdk/compute/src/v2/server/os_get_console_output.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_get_console_output.rs rename to sdk/compute/src/v2/server/os_get_console_output.rs index 3517ba784..68138bb45 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_console_output.rs +++ b/sdk/compute/src/v2/server/os_get_console_output.rs @@ -142,7 +142,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_rdpconsole.rs b/sdk/compute/src/v2/server/os_get_rdpconsole.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/os_get_rdpconsole.rs rename to sdk/compute/src/v2/server/os_get_rdpconsole.rs index 0e9cae908..7077a9ec5 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_rdpconsole.rs +++ b/sdk/compute/src/v2/server/os_get_rdpconsole.rs @@ -118,7 +118,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_rdpconsole_21.rs b/sdk/compute/src/v2/server/os_get_rdpconsole_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_get_rdpconsole_21.rs rename to sdk/compute/src/v2/server/os_get_rdpconsole_21.rs index f546ffd0e..37b626294 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_rdpconsole_21.rs +++ b/sdk/compute/src/v2/server/os_get_rdpconsole_21.rs @@ -133,7 +133,7 @@ mod tests { #![allow(unused_imports)] use super::*; use crate::api::Query; - use crate::test::client::MockServerClient; + use openstack_sdk_core::test::client::MockServerClient; use crate::types::ServiceType; use http::{HeaderName, HeaderValue}; use serde_json::json; diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_serial_console.rs b/sdk/compute/src/v2/server/os_get_serial_console.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/os_get_serial_console.rs rename to sdk/compute/src/v2/server/os_get_serial_console.rs index adfb6f3ba..dd32fe2d1 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_serial_console.rs +++ b/sdk/compute/src/v2/server/os_get_serial_console.rs @@ -104,7 +104,7 @@ impl<'a> RestEndpoint for Request<'a> { mod tests { use super::*; use crate::api::{self, Query, RawQuery}; - use crate::test::client::MockServerClient; + use openstack_sdk_core::test::client::MockServerClient; use crate::types::ServiceType; use http::{HeaderName, HeaderValue}; use serde::Deserialize; diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_serial_console_21.rs b/sdk/compute/src/v2/server/os_get_serial_console_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_get_serial_console_21.rs rename to sdk/compute/src/v2/server/os_get_serial_console_21.rs index dff518192..1ae57d987 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_serial_console_21.rs +++ b/sdk/compute/src/v2/server/os_get_serial_console_21.rs @@ -142,7 +142,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_spiceconsole.rs b/sdk/compute/src/v2/server/os_get_spiceconsole.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/os_get_spiceconsole.rs rename to sdk/compute/src/v2/server/os_get_spiceconsole.rs index 2f74bba05..33e195fc7 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_spiceconsole.rs +++ b/sdk/compute/src/v2/server/os_get_spiceconsole.rs @@ -104,7 +104,7 @@ impl<'a> RestEndpoint for Request<'a> { mod tests { use super::*; use crate::api::{self, Query, RawQuery}; - use crate::test::client::MockServerClient; + use openstack_sdk_core::test::client::MockServerClient; use crate::types::ServiceType; use http::{HeaderName, HeaderValue}; use serde::Deserialize; diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_spiceconsole_21.rs b/sdk/compute/src/v2/server/os_get_spiceconsole_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_get_spiceconsole_21.rs rename to sdk/compute/src/v2/server/os_get_spiceconsole_21.rs index 6c5960084..0645011a0 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_spiceconsole_21.rs +++ b/sdk/compute/src/v2/server/os_get_spiceconsole_21.rs @@ -142,7 +142,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_vncconsole.rs b/sdk/compute/src/v2/server/os_get_vncconsole.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/os_get_vncconsole.rs rename to sdk/compute/src/v2/server/os_get_vncconsole.rs index 04c67f384..71c659f67 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_vncconsole.rs +++ b/sdk/compute/src/v2/server/os_get_vncconsole.rs @@ -104,7 +104,7 @@ impl<'a> RestEndpoint for Request<'a> { mod tests { use super::*; use crate::api::{self, Query, RawQuery}; - use crate::test::client::MockServerClient; + use openstack_sdk_core::test::client::MockServerClient; use crate::types::ServiceType; use http::{HeaderName, HeaderValue}; use serde::Deserialize; diff --git a/openstack_sdk/src/api/compute/v2/server/os_get_vncconsole_21.rs b/sdk/compute/src/v2/server/os_get_vncconsole_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_get_vncconsole_21.rs rename to sdk/compute/src/v2/server/os_get_vncconsole_21.rs index e1d9dfb27..d2f289644 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_get_vncconsole_21.rs +++ b/sdk/compute/src/v2/server/os_get_vncconsole_21.rs @@ -144,7 +144,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_20.rs b/sdk/compute/src/v2/server/os_migrate_live_20.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_migrate_live_20.rs rename to sdk/compute/src/v2/server/os_migrate_live_20.rs index c3415739b..b98d10bf5 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_20.rs +++ b/sdk/compute/src/v2/server/os_migrate_live_20.rs @@ -164,7 +164,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_225.rs b/sdk/compute/src/v2/server/os_migrate_live_225.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_migrate_live_225.rs rename to sdk/compute/src/v2/server/os_migrate_live_225.rs index 7d4f8976a..ad8b73e8d 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_225.rs +++ b/sdk/compute/src/v2/server/os_migrate_live_225.rs @@ -159,7 +159,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_230.rs b/sdk/compute/src/v2/server/os_migrate_live_230.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_migrate_live_230.rs rename to sdk/compute/src/v2/server/os_migrate_live_230.rs index 253736547..eb2d1646c 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_230.rs +++ b/sdk/compute/src/v2/server/os_migrate_live_230.rs @@ -176,7 +176,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_268.rs b/sdk/compute/src/v2/server/os_migrate_live_268.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_migrate_live_268.rs rename to sdk/compute/src/v2/server/os_migrate_live_268.rs index 1346a51b6..ee9a5778d 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_migrate_live_268.rs +++ b/sdk/compute/src/v2/server/os_migrate_live_268.rs @@ -159,7 +159,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_reset_state.rs b/sdk/compute/src/v2/server/os_reset_state.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/os_reset_state.rs rename to sdk/compute/src/v2/server/os_reset_state.rs index 284b9b83d..5a3f36ee7 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_reset_state.rs +++ b/sdk/compute/src/v2/server/os_reset_state.rs @@ -141,7 +141,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_start.rs b/sdk/compute/src/v2/server/os_start.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/os_start.rs rename to sdk/compute/src/v2/server/os_start.rs index 5398d78ed..2e4f26e6f 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_start.rs +++ b/sdk/compute/src/v2/server/os_start.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/os_stop.rs b/sdk/compute/src/v2/server/os_stop.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/os_stop.rs rename to sdk/compute/src/v2/server/os_stop.rs index d23963ee7..00cd1e8f6 100644 --- a/openstack_sdk/src/api/compute/v2/server/os_stop.rs +++ b/sdk/compute/src/v2/server/os_stop.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/pause.rs b/sdk/compute/src/v2/server/pause.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/pause.rs rename to sdk/compute/src/v2/server/pause.rs index e3da68c5f..f7613e97f 100644 --- a/openstack_sdk/src/api/compute/v2/server/pause.rs +++ b/sdk/compute/src/v2/server/pause.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/reboot.rs b/sdk/compute/src/v2/server/reboot.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/reboot.rs rename to sdk/compute/src/v2/server/reboot.rs index 881b2a878..8cce94454 100644 --- a/openstack_sdk/src/api/compute/v2/server/reboot.rs +++ b/sdk/compute/src/v2/server/reboot.rs @@ -154,7 +154,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_20.rs b/sdk/compute/src/v2/server/rebuild_20.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_20.rs rename to sdk/compute/src/v2/server/rebuild_20.rs index b089265dd..594c9c2a6 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_20.rs +++ b/sdk/compute/src/v2/server/rebuild_20.rs @@ -248,7 +248,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_21.rs b/sdk/compute/src/v2/server/rebuild_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_21.rs rename to sdk/compute/src/v2/server/rebuild_21.rs index 28175ed85..36a36efbf 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_21.rs +++ b/sdk/compute/src/v2/server/rebuild_21.rs @@ -248,7 +248,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_219.rs b/sdk/compute/src/v2/server/rebuild_219.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_219.rs rename to sdk/compute/src/v2/server/rebuild_219.rs index 59314de5a..675f72ba0 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_219.rs +++ b/sdk/compute/src/v2/server/rebuild_219.rs @@ -256,7 +256,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_254.rs b/sdk/compute/src/v2/server/rebuild_254.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_254.rs rename to sdk/compute/src/v2/server/rebuild_254.rs index 4a74a8b48..9352356e9 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_254.rs +++ b/sdk/compute/src/v2/server/rebuild_254.rs @@ -272,7 +272,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_257.rs b/sdk/compute/src/v2/server/rebuild_257.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_257.rs rename to sdk/compute/src/v2/server/rebuild_257.rs index 844b1234e..0f71506fc 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_257.rs +++ b/sdk/compute/src/v2/server/rebuild_257.rs @@ -259,7 +259,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_263.rs b/sdk/compute/src/v2/server/rebuild_263.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_263.rs rename to sdk/compute/src/v2/server/rebuild_263.rs index 5d84f073f..6a5546cbd 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_263.rs +++ b/sdk/compute/src/v2/server/rebuild_263.rs @@ -273,7 +273,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_290.rs b/sdk/compute/src/v2/server/rebuild_290.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_290.rs rename to sdk/compute/src/v2/server/rebuild_290.rs index 6190e2421..e6eafc3ae 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_290.rs +++ b/sdk/compute/src/v2/server/rebuild_290.rs @@ -289,7 +289,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rebuild_294.rs b/sdk/compute/src/v2/server/rebuild_294.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rebuild_294.rs rename to sdk/compute/src/v2/server/rebuild_294.rs index 85f997f60..15f86b239 100644 --- a/openstack_sdk/src/api/compute/v2/server/rebuild_294.rs +++ b/sdk/compute/src/v2/server/rebuild_294.rs @@ -289,7 +289,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/remote_console.rs b/sdk/compute/src/v2/server/remote_console.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/remote_console.rs rename to sdk/compute/src/v2/server/remote_console.rs diff --git a/openstack_sdk/src/api/compute/v2/server/remote_console/create_26.rs b/sdk/compute/src/v2/server/remote_console/create_26.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/remote_console/create_26.rs rename to sdk/compute/src/v2/server/remote_console/create_26.rs index 38526c8c8..08d053dfd 100644 --- a/openstack_sdk/src/api/compute/v2/server/remote_console/create_26.rs +++ b/sdk/compute/src/v2/server/remote_console/create_26.rs @@ -189,7 +189,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/remote_console/create_28.rs b/sdk/compute/src/v2/server/remote_console/create_28.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/remote_console/create_28.rs rename to sdk/compute/src/v2/server/remote_console/create_28.rs index 97d2163a8..13f3edccf 100644 --- a/openstack_sdk/src/api/compute/v2/server/remote_console/create_28.rs +++ b/sdk/compute/src/v2/server/remote_console/create_28.rs @@ -193,7 +193,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/remote_console/create_299.rs b/sdk/compute/src/v2/server/remote_console/create_299.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/remote_console/create_299.rs rename to sdk/compute/src/v2/server/remote_console/create_299.rs index b496d4a86..f2de12c41 100644 --- a/openstack_sdk/src/api/compute/v2/server/remote_console/create_299.rs +++ b/sdk/compute/src/v2/server/remote_console/create_299.rs @@ -195,7 +195,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/remove_fixed_ip_21.rs b/sdk/compute/src/v2/server/remove_fixed_ip_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/remove_fixed_ip_21.rs rename to sdk/compute/src/v2/server/remove_fixed_ip_21.rs index 52541a8d1..dbc7776eb 100644 --- a/openstack_sdk/src/api/compute/v2/server/remove_fixed_ip_21.rs +++ b/sdk/compute/src/v2/server/remove_fixed_ip_21.rs @@ -136,7 +136,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/remove_floating_ip_21.rs b/sdk/compute/src/v2/server/remove_floating_ip_21.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/remove_floating_ip_21.rs rename to sdk/compute/src/v2/server/remove_floating_ip_21.rs index 32e92d936..acb68b197 100644 --- a/openstack_sdk/src/api/compute/v2/server/remove_floating_ip_21.rs +++ b/sdk/compute/src/v2/server/remove_floating_ip_21.rs @@ -137,7 +137,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/remove_security_group.rs b/sdk/compute/src/v2/server/remove_security_group.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/remove_security_group.rs rename to sdk/compute/src/v2/server/remove_security_group.rs index 61b5112c6..96a9921d0 100644 --- a/openstack_sdk/src/api/compute/v2/server/remove_security_group.rs +++ b/sdk/compute/src/v2/server/remove_security_group.rs @@ -155,7 +155,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/rescue.rs b/sdk/compute/src/v2/server/rescue.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/rescue.rs rename to sdk/compute/src/v2/server/rescue.rs index d29794d26..34e8c79c5 100644 --- a/openstack_sdk/src/api/compute/v2/server/rescue.rs +++ b/sdk/compute/src/v2/server/rescue.rs @@ -136,7 +136,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/reset_network.rs b/sdk/compute/src/v2/server/reset_network.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/reset_network.rs rename to sdk/compute/src/v2/server/reset_network.rs index ae15d88d6..d327ecc4b 100644 --- a/openstack_sdk/src/api/compute/v2/server/reset_network.rs +++ b/sdk/compute/src/v2/server/reset_network.rs @@ -118,7 +118,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/resize.rs b/sdk/compute/src/v2/server/resize.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/resize.rs rename to sdk/compute/src/v2/server/resize.rs index 7e53e4e43..beb224384 100644 --- a/openstack_sdk/src/api/compute/v2/server/resize.rs +++ b/sdk/compute/src/v2/server/resize.rs @@ -166,7 +166,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/restore.rs b/sdk/compute/src/v2/server/restore.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/restore.rs rename to sdk/compute/src/v2/server/restore.rs index 4811d72ad..bc13fedc8 100644 --- a/openstack_sdk/src/api/compute/v2/server/restore.rs +++ b/sdk/compute/src/v2/server/restore.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/resume.rs b/sdk/compute/src/v2/server/resume.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/resume.rs rename to sdk/compute/src/v2/server/resume.rs index 5f5221b82..1b2c64e15 100644 --- a/openstack_sdk/src/api/compute/v2/server/resume.rs +++ b/sdk/compute/src/v2/server/resume.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/revert_resize.rs b/sdk/compute/src/v2/server/revert_resize.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/revert_resize.rs rename to sdk/compute/src/v2/server/revert_resize.rs index d8622cb55..a50651c2e 100644 --- a/openstack_sdk/src/api/compute/v2/server/revert_resize.rs +++ b/sdk/compute/src/v2/server/revert_resize.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/security_group.rs b/sdk/compute/src/v2/server/security_group.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/security_group.rs rename to sdk/compute/src/v2/server/security_group.rs diff --git a/sdk/compute/src/v2/server/security_group/list.rs b/sdk/compute/src/v2/server/security_group/list.rs new file mode 100644 index 000000000..75b58b4f3 --- /dev/null +++ b/sdk/compute/src/v2/server/security_group/list.rs @@ -0,0 +1,198 @@ +// 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`. + +//! Lists security groups for a server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/os-security-groups + /// API + #[builder(default, setter(into))] + server_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 Security_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-security-groups", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("security_groups".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "security_groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-security-groups", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_groups": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-security-groups", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_groups": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/server_password.rs b/sdk/compute/src/v2/server/server_password.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/server_password.rs rename to sdk/compute/src/v2/server/server_password.rs diff --git a/sdk/compute/src/v2/server/server_password/delete.rs b/sdk/compute/src/v2/server/server_password/delete.rs new file mode 100644 index 000000000..684c7cf5c --- /dev/null +++ b/sdk/compute/src/v2/server/server_password/delete.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Clears the encrypted administrative password for a server, which removes it +//! from the database. +//! +//! This action does not actually change the instance server password. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/os-server-password + /// API + #[builder(default, setter(into))] + server_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 Server_Password. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-server-password", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/os-server-password", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/os-server-password", + server_id = "server_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() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/server_password/get.rs b/sdk/compute/src/v2/server/server_password/get.rs new file mode 100644 index 000000000..303c6dfae --- /dev/null +++ b/sdk/compute/src/v2/server/server_password/get.rs @@ -0,0 +1,206 @@ +// 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`. + +//! Shows the administrative password for a server. +//! +//! This operation calls the metadata service to query metadata information and +//! does not read password information from the server itself. +//! +//! The password saved in the metadata service is typically encrypted using the +//! public SSH key injected into this server, so the SSH private key is needed +//! to read the password. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of the server to perform this operation. Cloud providers can change these +//! permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/os-server-password + /// API + #[builder(default, setter(into))] + server_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 Server_Password. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-server-password", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-server-password", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-server-password", + server_id = "server_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() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/set_20.rs b/sdk/compute/src/v2/server/set_20.rs new file mode 100644 index 000000000..b15851968 --- /dev/null +++ b/sdk/compute/src/v2/server/set_20.rs @@ -0,0 +1,265 @@ +// 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`. + +//! Updates the editable attributes of an existing server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum OsDcfDiskConfig { + #[serde(rename = "AUTO")] + Auto, + #[serde(rename = "MANUAL")] + Manual, +} + +/// A `server` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Server<'a> { + /// IPv4 address that should be used to access this server. + #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv4: Option>, + + /// IPv6 address that should be used to access this server. + #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv6: Option>, + + /// The server name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Controls how the API partitions the disk when you create, rebuild, or + /// resize servers. A server inherits the `OS-DCF:diskConfig` value from + /// the image from which it was created, and an image inherits the + /// `OS-DCF:diskConfig` value from the server from which it was created. To + /// override the inherited setting, you can include this attribute in the + /// request body of a server create, rebuild, or resize request. If the + /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a + /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. + /// A valid value is: + /// + /// - `AUTO`. The API builds the server with a single partition the size of + /// the target flavor disk. The API automatically adjusts the file system + /// to fit the entire partition. + /// - `MANUAL`. The API builds the server by using whatever partition + /// scheme and file system is in the source image. If the target flavor + /// disk is larger, the API does not partition the remaining disk space. + #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) os_dcf_disk_config: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `server` object. + #[builder(setter(into))] + pub(crate) server: Server<'a>, + + /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("servers/{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("server", serde_json::to_value(&self.server)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .server(ServerBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .server(ServerBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "server" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/servers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server(ServerBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/servers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server(ServerBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/set_21.rs b/sdk/compute/src/v2/server/set_21.rs new file mode 100644 index 000000000..ceafcd5c7 --- /dev/null +++ b/sdk/compute/src/v2/server/set_21.rs @@ -0,0 +1,265 @@ +// 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`. + +//! Updates the editable attributes of an existing server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum OsDcfDiskConfig { + #[serde(rename = "AUTO")] + Auto, + #[serde(rename = "MANUAL")] + Manual, +} + +/// A `server` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Server<'a> { + /// IPv4 address that should be used to access this server. + #[serde(rename = "accessIPv4", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv4: Option>, + + /// IPv6 address that should be used to access this server. + #[serde(rename = "accessIPv6", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_ipv6: Option>, + + /// The server name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Controls how the API partitions the disk when you create, rebuild, or + /// resize servers. A server inherits the `OS-DCF:diskConfig` value from + /// the image from which it was created, and an image inherits the + /// `OS-DCF:diskConfig` value from the server from which it was created. To + /// override the inherited setting, you can include this attribute in the + /// request body of a server create, rebuild, or resize request. If the + /// `OS-DCF:diskConfig` value for an image is `MANUAL`, you cannot create a + /// server from that image and set its `OS-DCF:diskConfig` value to `AUTO`. + /// A valid value is: + /// + /// - `AUTO`. The API builds the server with a single partition the size of + /// the target flavor disk. The API automatically adjusts the file system + /// to fit the entire partition. + /// - `MANUAL`. The API builds the server by using whatever partition + /// scheme and file system is in the source image. If the target flavor + /// disk is larger, the API does not partition the remaining disk space. + #[serde(rename = "OS-DCF:diskConfig", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) os_dcf_disk_config: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `server` object. + #[builder(setter(into))] + pub(crate) server: Server<'a>, + + /// id parameter for /v2.1/servers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Server. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("servers/{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("server", serde_json::to_value(&self.server)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .server(ServerBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .server(ServerBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "server" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/servers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server(ServerBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/servers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server(ServerBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/set_219.rs b/sdk/compute/src/v2/server/set_219.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/set_219.rs rename to sdk/compute/src/v2/server/set_219.rs index 4885e1a45..c594b165e 100644 --- a/openstack_sdk/src/api/compute/v2/server/set_219.rs +++ b/sdk/compute/src/v2/server/set_219.rs @@ -186,7 +186,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/set_290.rs b/sdk/compute/src/v2/server/set_290.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/set_290.rs rename to sdk/compute/src/v2/server/set_290.rs index 0284c4750..41757c8c0 100644 --- a/openstack_sdk/src/api/compute/v2/server/set_290.rs +++ b/sdk/compute/src/v2/server/set_290.rs @@ -202,7 +202,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/set_294.rs b/sdk/compute/src/v2/server/set_294.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/set_294.rs rename to sdk/compute/src/v2/server/set_294.rs index 63f913fd8..f3d0fc313 100644 --- a/openstack_sdk/src/api/compute/v2/server/set_294.rs +++ b/sdk/compute/src/v2/server/set_294.rs @@ -202,7 +202,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/share.rs b/sdk/compute/src/v2/server/share.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/share.rs rename to sdk/compute/src/v2/server/share.rs diff --git a/openstack_sdk/src/api/compute/v2/server/share/create_297.rs b/sdk/compute/src/v2/server/share/create_297.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/share/create_297.rs rename to sdk/compute/src/v2/server/share/create_297.rs index 6a2ea3a59..5de861738 100644 --- a/openstack_sdk/src/api/compute/v2/server/share/create_297.rs +++ b/sdk/compute/src/v2/server/share/create_297.rs @@ -149,7 +149,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/share/delete.rs b/sdk/compute/src/v2/server/share/delete.rs new file mode 100644 index 000000000..d5ad34a58 --- /dev/null +++ b/sdk/compute/src/v2/server/share/delete.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`. + +//! Detach a share from an instance. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), forbidden(403), itemNotFound(404), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/shares/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/shares/{id} API + #[builder(default, setter(into))] + server_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 Share. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/shares/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/shares/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/shares/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/share/get.rs b/sdk/compute/src/v2/server/share/get.rs new file mode 100644 index 000000000..83b66e0c2 --- /dev/null +++ b/sdk/compute/src/v2/server/share/get.rs @@ -0,0 +1,209 @@ +// 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 a detail of a share attachment. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/shares/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/shares/{id} API + #[builder(default, setter(into))] + server_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 Share. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/shares/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("share".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "share" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/shares/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "share": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/shares/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "share": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/share/list.rs b/sdk/compute/src/v2/server/share/list.rs new file mode 100644 index 000000000..844a6884e --- /dev/null +++ b/sdk/compute/src/v2/server/share/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 share attachments for an instance. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badrequest(400), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/shares/{id} API + #[builder(default, setter(into))] + server_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 Share. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/shares", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("shares".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "shares" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/shares", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "shares": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/shares", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "shares": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/shelve.rs b/sdk/compute/src/v2/server/shelve.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/shelve.rs rename to sdk/compute/src/v2/server/shelve.rs index 63afcb463..70d4c5263 100644 --- a/openstack_sdk/src/api/compute/v2/server/shelve.rs +++ b/sdk/compute/src/v2/server/shelve.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/shelve_offload.rs b/sdk/compute/src/v2/server/shelve_offload.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/shelve_offload.rs rename to sdk/compute/src/v2/server/shelve_offload.rs index d7b46afb9..9fbaabf37 100644 --- a/openstack_sdk/src/api/compute/v2/server/shelve_offload.rs +++ b/sdk/compute/src/v2/server/shelve_offload.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/suspend.rs b/sdk/compute/src/v2/server/suspend.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/suspend.rs rename to sdk/compute/src/v2/server/suspend.rs index ccf26bca1..683a27ef4 100644 --- a/openstack_sdk/src/api/compute/v2/server/suspend.rs +++ b/sdk/compute/src/v2/server/suspend.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/tag.rs b/sdk/compute/src/v2/server/tag.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/tag.rs rename to sdk/compute/src/v2/server/tag.rs diff --git a/sdk/compute/src/v2/server/tag/delete.rs b/sdk/compute/src/v2/server/tag/delete.rs new file mode 100644 index 000000000..840ab8843 --- /dev/null +++ b/sdk/compute/src/v2/server/tag/delete.rs @@ -0,0 +1,206 @@ +// 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`. + +//! Deletes a single tag from the specified server. +//! +//! Normal response codes: 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + server_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/tags/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/tags/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/tags/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/tag/delete_all.rs b/sdk/compute/src/v2/server/tag/delete_all.rs new file mode 100644 index 000000000..99d4b9f13 --- /dev/null +++ b/sdk/compute/src/v2/server/tag/delete_all.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Deletes all tags from the specified server. +//! +//! Normal response codes: 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + server_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/tags", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/tags", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/tags", + server_id = "server_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() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/tag/get.rs b/sdk/compute/src/v2/server/tag/get.rs new file mode 100644 index 000000000..250cd754e --- /dev/null +++ b/sdk/compute/src/v2/server/tag/get.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`. + +//! Checks tag existence on the server. If tag exists response with 204 status +//! code will be returned. Otherwise returns 404. +//! +//! Normal response codes: 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + server_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/tags/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/tags/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/tags/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/tag/list.rs b/sdk/compute/src/v2/server/tag/list.rs new file mode 100644 index 000000000..8d2085e0a --- /dev/null +++ b/sdk/compute/src/v2/server/tag/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`. + +//! Lists all tags for a server. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + server_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/tags", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/tags", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/tags", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/tag/replace_226.rs b/sdk/compute/src/v2/server/tag/replace_226.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/tag/replace_226.rs rename to sdk/compute/src/v2/server/tag/replace_226.rs index 8f32010f7..7e5a16015 100644 --- a/openstack_sdk/src/api/compute/v2/server/tag/replace_226.rs +++ b/sdk/compute/src/v2/server/tag/replace_226.rs @@ -132,7 +132,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/tag/set.rs b/sdk/compute/src/v2/server/tag/set.rs new file mode 100644 index 000000000..929927543 --- /dev/null +++ b/sdk/compute/src/v2/server/tag/set.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Adds a single tag to the server if server has no specified tag. Response +//! code in this case is 201. +//! +//! If the server has specified tag just returns 204. +//! +//! Normal response codes: 201, 204 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for /v2.1/servers/{server_id}/tags/{id} API + #[builder(default, setter(into))] + server_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "servers/{server_id}/tags/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/servers/{server_id}/tags/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/servers/{server_id}/tags/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/topology.rs b/sdk/compute/src/v2/server/topology.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/topology.rs rename to sdk/compute/src/v2/server/topology.rs diff --git a/sdk/compute/src/v2/server/topology/list.rs b/sdk/compute/src/v2/server/topology/list.rs new file mode 100644 index 000000000..def4bf7fe --- /dev/null +++ b/sdk/compute/src/v2/server/topology/list.rs @@ -0,0 +1,201 @@ +// 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`. + +//! Shows NUMA topology information for a server. +//! +//! Policy defaults enable only users with the administrative role or the +//! owners of the server to perform this operation. Cloud providers can change +//! these permissions through the `policy.yaml` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), notfound(404), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/topology API + #[builder(default, setter(into))] + server_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 Topology. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/topology", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("nodes".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "nodes" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/topology", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "nodes": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/topology", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "nodes": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/trigger_crash_dump_217.rs b/sdk/compute/src/v2/server/trigger_crash_dump_217.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/trigger_crash_dump_217.rs rename to sdk/compute/src/v2/server/trigger_crash_dump_217.rs index 8d897e8ef..33b93737d 100644 --- a/openstack_sdk/src/api/compute/v2/server/trigger_crash_dump_217.rs +++ b/sdk/compute/src/v2/server/trigger_crash_dump_217.rs @@ -118,7 +118,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/unlock_21.rs b/sdk/compute/src/v2/server/unlock_21.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/unlock_21.rs rename to sdk/compute/src/v2/server/unlock_21.rs index e384be73d..b98403161 100644 --- a/openstack_sdk/src/api/compute/v2/server/unlock_21.rs +++ b/sdk/compute/src/v2/server/unlock_21.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/unpause.rs b/sdk/compute/src/v2/server/unpause.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/unpause.rs rename to sdk/compute/src/v2/server/unpause.rs index d7f039200..9365acbb4 100644 --- a/openstack_sdk/src/api/compute/v2/server/unpause.rs +++ b/sdk/compute/src/v2/server/unpause.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/unrescue.rs b/sdk/compute/src/v2/server/unrescue.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/unrescue.rs rename to sdk/compute/src/v2/server/unrescue.rs index 04b2edec5..a083501e3 100644 --- a/openstack_sdk/src/api/compute/v2/server/unrescue.rs +++ b/sdk/compute/src/v2/server/unrescue.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/unshelve_21.rs b/sdk/compute/src/v2/server/unshelve_21.rs similarity index 98% rename from openstack_sdk/src/api/compute/v2/server/unshelve_21.rs rename to sdk/compute/src/v2/server/unshelve_21.rs index 4f0939657..2583238b5 100644 --- a/openstack_sdk/src/api/compute/v2/server/unshelve_21.rs +++ b/sdk/compute/src/v2/server/unshelve_21.rs @@ -122,7 +122,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/unshelve_277.rs b/sdk/compute/src/v2/server/unshelve_277.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/unshelve_277.rs rename to sdk/compute/src/v2/server/unshelve_277.rs index f32dfa349..974d4566f 100644 --- a/openstack_sdk/src/api/compute/v2/server/unshelve_277.rs +++ b/sdk/compute/src/v2/server/unshelve_277.rs @@ -132,7 +132,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/unshelve_291.rs b/sdk/compute/src/v2/server/unshelve_291.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/unshelve_291.rs rename to sdk/compute/src/v2/server/unshelve_291.rs index 1a20ec05c..89721b646 100644 --- a/openstack_sdk/src/api/compute/v2/server/unshelve_291.rs +++ b/sdk/compute/src/v2/server/unshelve_291.rs @@ -136,7 +136,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server/virtual_interface.rs b/sdk/compute/src/v2/server/virtual_interface.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/virtual_interface.rs rename to sdk/compute/src/v2/server/virtual_interface.rs diff --git a/sdk/compute/src/v2/server/virtual_interface/get.rs b/sdk/compute/src/v2/server/virtual_interface/get.rs new file mode 100644 index 000000000..b5ffdcd9a --- /dev/null +++ b/sdk/compute/src/v2/server/virtual_interface/get.rs @@ -0,0 +1,184 @@ +// +// 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 + +//! Lists the virtual interfaces for an instance. +//! +//! Policy defaults enable only users with the administrative role or the owner +//! of +//! the server to perform this operation. Change these permissions through the +//! `policy.json` file. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), gone(410) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; +use serde::Serialize; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// server_id parameter for /v2.1/servers/{server_id}/topology API + #[builder(default, setter(into))] + server_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 Virtual_Interface. + 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!( + "v2.1/servers/{server_id}/os-virtual-interfaces", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::api::{self, Query, RawQuery}; + use openstack_sdk_core::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde::Deserialize; + use serde::Serialize; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/v2.1/servers/{server_id}/os-virtual-interfaces", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/v2.1/servers/{server_id}/os-virtual-interfaces", + server_id = "server_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() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .iter() + .cloned(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment.rs b/sdk/compute/src/v2/server/volume_attachment.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server/volume_attachment.rs rename to sdk/compute/src/v2/server/volume_attachment.rs diff --git a/sdk/compute/src/v2/server/volume_attachment/create_20.rs b/sdk/compute/src/v2/server/volume_attachment/create_20.rs new file mode 100644 index 000000000..858fa9344 --- /dev/null +++ b/sdk/compute/src/v2/server/volume_attachment/create_20.rs @@ -0,0 +1,273 @@ +// 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`. + +//! Attach a volume to an instance. +//! +//! Normal response codes: 200 (microversions 2.0 - 2.100), 202 (microversion +//! 2.101 - ) +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A dictionary representation of a volume attachment containing the fields +/// `device` and `volumeId`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct VolumeAttachment<'a> { + /// Name of the device such as, `/dev/vdb`. Omit or set this parameter to + /// null for auto-assignment, if supported. If you specify this parameter, + /// the device must not exist in the guest operating system. Note that as + /// of the 12.0.0 Liberty release, the Nova libvirt driver no longer honors + /// a user-supplied device name. This is the same behavior as if the device + /// name parameter is not supplied on the request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device: Option>>, + + /// The UUID of the volume to attach. + #[serde(rename = "volumeId")] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary representation of a volume attachment containing the + /// fields `device` and `volumeId`. + #[builder(setter(into))] + pub(crate) volume_attachment: VolumeAttachment<'a>, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API + #[builder(default, setter(into))] + server_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 Volume_Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "servers/{server_id}/os-volume_attachments", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "volumeAttachment", + serde_json::to_value(&self.volume_attachment)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("volumeAttachment".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "volumeAttachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/servers/{server_id}/os-volume_attachments", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/servers/{server_id}/os-volume_attachments", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/volume_attachment/create_249.rs b/sdk/compute/src/v2/server/volume_attachment/create_249.rs new file mode 100644 index 000000000..0794aa0f7 --- /dev/null +++ b/sdk/compute/src/v2/server/volume_attachment/create_249.rs @@ -0,0 +1,288 @@ +// 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`. + +//! Attach a volume to an instance. +//! +//! Normal response codes: 200 (microversions 2.0 - 2.100), 202 (microversion +//! 2.101 - ) +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A dictionary representation of a volume attachment containing the fields +/// `device` and `volumeId`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct VolumeAttachment<'a> { + /// Name of the device such as, `/dev/vdb`. Omit or set this parameter to + /// null for auto-assignment, if supported. If you specify this parameter, + /// the device must not exist in the guest operating system. Note that as + /// of the 12.0.0 Liberty release, the Nova libvirt driver no longer honors + /// a user-supplied device name. This is the same behavior as if the device + /// name parameter is not supplied on the request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device: Option>>, + + /// A device role tag that can be applied to a volume when attaching it to + /// the VM. The guest OS of a server that has devices tagged in this manner + /// can access hardware metadata about the tagged devices from the metadata + /// API and on the config drive, if enabled. + /// + /// Note + /// + /// Tagged volume attachment is not supported for shelved-offloaded + /// instances. + /// + /// **New in version 2.49** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tag: Option>, + + /// The UUID of the volume to attach. + #[serde(rename = "volumeId")] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary representation of a volume attachment containing the + /// fields `device` and `volumeId`. + #[builder(setter(into))] + pub(crate) volume_attachment: VolumeAttachment<'a>, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API + #[builder(default, setter(into))] + server_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 Volume_Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "servers/{server_id}/os-volume_attachments", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "volumeAttachment", + serde_json::to_value(&self.volume_attachment)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("volumeAttachment".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(2, 49)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "volumeAttachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/servers/{server_id}/os-volume_attachments", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/servers/{server_id}/os-volume_attachments", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_279.rs b/sdk/compute/src/v2/server/volume_attachment/create_279.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/volume_attachment/create_279.rs rename to sdk/compute/src/v2/server/volume_attachment/create_279.rs index 3ce0db90a..43e3e25f0 100644 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/create_279.rs +++ b/sdk/compute/src/v2/server/volume_attachment/create_279.rs @@ -184,7 +184,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server/volume_attachment/delete.rs b/sdk/compute/src/v2/server/volume_attachment/delete.rs new file mode 100644 index 000000000..75f08ef29 --- /dev/null +++ b/sdk/compute/src/v2/server/volume_attachment/delete.rs @@ -0,0 +1,209 @@ +// 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`. + +//! Detach a volume from an instance. +//! +//! Normal response codes: 202 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/os-volume_attachments/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API + #[builder(default, setter(into))] + server_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 Volume_Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-volume_attachments/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/servers/{server_id}/os-volume_attachments/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/servers/{server_id}/os-volume_attachments/{id}", + id = "id", + server_id = "server_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") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/volume_attachment/find.rs b/sdk/compute/src/v2/server/volume_attachment/find.rs new file mode 100644 index 000000000..8fdf1e736 --- /dev/null +++ b/sdk/compute/src/v2/server/volume_attachment/find.rs @@ -0,0 +1,118 @@ +// 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 tracing::trace; + +use crate::api::find::Findable; +use crate::api::rest_endpoint_prelude::*; + +use crate::api::{ApiError, RestClient}; + +use crate::v2::server::volume_attachment::{get as Get, list as List}; + +/// Find for server/volume_attachment by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[builder(default, setter(into))] + server_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 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<'a>; + fn get_ep(&self) -> Get::Request<'a> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.server_id(self.server_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<'a> { + let mut ep = List::Request::builder(); + ep.server_id(self.server_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().unwrap() + } + /// Locate server/volume_attachment in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // server/volume_attachment 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/sdk/compute/src/v2/server/volume_attachment/get.rs b/sdk/compute/src/v2/server/volume_attachment/get.rs new file mode 100644 index 000000000..d4c2c3837 --- /dev/null +++ b/sdk/compute/src/v2/server/volume_attachment/get.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`. + +//! Show a detail of a volume attachment. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/servers/{server_id}/os-volume_attachments/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API + #[builder(default, setter(into))] + server_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 Volume_Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-volume_attachments/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("volumeAttachment".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volumeAttachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-volume_attachments/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-volume_attachments/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/volume_attachment/list.rs b/sdk/compute/src/v2/server/volume_attachment/list.rs new file mode 100644 index 000000000..e38432a02 --- /dev/null +++ b/sdk/compute/src/v2/server/volume_attachment/list.rs @@ -0,0 +1,210 @@ +// 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 volume attachments for an instance. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default)] + limit: Option, + + #[builder(default)] + offset: Option, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API + #[builder(default, setter(into))] + server_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 Volume_Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "servers/{server_id}/os-volume_attachments", + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("offset", self.offset); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("volumeAttachments".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "volumeAttachments" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/servers/{server_id}/os-volume_attachments", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachments": {} })); + }); + + let endpoint = Request::builder().server_id("server_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/servers/{server_id}/os-volume_attachments", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachments": {} })); + }); + + let endpoint = Request::builder() + .server_id("server_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server/volume_attachment/set_20.rs b/sdk/compute/src/v2/server/volume_attachment/set_20.rs new file mode 100644 index 000000000..871d1df81 --- /dev/null +++ b/sdk/compute/src/v2/server/volume_attachment/set_20.rs @@ -0,0 +1,279 @@ +// 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 a volume attachment. +//! +//! Policy default role is ‘rule:admin_or_owner’, its scope is [project], which +//! allow project members or admins to change the fields of an attached volume +//! of a server. Cloud providers can change these permissions through the +//! `policy.yaml` file. +//! +//! Normal response codes: 202 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A dictionary representation of a volume attachment containing the field +/// `volumeId` which is the UUID of the replacement volume, and other fields to +/// update in the attachment. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct VolumeAttachment<'a> { + /// The UUID of the attached volume. + #[serde(rename = "volumeId")] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary representation of a volume attachment containing the field + /// `volumeId` which is the UUID of the replacement volume, and other + /// fields to update in the attachment. + #[builder(setter(into))] + pub(crate) volume_attachment: VolumeAttachment<'a>, + + /// id parameter for /v2.1/servers/{server_id}/os-volume_attachments/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// server_id parameter for + /// /v2.1/servers/{server_id}/os-volume_attachments/{id} API + #[builder(default, setter(into))] + server_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 Volume_Attachment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "servers/{server_id}/os-volume_attachments/{id}", + id = self.id.as_ref(), + server_id = self.server_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "volumeAttachment", + serde_json::to_value(&self.volume_attachment)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("volumeAttachment".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "volumeAttachment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/servers/{server_id}/os-volume_attachments/{id}", + id = "id", + server_id = "server_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/servers/{server_id}/os-volume_attachments/{id}", + id = "id", + server_id = "server_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "volumeAttachment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .server_id("server_id") + .volume_attachment( + VolumeAttachmentBuilder::default() + .volume_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server/volume_attachment/set_285.rs b/sdk/compute/src/v2/server/volume_attachment/set_285.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server/volume_attachment/set_285.rs rename to sdk/compute/src/v2/server/volume_attachment/set_285.rs index 867fc45d9..467c4d58e 100644 --- a/openstack_sdk/src/api/compute/v2/server/volume_attachment/set_285.rs +++ b/sdk/compute/src/v2/server/volume_attachment/set_285.rs @@ -199,7 +199,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server_external_event.rs b/sdk/compute/src/v2/server_external_event.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server_external_event.rs rename to sdk/compute/src/v2/server_external_event.rs diff --git a/sdk/compute/src/v2/server_external_event/create_20.rs b/sdk/compute/src/v2/server_external_event/create_20.rs new file mode 100644 index 000000000..08a7ea3b8 --- /dev/null +++ b/sdk/compute/src/v2/server_external_event/create_20.rs @@ -0,0 +1,299 @@ +// 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`. + +//! Creates one or more external events, which the API dispatches to the host a +//! server is assigned to. If the server is not currently assigned to a host +//! the event will not be delivered. +//! +//! You will receive back the list of events that you submitted, with an +//! updated `code` and `status` indicating their level of success. +//! +//! Normal response codes: 200, 207 +//! +//! A 200 will be returned if all events succeeded, 207 will be returned if any +//! events could not be processed. The `code` attribute for the event will +//! explain further what went wrong. +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Name { + #[serde(rename = "network-changed")] + NetworkChanged, + #[serde(rename = "network-vif-deleted")] + NetworkVifDeleted, + #[serde(rename = "network-vif-plugged")] + NetworkVifPlugged, + #[serde(rename = "network-vif-unplugged")] + NetworkVifUnplugged, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Status { + #[serde(rename = "completed")] + Completed, + #[serde(rename = "failed")] + Failed, + #[serde(rename = "in-progress")] + InProgress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Events<'a> { + /// The event name. A valid value is: + /// + /// - `network-changed` + /// - `network-vif-plugged` + /// - `network-vif-unplugged` + /// - `network-vif-deleted` + /// - `volume-extended` (since microversion `2.51`) + /// - `power-update` (since microversion `2.76`) + /// - `accelerator-request-bound` (since microversion `2.82`) + /// - `volume-reimaged` (since microversion `2.93`) + #[serde()] + #[builder()] + pub(crate) name: Name, + + /// The UUID of the server instance to which the API dispatches the event. + /// You must assign this instance to a host. Otherwise, this call does not + /// dispatch the event to the instance. + #[serde()] + #[builder(setter(into))] + pub(crate) server_uuid: Cow<'a, str>, + + /// The event status. A valid value is `failed`, `completed`, or + /// `in-progress`. Default is `completed`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) status: Option, + + /// A string value that identifies the event. Certain types of events + /// require specific tags: + /// + /// - For the `accelerator-request-bound` event, the tag must be the + /// accelerator request UUID. + /// - For the `power-update` event the tag must be either be `POWER_ON` or + /// `POWER_OFF`. + /// - For the `volume-extended` event the tag must be the volume id. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tag: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// List of external events to process. + #[builder(setter(into))] + pub(crate) events: Vec>, + + #[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 Server_External_Event. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-server-external-events".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("events", serde_json::to_value(&self.events)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .events(Vec::from([EventsBuilder::default() + .name(Name::NetworkChanged) + .server_uuid("foo") + .build() + .unwrap()])) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .events(Vec::from([EventsBuilder::default() + .name(Name::NetworkChanged) + .server_uuid("foo") + .build() + .unwrap()])) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-server-external-events".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .events(Vec::from([EventsBuilder::default() + .name(Name::NetworkChanged) + .server_uuid("foo") + .build() + .unwrap()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-server-external-events".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() + .events(Vec::from([EventsBuilder::default() + .name(Name::NetworkChanged) + .server_uuid("foo") + .build() + .unwrap()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server_external_event/create_251.rs b/sdk/compute/src/v2/server_external_event/create_251.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server_external_event/create_251.rs rename to sdk/compute/src/v2/server_external_event/create_251.rs index f2c7c8266..6be099652 100644 --- a/openstack_sdk/src/api/compute/v2/server_external_event/create_251.rs +++ b/sdk/compute/src/v2/server_external_event/create_251.rs @@ -201,7 +201,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server_external_event/create_276.rs b/sdk/compute/src/v2/server_external_event/create_276.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server_external_event/create_276.rs rename to sdk/compute/src/v2/server_external_event/create_276.rs index 806dd67f4..0fbf7fc2e 100644 --- a/openstack_sdk/src/api/compute/v2/server_external_event/create_276.rs +++ b/sdk/compute/src/v2/server_external_event/create_276.rs @@ -203,7 +203,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server_external_event/create_282.rs b/sdk/compute/src/v2/server_external_event/create_282.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server_external_event/create_282.rs rename to sdk/compute/src/v2/server_external_event/create_282.rs index d588f724e..8b604a878 100644 --- a/openstack_sdk/src/api/compute/v2/server_external_event/create_282.rs +++ b/sdk/compute/src/v2/server_external_event/create_282.rs @@ -205,7 +205,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server_external_event/create_293.rs b/sdk/compute/src/v2/server_external_event/create_293.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server_external_event/create_293.rs rename to sdk/compute/src/v2/server_external_event/create_293.rs index cbc3b9690..c09342502 100644 --- a/openstack_sdk/src/api/compute/v2/server_external_event/create_293.rs +++ b/sdk/compute/src/v2/server_external_event/create_293.rs @@ -207,7 +207,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server_group.rs b/sdk/compute/src/v2/server_group.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/server_group.rs rename to sdk/compute/src/v2/server_group.rs diff --git a/sdk/compute/src/v2/server_group/create_20.rs b/sdk/compute/src/v2/server_group/create_20.rs new file mode 100644 index 000000000..7f277892c --- /dev/null +++ b/sdk/compute/src/v2/server_group/create_20.rs @@ -0,0 +1,274 @@ +// 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`. + +//! Creates a server group. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Policies { + #[serde(rename = "affinity")] + Affinity, + #[serde(rename = "anti-affinity")] + AntiAffinity, +} + +/// The server group object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ServerGroup<'a> { + /// The name of the server group. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// A list of exactly one policy name to associate with the server group. + /// The current valid policy names are: + /// + /// - `anti-affinity` - servers in this group must be scheduled to + /// different hosts. + /// - `affinity` - servers in this group must be scheduled to the same + /// host. + /// - `soft-anti-affinity` - servers in this group should be scheduled to + /// different hosts if possible, but if not possible then they should + /// still be scheduled instead of resulting in a build failure. This + /// policy was added in microversion 2.15. + /// - `soft-affinity` - servers in this group should be scheduled to the + /// same host if possible, but if not possible then they should still be + /// scheduled instead of resulting in a build failure. This policy was + /// added in microversion 2.15. + /// + /// **Available until version 2.63** + #[serde()] + #[builder(setter(into))] + pub(crate) policies: Vec, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The server group object. + #[builder(setter(into))] + pub(crate) server_group: ServerGroup<'a>, + + #[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 Server_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-server-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("server_group", serde_json::to_value(&self.server_group)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .server_group( + ServerGroupBuilder::default() + .name("foo") + .policies(Vec::from([Policies::Affinity])) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .server_group( + ServerGroupBuilder::default() + .name("foo") + .policies(Vec::from([Policies::Affinity])) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "server_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-server-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server_group": {} })); + }); + + let endpoint = Request::builder() + .server_group( + ServerGroupBuilder::default() + .name("foo") + .policies(Vec::from([Policies::Affinity])) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/os-server-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server_group": {} })); + }); + + let endpoint = Request::builder() + .server_group( + ServerGroupBuilder::default() + .name("foo") + .policies(Vec::from([Policies::Affinity])) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/server_group/create_215.rs b/sdk/compute/src/v2/server_group/create_215.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server_group/create_215.rs rename to sdk/compute/src/v2/server_group/create_215.rs index 48d4eb79e..e005a499b 100644 --- a/openstack_sdk/src/api/compute/v2/server_group/create_215.rs +++ b/sdk/compute/src/v2/server_group/create_215.rs @@ -169,7 +169,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/server_group/create_264.rs b/sdk/compute/src/v2/server_group/create_264.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/server_group/create_264.rs rename to sdk/compute/src/v2/server_group/create_264.rs index 2d06dcb8e..de51e3167 100644 --- a/openstack_sdk/src/api/compute/v2/server_group/create_264.rs +++ b/sdk/compute/src/v2/server_group/create_264.rs @@ -197,7 +197,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/compute/src/v2/server_group/delete.rs b/sdk/compute/src/v2/server_group/delete.rs new file mode 100644 index 000000000..513e44323 --- /dev/null +++ b/sdk/compute/src/v2/server_group/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a server group. +//! +//! Normal response codes: 204 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-server-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Server_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-server-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-server-groups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-server-groups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server_group/find.rs b/sdk/compute/src/v2/server_group/find.rs new file mode 100644 index 000000000..dd9c0edbe --- /dev/null +++ b/sdk/compute/src/v2/server_group/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::server_group::{get as Get, list as List}; + +/// Find for server_group 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate server_group in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // server_group 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/compute/src/v2/server_group/get.rs b/sdk/compute/src/v2/server_group/get.rs new file mode 100644 index 000000000..832feb174 --- /dev/null +++ b/sdk/compute/src/v2/server_group/get.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Shows details for a server group. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403), itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-server-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Server_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-server-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server_group".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "server_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-server-groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server_group": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-server-groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/server_group/list.rs b/sdk/compute/src/v2/server_group/list.rs new file mode 100644 index 000000000..9c3033b97 --- /dev/null +++ b/sdk/compute/src/v2/server_group/list.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Lists all server groups for the tenant. +//! +//! Administrative users can use the `all_projects` query parameter to list all +//! server groups for all projects. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + all_projects: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default)] + offset: 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> { + /// Add a single header to the Server_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-server-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("all_projects", self.all_projects.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("offset", self.offset); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("server_groups".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(2, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "server_groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-server-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server_groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-server-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "server_groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/service.rs b/sdk/compute/src/v2/service.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/service.rs rename to sdk/compute/src/v2/service.rs diff --git a/sdk/compute/src/v2/service/delete.rs b/sdk/compute/src/v2/service/delete.rs new file mode 100644 index 000000000..f5c87cde9 --- /dev/null +++ b/sdk/compute/src/v2/service/delete.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`. + +//! Deletes a service. If it’s a `nova-compute` service, then the corresponding +//! host will be removed from all the host aggregates as well. +//! +//! Attempts to delete a `nova-compute` service which is still hosting +//! instances will result in a 409 HTTPConflict response. The instances will +//! need to be migrated or deleted before a compute service can be deleted. +//! +//! Similarly, attempts to delete a `nova-compute` service which is involved in +//! in-progress migrations will result in a 409 HTTPConflict response. The +//! migrations will need to be completed, for example confirming or reverting a +//! resize, or the instances will need to be deleted before the compute service +//! can be deleted. +//! +//! Normal response codes: 204 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/os-services/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-services/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-services/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-services/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/service/list.rs b/sdk/compute/src/v2/service/list.rs new file mode 100644 index 000000000..d22893458 --- /dev/null +++ b/sdk/compute/src/v2/service/list.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Lists all running Compute services. +//! +//! Provides details why any services were disabled. +//! +//! Normal response codes: 200 +//! +//! Error response codes: unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + binary: Option>, + + #[builder(default, setter(into))] + host: 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> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-services".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("binary", self.binary.as_ref()); + params.push_opt("host", self.host.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("services".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "services" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-services".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "services": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-services".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "services": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/service/set_20.rs b/sdk/compute/src/v2/service/set_20.rs new file mode 100644 index 000000000..367851a66 --- /dev/null +++ b/sdk/compute/src/v2/service/set_20.rs @@ -0,0 +1,236 @@ +// 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 a compute service to enable or disable scheduling, including +//! recording a reason why a compute service was disabled from scheduling. Set +//! or unset the `forced_down` flag for the service. This operation is only +//! allowed on services whose `binary` is `nova-compute`. +//! +//! This API is available starting with microversion 2.53. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403), +//! itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) binary: Cow<'a, str>, + + /// The reason for disabling a service. The minimum length is 1 and the + /// maximum length is 255. This may only be requested with + /// `status=disabled`. + #[builder(default, setter(into))] + pub(crate) disabled_reason: Option>, + + #[builder(setter(into))] + pub(crate) host: Cow<'a, str>, + + /// id parameter for /v2.1/os-services/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-services/{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("binary", serde_json::to_value(&self.binary)?); + if let Some(val) = &self.disabled_reason { + params.push("disabled_reason", serde_json::to_value(val)?); + } + params.push("host", serde_json::to_value(&self.host)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("service".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .binary("foo") + .host("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .binary("foo") + .host("foo") + .build() + .unwrap() + .response_key() + .unwrap(), + "service" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-services/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .binary("foo") + .host("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-services/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .binary("foo") + .host("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/service/set_211.rs b/sdk/compute/src/v2/service/set_211.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/service/set_211.rs rename to sdk/compute/src/v2/service/set_211.rs index 60c7d64d0..a9d6e4d0e 100644 --- a/openstack_sdk/src/api/compute/v2/service/set_211.rs +++ b/sdk/compute/src/v2/service/set_211.rs @@ -161,7 +161,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/service/set_253.rs b/sdk/compute/src/v2/service/set_253.rs similarity index 99% rename from openstack_sdk/src/api/compute/v2/service/set_253.rs rename to sdk/compute/src/v2/service/set_253.rs index 7e0198a2e..f140702bb 100644 --- a/openstack_sdk/src/api/compute/v2/service/set_253.rs +++ b/sdk/compute/src/v2/service/set_253.rs @@ -170,7 +170,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/compute/v2/simple_tenant_usage.rs b/sdk/compute/src/v2/simple_tenant_usage.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/simple_tenant_usage.rs rename to sdk/compute/src/v2/simple_tenant_usage.rs diff --git a/sdk/compute/src/v2/simple_tenant_usage/get.rs b/sdk/compute/src/v2/simple_tenant_usage/get.rs new file mode 100644 index 000000000..b9561292a --- /dev/null +++ b/sdk/compute/src/v2/simple_tenant_usage/get.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Shows usage statistics for a tenant. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + end: Option>, + + /// id parameter for /v2.1/os-simple-tenant-usage/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + start: 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> { + /// Add a single header to the Simple_Tenant_Usage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("os-simple-tenant-usage/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("end", self.end.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("start", self.start.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-simple-tenant-usage/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-simple-tenant-usage/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/compute/src/v2/simple_tenant_usage/list.rs b/sdk/compute/src/v2/simple_tenant_usage/list.rs new file mode 100644 index 000000000..15540f0d3 --- /dev/null +++ b/sdk/compute/src/v2/simple_tenant_usage/list.rs @@ -0,0 +1,204 @@ +// 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`. + +//! Lists usage statistics for all tenants. +//! +//! Normal response codes: 200 +//! +//! Error response codes: badRequest(400), unauthorized(401), forbidden(403) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + detailed: Option>, + + #[builder(default, setter(into))] + end: Option>, + + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + start: 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> { + /// Add a single header to the Simple_Tenant_Usage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "os-simple-tenant-usage".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("detailed", self.detailed.as_ref()); + params.push_opt("end", self.end.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("start", self.start.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + 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, 1)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-simple-tenant-usage".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-simple-tenant-usage".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/compute/v2/version.rs b/sdk/compute/src/v2/version.rs similarity index 100% rename from openstack_sdk/src/api/compute/v2/version.rs rename to sdk/compute/src/v2/version.rs diff --git a/sdk/compute/src/v2/version/get.rs b/sdk/compute/src/v2/version/get.rs new file mode 100644 index 000000000..83bb8c63d --- /dev/null +++ b/sdk/compute/src/v2/version/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.1/versions/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Version. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("versions/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Compute + } + + fn response_key(&self) -> Option> { + Some("version".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(2, 1)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Compute + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "version" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/versions/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "version": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/versions/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "version": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/Cargo.toml b/sdk/container-infrastructure-management/Cargo.toml new file mode 100644 index 000000000..ddf17b88c --- /dev/null +++ b/sdk/container-infrastructure-management/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "openstack-sdk-container-infrastructure-management" +description = "OpenStack SDK Container Infrastructure Management service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/container-infrastructure-management/src/lib.rs b/sdk/container-infrastructure-management/src/lib.rs new file mode 100644 index 000000000..fc5b910bb --- /dev/null +++ b/sdk/container-infrastructure-management/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Container_infrastructure_management` Service bindings +pub mod v1; diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1.rs b/sdk/container-infrastructure-management/src/v1.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1.rs rename to sdk/container-infrastructure-management/src/v1.rs diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/certificate.rs b/sdk/container-infrastructure-management/src/v1/certificate.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/certificate.rs rename to sdk/container-infrastructure-management/src/v1/certificate.rs diff --git a/sdk/container-infrastructure-management/src/v1/certificate/create.rs b/sdk/container-infrastructure-management/src/v1/certificate/create.rs new file mode 100644 index 000000000..f8675924b --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/certificate/create.rs @@ -0,0 +1,255 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Certificate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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.ca_cert_type { + params.push("ca_cert_type", serde_json::to_value(val)?); + } + if let Some(val) = &self.cluster_uuid { + params.push("cluster_uuid", 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.csr { + params.push("csr", serde_json::to_value(val)?); + } + if let Some(val) = &self.links { + params.push("links", serde_json::to_value(val)?); + } + if let Some(val) = &self.pem { + params.push("pem", 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/certificate/get.rs b/sdk/container-infrastructure-management/src/v1/certificate/get.rs new file mode 100644 index 000000000..db894c1c2 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/certificate/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Certificate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/cluster.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/cluster.rs rename to sdk/container-infrastructure-management/src/v1/cluster.rs diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action.rs b/sdk/container-infrastructure-management/src/v1/cluster/action.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action.rs rename to sdk/container-infrastructure-management/src/v1/cluster/action.rs diff --git a/openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize.rs b/sdk/container-infrastructure-management/src/v1/cluster/action/resize.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/resize.rs rename to sdk/container-infrastructure-management/src/v1/cluster/action/resize.rs diff --git a/sdk/container-infrastructure-management/src/v1/cluster/action/resize/create.rs b/sdk/container-infrastructure-management/src/v1/cluster/action/resize/create.rs new file mode 100644 index 000000000..174316322 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/action/resize/create.rs @@ -0,0 +1,221 @@ +// 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 openstack_sdk_core::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(setter(into))] + 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<'a> RequestBuilder<'a> { + /// Add a single header to the Resize. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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(); + + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + params.push("node_count", serde_json::to_value(self.node_count)?); + if let Some(val) = &self.nodegroup { + params.push("nodegroup", serde_json::to_value(val)?); + } + if let Some(val) = &self.nodes_to_remove { + params.push("nodes_to_remove", 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/cluster/action/upgrade.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/cluster/action/upgrade.rs rename to sdk/container-infrastructure-management/src/v1/cluster/action/upgrade.rs diff --git a/sdk/container-infrastructure-management/src/v1/cluster/action/upgrade/create.rs b/sdk/container-infrastructure-management/src/v1/cluster/action/upgrade/create.rs new file mode 100644 index 000000000..630561a1a --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/action/upgrade/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 openstack_sdk_core::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, setter(into))] + 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<'a> RequestBuilder<'a> { + /// Add a single header to the Upgrade. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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.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.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.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/create.rs b/sdk/container-infrastructure-management/src/v1/cluster/create.rs new file mode 100644 index 000000000..b84b70fdb --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/create.rs @@ -0,0 +1,659 @@ +// 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 openstack_sdk_core::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 HealthStatus { + #[serde(rename = "HEALTHY")] + Healthy, + #[serde(rename = "UNHEALTHY")] + Unhealthy, + #[serde(rename = "UNKNOWN")] + Unknown, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum Labels<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LabelsAdded<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LabelsOverridden<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LabelsSkipped<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +/// 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) 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, setter(into))] + 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, setter(into))] + pub(crate) docker_volume_size: Option, + + #[builder(default, private, setter(into, 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(into, 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(into, name = "_labels"))] + pub(crate) labels: Option, Labels<'a>>>, + + #[builder(default, private, setter(into, name = "_labels_added"))] + pub(crate) labels_added: Option, LabelsAdded<'a>>>, + + #[builder(default, private, setter(into, name = "_labels_overridden"))] + pub(crate) labels_overridden: Option, LabelsOverridden<'a>>>, + + #[builder(default, private, setter(into, name = "_labels_skipped"))] + pub(crate) labels_skipped: Option, LabelsSkipped<'a>>>, + + #[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, setter(into))] + 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, setter(into))] + 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> { + 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 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 + } + + /// 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 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_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_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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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.api_address { + params.push("api_address", serde_json::to_value(val)?); + } + params.push( + "cluster_template_id", + serde_json::to_value(&self.cluster_template_id)?, + ); + 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.create_timeout { + params.push("create_timeout", 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.discovery_url { + params.push("discovery_url", 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.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.flavor_id { + params.push("flavor_id", 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.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.keypair { + params.push("keypair", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels { + params.push("labels", 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_overridden { + params.push("labels_overridden", 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.links { + params.push("links", 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.master_count { + params.push("master_count", 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.master_lb_enabled { + params.push("master_lb_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.name { + params.push("name", 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.project_id { + params.push("project_id", 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.updated_at { + params.push("updated_at", 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.uuid { + params.push("uuid", 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/delete.rs b/sdk/container-infrastructure-management/src/v1/cluster/delete.rs new file mode 100644 index 000000000..c12132f41 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/delete.rs @@ -0,0 +1,181 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/get.rs b/sdk/container-infrastructure-management/src/v1/cluster/get.rs new file mode 100644 index 000000000..c9d3bbfb9 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/get.rs @@ -0,0 +1,181 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/list.rs b/sdk/container-infrastructure-management/src/v1/cluster/list.rs new file mode 100644 index 000000000..1c8e1e98b --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/list.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`. + +//! List all clusters in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/cluster/nodegroup.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/cluster/nodegroup.rs rename to sdk/container-infrastructure-management/src/v1/cluster/nodegroup.rs diff --git a/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/create.rs b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/create.rs new file mode 100644 index 000000000..eac08bc84 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/create.rs @@ -0,0 +1,498 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum Labels<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LabelsAdded<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LabelsOverridden<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LabelsSkipped<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +/// 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, setter(into))] + pub(crate) docker_volume_size: Option, + + #[builder(default, setter(into))] + pub(crate) flavor_id: Option>, + + #[builder(default, setter(into))] + 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(into, name = "_labels"))] + pub(crate) labels: Option, Labels<'a>>>, + + #[builder(default, private, setter(into, name = "_labels_added"))] + pub(crate) labels_added: Option, LabelsAdded<'a>>>, + + #[builder(default, private, setter(into, name = "_labels_overridden"))] + pub(crate) labels_overridden: Option, LabelsOverridden<'a>>>, + + #[builder(default, private, setter(into, name = "_labels_skipped"))] + pub(crate) labels_skipped: Option, LabelsSkipped<'a>>>, + + #[builder(default, setter(into))] + pub(crate) links: Option>>, + + #[builder(default, setter(into))] + pub(crate) max_node_count: Option, + + #[builder(default, setter(into))] + pub(crate) merge_labels: Option>, + + #[builder(default, setter(into))] + 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, setter(into))] + 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_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_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_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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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.cluster_id { + params.push("cluster_id", 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.docker_volume_size { + params.push("docker_volume_size", 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.id { + params.push("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.is_default { + params.push("is_default", serde_json::to_value(val)?); + } + if let Some(val) = &self.labels { + params.push("labels", 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_overridden { + params.push("labels_overridden", 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.links { + params.push("links", 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.merge_labels { + params.push("merge_labels", 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.name { + params.push("name", 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.project_id { + params.push("project_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.role { + params.push("role", 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.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.uuid { + params.push("uuid", serde_json::to_value(val)?); + } + if let Some(val) = &self.version { + params.push("version", 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/delete.rs b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/delete.rs new file mode 100644 index 000000000..c7c6a974e --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/delete.rs @@ -0,0 +1,184 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/delete_all.rs b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/delete_all.rs new file mode 100644 index 000000000..d4f2720e5 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/delete_all.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 openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/find.rs b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/find.rs new file mode 100644 index 000000000..968e6c374 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result> { + 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().map_err(ApiError::endpoint_builder) + } + /// 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/get.rs b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/get.rs new file mode 100644 index 000000000..3244abe59 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/get.rs @@ -0,0 +1,184 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/list.rs b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/list.rs new file mode 100644 index 000000000..2f441cf5f --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/list.rs @@ -0,0 +1,184 @@ +// 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/set.rs b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/set.rs new file mode 100644 index 000000000..1fa433ce1 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/nodegroup/set.rs @@ -0,0 +1,243 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Nodegroup. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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("op", serde_json::to_value(&self.op)?); + params.push("path", serde_json::to_value(&self.path)?); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .op(Op::Add) + .path("foo") + .build() + .unwrap() + .service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .op(Op::Add) + .path("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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") + .op(Op::Add) + .path("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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") + .op(Op::Add) + .path("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/cluster/set.rs b/sdk/container-infrastructure-management/src/v1/cluster/set.rs new file mode 100644 index 000000000..57c9876b1 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/cluster/set.rs @@ -0,0 +1,241 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Cluster. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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("op", serde_json::to_value(&self.op)?); + params.push("path", serde_json::to_value(&self.path)?); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .op(Op::Add) + .path("foo") + .build() + .unwrap() + .service_type(), + ServiceType::ContainerInfrastructureManagement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .op(Op::Add) + .path("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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") + .op(Op::Add) + .path("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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") + .op(Op::Add) + .path("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/clustertemplate.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/clustertemplate.rs rename to sdk/container-infrastructure-management/src/v1/clustertemplate.rs diff --git a/sdk/container-infrastructure-management/src/v1/clustertemplate/create.rs b/sdk/container-infrastructure-management/src/v1/clustertemplate/create.rs new file mode 100644 index 000000000..302a8fae8 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/clustertemplate/create.rs @@ -0,0 +1,570 @@ +// 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 openstack_sdk_core::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, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum Labels<'a> { + F1(bool), + F2(i32), + F3(Cow<'a, str>), +} + +/// 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, setter(into))] + 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, setter(into))] + 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>, + + /// The URL pointing to users’s own private insecure docker registry to + /// deploy and run docker containers. + #[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(into, name = "_labels"))] + pub(crate) labels: Option, Labels<'a>>>, + + #[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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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.apiserver_port { + params.push("apiserver_port", 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.coe { + params.push("coe", 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.dns_nameserver { + params.push("dns_nameserver", 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.docker_volume_size { + params.push("docker_volume_size", serde_json::to_value(val)?); + } + if let Some(val) = &self.driver { + params.push("driver", 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.flavor_id { + params.push("flavor_id", 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.hidden { + params.push("hidden", 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)?); + } + params.push("image_id", serde_json::to_value(&self.image_id)?); + if let Some(val) = &self.insecure_registry { + params.push("insecure_registry", 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.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.master_flavor_id { + params.push("master_flavor_id", 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.name { + params.push("name", 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.no_proxy { + params.push("no_proxy", 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.public { + params.push("public", 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.server_type { + params.push("server_type", serde_json::to_value(val)?); + } + if let Some(val) = &self.tags { + params.push("tags", 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.updated_at { + params.push("updated_at", 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.uuid { + params.push("uuid", serde_json::to_value(val)?); + } + if let Some(val) = &self.volume_driver { + params.push("volume_driver", 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/clustertemplate/delete.rs b/sdk/container-infrastructure-management/src/v1/clustertemplate/delete.rs new file mode 100644 index 000000000..d6405cd99 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/clustertemplate/delete.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Clustertemplate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/clustertemplate/get.rs b/sdk/container-infrastructure-management/src/v1/clustertemplate/get.rs new file mode 100644 index 000000000..7fc3e7e41 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/clustertemplate/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Clustertemplate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/clustertemplate/list.rs b/sdk/container-infrastructure-management/src/v1/clustertemplate/list.rs new file mode 100644 index 000000000..a3662698f --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/clustertemplate/list.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`. + +//! List all available cluster templates in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/federation.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/federation.rs rename to sdk/container-infrastructure-management/src/v1/federation.rs diff --git a/sdk/container-infrastructure-management/src/v1/federation/create.rs b/sdk/container-infrastructure-management/src/v1/federation/create.rs new file mode 100644 index 000000000..ed44d3caf --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/federation/create.rs @@ -0,0 +1,309 @@ +// 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 openstack_sdk_core::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 = "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, +} + +#[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(into, 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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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.created_at { + params.push("created_at", 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.links { + params.push("links", 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.name { + params.push("name", serde_json::to_value(val)?); + } + if let Some(val) = &self.properties { + params.push("properties", 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.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.uuid { + params.push("uuid", 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/federation/delete.rs b/sdk/container-infrastructure-management/src/v1/federation/delete.rs new file mode 100644 index 000000000..80dc2ce38 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/federation/delete.rs @@ -0,0 +1,184 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Federation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/federation/get.rs b/sdk/container-infrastructure-management/src/v1/federation/get.rs new file mode 100644 index 000000000..5440b23b2 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/federation/get.rs @@ -0,0 +1,184 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Federation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/federation/list.rs b/sdk/container-infrastructure-management/src/v1/federation/list.rs new file mode 100644 index 000000000..6a270737e --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/federation/list.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/mservice.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/mservice.rs rename to sdk/container-infrastructure-management/src/v1/mservice.rs diff --git a/sdk/container-infrastructure-management/src/v1/mservice/list.rs b/sdk/container-infrastructure-management/src/v1/mservice/list.rs new file mode 100644 index 000000000..7167ce9a9 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/mservice/list.rs @@ -0,0 +1,181 @@ +// 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/quota.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/quota.rs rename to sdk/container-infrastructure-management/src/v1/quota.rs diff --git a/sdk/container-infrastructure-management/src/v1/quota/create.rs b/sdk/container-infrastructure-management/src/v1/quota/create.rs new file mode 100644 index 000000000..e9e0e3545 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/quota/create.rs @@ -0,0 +1,227 @@ +// 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 openstack_sdk_core::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, setter(into))] + pub(crate) hard_limit: Option, + + #[builder(default, setter(into))] + 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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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.created_at { + params.push("created_at", 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.id { + params.push("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.resource { + params.push("resource", 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/quota/delete.rs b/sdk/container-infrastructure-management/src/v1/quota/delete.rs new file mode 100644 index 000000000..5d71cc205 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/quota/delete.rs @@ -0,0 +1,184 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/quota/get.rs b/sdk/container-infrastructure-management/src/v1/quota/get.rs new file mode 100644 index 000000000..fbdfc5bea --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/quota/get.rs @@ -0,0 +1,184 @@ +// 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 openstack_sdk_core::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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/container-infrastructure-management/src/v1/quota/list.rs b/sdk/container-infrastructure-management/src/v1/quota/list.rs new file mode 100644 index 000000000..a39895b0e --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/quota/list.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`. + +//! List all quotas in Magnum. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/stat.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/stat.rs rename to sdk/container-infrastructure-management/src/v1/stat.rs diff --git a/sdk/container-infrastructure-management/src/v1/stat/get.rs b/sdk/container-infrastructure-management/src/v1/stat/get.rs new file mode 100644 index 000000000..1abd36866 --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/stat/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 overall Magnum system stats. If the requester is non-admin user show +//! self stats. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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/sdk/container-infrastructure-management/src/v1/version.rs similarity index 100% rename from openstack_sdk/src/api/container_infrastructure_management/v1/version.rs rename to sdk/container-infrastructure-management/src/v1/version.rs diff --git a/sdk/container-infrastructure-management/src/v1/version/get.rs b/sdk/container-infrastructure-management/src/v1/version/get.rs new file mode 100644 index 000000000..0c677074f --- /dev/null +++ b/sdk/container-infrastructure-management/src/v1/version/get.rs @@ -0,0 +1,171 @@ +// 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk-core/CHANGELOG.md b/sdk/core/CHANGELOG.md similarity index 100% rename from sdk-core/CHANGELOG.md rename to sdk/core/CHANGELOG.md diff --git a/sdk-core/Cargo.toml b/sdk/core/Cargo.toml similarity index 100% rename from sdk-core/Cargo.toml rename to sdk/core/Cargo.toml diff --git a/sdk-core/examples/ignore.rs b/sdk/core/examples/ignore.rs similarity index 100% rename from sdk-core/examples/ignore.rs rename to sdk/core/examples/ignore.rs diff --git a/sdk-core/examples/paged.rs b/sdk/core/examples/paged.rs similarity index 100% rename from sdk-core/examples/paged.rs rename to sdk/core/examples/paged.rs diff --git a/sdk-core/examples/query.rs b/sdk/core/examples/query.rs similarity index 100% rename from sdk-core/examples/query.rs rename to sdk/core/examples/query.rs diff --git a/sdk-core/src/api.rs b/sdk/core/src/api.rs similarity index 100% rename from sdk-core/src/api.rs rename to sdk/core/src/api.rs diff --git a/sdk-core/src/api/client.rs b/sdk/core/src/api/client.rs similarity index 100% rename from sdk-core/src/api/client.rs rename to sdk/core/src/api/client.rs diff --git a/sdk-core/src/api/common.rs b/sdk/core/src/api/common.rs similarity index 100% rename from sdk-core/src/api/common.rs rename to sdk/core/src/api/common.rs diff --git a/sdk-core/src/api/error.rs b/sdk/core/src/api/error.rs similarity index 100% rename from sdk-core/src/api/error.rs rename to sdk/core/src/api/error.rs diff --git a/sdk-core/src/api/find.rs b/sdk/core/src/api/find.rs similarity index 100% rename from sdk-core/src/api/find.rs rename to sdk/core/src/api/find.rs diff --git a/sdk-core/src/api/identity.rs b/sdk/core/src/api/identity.rs similarity index 100% rename from sdk-core/src/api/identity.rs rename to sdk/core/src/api/identity.rs diff --git a/sdk-core/src/api/ignore.rs b/sdk/core/src/api/ignore.rs similarity index 100% rename from sdk-core/src/api/ignore.rs rename to sdk/core/src/api/ignore.rs diff --git a/sdk-core/src/api/paged.rs b/sdk/core/src/api/paged.rs similarity index 100% rename from sdk-core/src/api/paged.rs rename to sdk/core/src/api/paged.rs diff --git a/sdk-core/src/api/paged/iter.rs b/sdk/core/src/api/paged/iter.rs similarity index 100% rename from sdk-core/src/api/paged/iter.rs rename to sdk/core/src/api/paged/iter.rs diff --git a/sdk-core/src/api/paged/next_page.rs b/sdk/core/src/api/paged/next_page.rs similarity index 100% rename from sdk-core/src/api/paged/next_page.rs rename to sdk/core/src/api/paged/next_page.rs diff --git a/sdk-core/src/api/paged/pagination.rs b/sdk/core/src/api/paged/pagination.rs similarity index 100% rename from sdk-core/src/api/paged/pagination.rs rename to sdk/core/src/api/paged/pagination.rs diff --git a/sdk-core/src/api/params.rs b/sdk/core/src/api/params.rs similarity index 100% rename from sdk-core/src/api/params.rs rename to sdk/core/src/api/params.rs diff --git a/sdk-core/src/api/query.rs b/sdk/core/src/api/query.rs similarity index 100% rename from sdk-core/src/api/query.rs rename to sdk/core/src/api/query.rs diff --git a/sdk-core/src/api/rest_endpoint.rs b/sdk/core/src/api/rest_endpoint.rs similarity index 100% rename from sdk-core/src/api/rest_endpoint.rs rename to sdk/core/src/api/rest_endpoint.rs diff --git a/sdk-core/src/api/rest_endpoint_prelude.rs b/sdk/core/src/api/rest_endpoint_prelude.rs similarity index 100% rename from sdk-core/src/api/rest_endpoint_prelude.rs rename to sdk/core/src/api/rest_endpoint_prelude.rs diff --git a/sdk-core/src/auth.rs b/sdk/core/src/auth.rs similarity index 100% rename from sdk-core/src/auth.rs rename to sdk/core/src/auth.rs diff --git a/sdk-core/src/auth/auth_helper.rs b/sdk/core/src/auth/auth_helper.rs similarity index 100% rename from sdk-core/src/auth/auth_helper.rs rename to sdk/core/src/auth/auth_helper.rs diff --git a/sdk-core/src/auth/authtoken_scope.rs b/sdk/core/src/auth/authtoken_scope.rs similarity index 100% rename from sdk-core/src/auth/authtoken_scope.rs rename to sdk/core/src/auth/authtoken_scope.rs diff --git a/sdk-core/src/catalog.rs b/sdk/core/src/catalog.rs similarity index 100% rename from sdk-core/src/catalog.rs rename to sdk/core/src/catalog.rs diff --git a/sdk-core/src/catalog/discovery.rs b/sdk/core/src/catalog/discovery.rs similarity index 100% rename from sdk-core/src/catalog/discovery.rs rename to sdk/core/src/catalog/discovery.rs diff --git a/sdk-core/src/catalog/error.rs b/sdk/core/src/catalog/error.rs similarity index 100% rename from sdk-core/src/catalog/error.rs rename to sdk/core/src/catalog/error.rs diff --git a/sdk-core/src/catalog/service_authority.rs b/sdk/core/src/catalog/service_authority.rs similarity index 100% rename from sdk-core/src/catalog/service_authority.rs rename to sdk/core/src/catalog/service_authority.rs diff --git a/sdk-core/src/catalog/service_endpoint.rs b/sdk/core/src/catalog/service_endpoint.rs similarity index 100% rename from sdk-core/src/catalog/service_endpoint.rs rename to sdk/core/src/catalog/service_endpoint.rs diff --git a/sdk-core/src/config.rs b/sdk/core/src/config.rs similarity index 100% rename from sdk-core/src/config.rs rename to sdk/core/src/config.rs diff --git a/sdk-core/src/error.rs b/sdk/core/src/error.rs similarity index 100% rename from sdk-core/src/error.rs rename to sdk/core/src/error.rs diff --git a/sdk/core/src/lib.rs b/sdk/core/src/lib.rs new file mode 100644 index 000000000..23b0f828b --- /dev/null +++ b/sdk/core/src/lib.rs @@ -0,0 +1,105 @@ +// 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 + +//! # OpenStack API bindings (SDK) - core +//! +//! `openstack_sdk_core` implements basic functionality used by the `openstack_sdk` +//! crate as the OpenStack SDK (interfaces, connection client, catalog, version +//! discovery, etc). This crate does not implement service bindings, and is +//! therefore not very useful alone. +//! +//! ## Features +//! +//! - Sync and Async interface +//! - `Query`, `Find` and `Pagination` interfaces implementing basic functionality +//! - `RawQuery` interface providing more control over the API invocation with +//! upload and download capabilities. +//! +//! # Using +//! +//! The simplest example demonstrating how to list compute flavors: +//! +//! ```rust +//! use openstack_sdk_core::api::{paged, Pagination, QueryAsync, Pageable, +//! RestEndpoint}; +//! use openstack_sdk_core::{config::ConfigFile, OpenStackError}; +//! use openstack_sdk_core::types::ServiceType; +//! use std::borrow::Cow; +//! +//! #[derive(derive_builder::Builder)] +//! #[builder(setter(strip_option))] +//! pub struct Request<'a> { +//! id: Cow<'a, str>, +//! #[builder(default, setter(into))] +//! min_disk: Option>, +//! } +//! +//! impl RestEndpoint for Request<'_> { +//! fn method(&self) -> http::Method { +//! http::Method::GET +//! } +//! +//! fn endpoint(&self) -> Cow<'static, str> { +//! "flavors".to_string().into() +//! } +//! +//! fn service_type(&self) -> ServiceType { +//! ServiceType::Compute +//! } +//! +//! fn response_key(&self) -> Option> { +//! Some("flavor".into()) +//! } +//! } +//! impl Pageable for Request<'_> {} +//! +//! async fn list_flavors() -> Result<(), OpenStackError> { +//! // Get the builder for the listing Flavors Endpoint +//! let mut ep_builder = RequestBuilder::default(); +//! // Set the `min_disk` query param +//! ep_builder.min_disk("15"); +//! let ep = ep_builder.build().unwrap(); +//! +//! let cfg = ConfigFile::new().unwrap(); +//! // Get connection config from clouds.yaml/secure.yaml +//! let _profile = cfg.get_cloud_config("devstack").unwrap().unwrap(); +//! // Establish connection +//! // let mut session = AsyncOpenStack::new(&profile).await?; +//! +//! // Invoke service discovery when desired. +//! // session.discover_service_endpoint(&ServiceType::Compute).await?; +//! +//! // Execute the call with pagination limiting maximum amount of entries to 1000 +//! // let data: Vec = paged(ep, Pagination::Limit(1000)) +//! // .query_async(&session) +//! // .await.unwrap(); +//! +//! // println!("Data = {:?}", data); +//! Ok(()) +//! } +//! ``` + +pub mod api; +pub mod auth; +pub mod catalog; +pub mod config; +pub mod error; +pub mod state; +pub mod types; +pub mod utils; + +pub use crate::error::{BuilderError, OpenStackError, RestError}; + +#[allow(dead_code)] +pub mod test; diff --git a/sdk-core/src/state.rs b/sdk/core/src/state.rs similarity index 100% rename from sdk-core/src/state.rs rename to sdk/core/src/state.rs diff --git a/sdk-core/src/test.rs b/sdk/core/src/test.rs similarity index 100% rename from sdk-core/src/test.rs rename to sdk/core/src/test.rs diff --git a/sdk-core/src/test/client.rs b/sdk/core/src/test/client.rs similarity index 100% rename from sdk-core/src/test/client.rs rename to sdk/core/src/test/client.rs diff --git a/sdk-core/src/test/internal.rs b/sdk/core/src/test/internal.rs similarity index 100% rename from sdk-core/src/test/internal.rs rename to sdk/core/src/test/internal.rs diff --git a/sdk-core/src/types.rs b/sdk/core/src/types.rs similarity index 100% rename from sdk-core/src/types.rs rename to sdk/core/src/types.rs diff --git a/sdk-core/src/types/api_version.rs b/sdk/core/src/types/api_version.rs similarity index 100% rename from sdk-core/src/types/api_version.rs rename to sdk/core/src/types/api_version.rs diff --git a/sdk-core/src/types/common.rs b/sdk/core/src/types/common.rs similarity index 100% rename from sdk-core/src/types/common.rs rename to sdk/core/src/types/common.rs diff --git a/sdk-core/src/types/identity.rs b/sdk/core/src/types/identity.rs similarity index 100% rename from sdk-core/src/types/identity.rs rename to sdk/core/src/types/identity.rs diff --git a/sdk-core/src/types/identity/v3.rs b/sdk/core/src/types/identity/v3.rs similarity index 100% rename from sdk-core/src/types/identity/v3.rs rename to sdk/core/src/types/identity/v3.rs diff --git a/sdk-core/src/types/identity/v3/version.rs b/sdk/core/src/types/identity/v3/version.rs similarity index 100% rename from sdk-core/src/types/identity/v3/version.rs rename to sdk/core/src/types/identity/v3/version.rs diff --git a/sdk-core/src/utils.rs b/sdk/core/src/utils.rs similarity index 100% rename from sdk-core/src/utils.rs rename to sdk/core/src/utils.rs diff --git a/sdk-core/static/callback.html b/sdk/core/static/callback.html similarity index 100% rename from sdk-core/static/callback.html rename to sdk/core/static/callback.html diff --git a/sdk-core/static/callback_error.html b/sdk/core/static/callback_error.html similarity index 100% rename from sdk-core/static/callback_error.html rename to sdk/core/static/callback_error.html diff --git a/sdk-core/static/service-types.json b/sdk/core/static/service-types.json similarity index 100% rename from sdk-core/static/service-types.json rename to sdk/core/static/service-types.json diff --git a/sdk/dns/Cargo.toml b/sdk/dns/Cargo.toml new file mode 100644 index 000000000..45fe7fb70 --- /dev/null +++ b/sdk/dns/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "openstack-sdk-dns" +description = "OpenStack SDK DNS service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/dns/src/lib.rs b/sdk/dns/src/lib.rs new file mode 100644 index 000000000..867289d23 --- /dev/null +++ b/sdk/dns/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Dns` Service bindings +pub mod v2; diff --git a/openstack_sdk/src/api/dns/v2.rs b/sdk/dns/src/v2.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2.rs rename to sdk/dns/src/v2.rs diff --git a/openstack_sdk/src/api/dns/v2/blacklist.rs b/sdk/dns/src/v2/blacklist.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/blacklist.rs rename to sdk/dns/src/v2/blacklist.rs diff --git a/sdk/dns/src/v2/blacklist/create.rs b/sdk/dns/src/v2/blacklist/create.rs new file mode 100644 index 000000000..4a02df610 --- /dev/null +++ b/sdk/dns/src/v2/blacklist/create.rs @@ -0,0 +1,202 @@ +// 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 Blacklist +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Blacklist. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "blacklists".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/blacklists".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/blacklists".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/blacklist/delete.rs b/sdk/dns/src/v2/blacklist/delete.rs new file mode 100644 index 000000000..90fcd2c64 --- /dev/null +++ b/sdk/dns/src/v2/blacklist/delete.rs @@ -0,0 +1,181 @@ +// 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 blacklist +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// blacklist_id parameter for /v2/blacklists/{blacklist_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<'a> RequestBuilder<'a> { + /// Add a single header to the Blacklist. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("blacklists/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/blacklists/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/blacklists/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/blacklist/get.rs b/sdk/dns/src/v2/blacklist/get.rs new file mode 100644 index 000000000..b140c2f6a --- /dev/null +++ b/sdk/dns/src/v2/blacklist/get.rs @@ -0,0 +1,181 @@ +// 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 a blacklist +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// blacklist_id parameter for /v2/blacklists/{blacklist_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<'a> RequestBuilder<'a> { + /// Add a single header to the Blacklist. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("blacklists/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/blacklists/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/blacklists/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/blacklist/list.rs b/sdk/dns/src/v2/blacklist/list.rs new file mode 100644 index 000000000..f6a699c98 --- /dev/null +++ b/sdk/dns/src/v2/blacklist/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 all blacklists +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Blacklist. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "blacklists".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/blacklists".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/blacklists".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/blacklist/set.rs b/sdk/dns/src/v2/blacklist/set.rs new file mode 100644 index 000000000..18561b6a3 --- /dev/null +++ b/sdk/dns/src/v2/blacklist/set.rs @@ -0,0 +1,212 @@ +// 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 a Blacklist +//! +//! Normal response codes: 200 +//! +//! Error response codes: 405,404,403,401,400,503 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// blacklist_id parameter for /v2/blacklists/{blacklist_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Blacklist. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("blacklists/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/blacklists/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/blacklists/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/limit.rs b/sdk/dns/src/v2/limit.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/limit.rs rename to sdk/dns/src/v2/limit.rs diff --git a/sdk/dns/src/v2/limit/get.rs b/sdk/dns/src/v2/limit/get.rs new file mode 100644 index 000000000..7d4b1698b --- /dev/null +++ b/sdk/dns/src/v2/limit/get.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 project limits +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "limits".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/pool.rs b/sdk/dns/src/v2/pool.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/pool.rs rename to sdk/dns/src/v2/pool.rs diff --git a/sdk/dns/src/v2/pool/create.rs b/sdk/dns/src/v2/pool/create.rs new file mode 100644 index 000000000..6b8d6054b --- /dev/null +++ b/sdk/dns/src/v2/pool/create.rs @@ -0,0 +1,202 @@ +// 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 Pool +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "pools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/pools".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/pools".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/pool/delete.rs b/sdk/dns/src/v2/pool/delete.rs new file mode 100644 index 000000000..065b38909 --- /dev/null +++ b/sdk/dns/src/v2/pool/delete.rs @@ -0,0 +1,181 @@ +// 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 the specific pool +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// pool_id parameter for /v2/pools/{pool_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<'a> RequestBuilder<'a> { + /// Add a single header to the Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("pools/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/pools/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/pools/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/pool/get.rs b/sdk/dns/src/v2/pool/get.rs new file mode 100644 index 000000000..86c4871af --- /dev/null +++ b/sdk/dns/src/v2/pool/get.rs @@ -0,0 +1,185 @@ +// 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 a specific Pool +//! +//! Normal response codes: 200 +//! +//! Error response codes: 405,404,403,401,400,503 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// pool_id parameter for /v2/pools/{pool_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<'a> RequestBuilder<'a> { + /// Add a single header to the Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("pools/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/pools/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/pools/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/pool/list.rs b/sdk/dns/src/v2/pool/list.rs new file mode 100644 index 000000000..25d95d3da --- /dev/null +++ b/sdk/dns/src/v2/pool/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`. + +//! Get the list of Pools. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "pools".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/pools".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/pools".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/pool/set.rs b/sdk/dns/src/v2/pool/set.rs new file mode 100644 index 000000000..1a8c71ecf --- /dev/null +++ b/sdk/dns/src/v2/pool/set.rs @@ -0,0 +1,208 @@ +// 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 the specific pool +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// pool_id parameter for /v2/pools/{pool_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("pools/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/pools/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/pools/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/quota.rs b/sdk/dns/src/v2/quota.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/quota.rs rename to sdk/dns/src/v2/quota.rs diff --git a/sdk/dns/src/v2/quota/delete.rs b/sdk/dns/src/v2/quota/delete.rs new file mode 100644 index 000000000..6a813c313 --- /dev/null +++ b/sdk/dns/src/v2/quota/delete.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Reset all quotas for a project to default +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v2/quotas/{project_id} API + #[builder(default, setter(into))] + project_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 Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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/{project_id}", project_id = self.project_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/quotas/{project_id}", project_id = "project_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/quotas/{project_id}", project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/quota/get.rs b/sdk/dns/src/v2/quota/get.rs new file mode 100644 index 000000000..3c2a40c9e --- /dev/null +++ b/sdk/dns/src/v2/quota/get.rs @@ -0,0 +1,183 @@ +// 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`. + +//! View a projects quotas +//! +//! This returns a key:value set of quotas on the system. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v2/quotas/{project_id} API + #[builder(default, setter(into))] + project_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 Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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/{project_id}", project_id = self.project_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{project_id}", project_id = "project_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{project_id}", project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/quota/list.rs b/sdk/dns/src/v2/quota/list.rs new file mode 100644 index 000000000..dcd6ef706 --- /dev/null +++ b/sdk/dns/src/v2/quota/list.rs @@ -0,0 +1,164 @@ +// 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 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::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 openstack_sdk_core::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("/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::GET) + .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/sdk/dns/src/v2/quota/set.rs b/sdk/dns/src/v2/quota/set.rs new file mode 100644 index 000000000..9d7789755 --- /dev/null +++ b/sdk/dns/src/v2/quota/set.rs @@ -0,0 +1,222 @@ +// 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 a projects quotas +//! +//! The request should be a key:value set of quotas to be set +//! +//! This returns a key:value set of quotas on the system. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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) api_export_size: Option, + + #[builder(default, setter(into))] + pub(crate) recordset_records: Option, + + #[builder(default, setter(into))] + pub(crate) zone_records: Option, + + #[builder(default, setter(into))] + pub(crate) zone_recordsets: Option, + + #[builder(default, setter(into))] + pub(crate) zones: Option, + + /// project_id parameter for /v2/quotas/{project_id} API + #[builder(default, setter(into))] + project_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 Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("quotas/{project_id}", project_id = self.project_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.api_export_size { + params.push("api_export_size", serde_json::to_value(val)?); + } + if let Some(val) = &self.recordset_records { + params.push("recordset_records", serde_json::to_value(val)?); + } + if let Some(val) = &self.zone_records { + params.push("zone_records", serde_json::to_value(val)?); + } + if let Some(val) = &self.zone_recordsets { + params.push("zone_recordsets", serde_json::to_value(val)?); + } + if let Some(val) = &self.zones { + params.push("zones", serde_json::to_value(val)?); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/quotas/{project_id}", project_id = "project_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/quotas/{project_id}", project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/recordset.rs b/sdk/dns/src/v2/recordset.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/recordset.rs rename to sdk/dns/src/v2/recordset.rs diff --git a/sdk/dns/src/v2/recordset/get.rs b/sdk/dns/src/v2/recordset/get.rs new file mode 100644 index 000000000..2d4b7035c --- /dev/null +++ b/sdk/dns/src/v2/recordset/get.rs @@ -0,0 +1,181 @@ +// 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 RecordSet +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// recordset_id parameter for /v2/recordsets/{recordset_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<'a> RequestBuilder<'a> { + /// Add a single header to the Recordset. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("recordsets/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/recordsets/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/recordsets/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/recordset/list.rs b/sdk/dns/src/v2/recordset/list.rs new file mode 100644 index 000000000..02338c21e --- /dev/null +++ b/sdk/dns/src/v2/recordset/list.rs @@ -0,0 +1,254 @@ +// 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`. + +//! This lists all recordsets owned by a project in Designate +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filter results to only show zones that have a type matching the filter + #[builder(default, setter(into))] + _type: Option>, + + /// Filter results to only show recordsets that have a record with data + /// matching the filter + #[builder(default, setter(into))] + data: Option>, + + /// Filter results to only show zones that have a description matching the + /// filter + #[builder(default, setter(into))] + description: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Filter results to only show zones that have a name matching the filter + #[builder(default, setter(into))] + name: Option>, + + /// Sorts the response by the requested sort direction. A valid value is + /// asc (ascending) or desc (descending). Default is asc. You can specify + /// multiple pairs of sort key and sort direction query parameters. If you + /// omit the sort direction in a pair, the API uses the natural sorting + /// direction of the server attribute that is provided as the sort_key. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts the response by the this attribute value. Default is id. You can + /// specify multiple pairs of sort key and sort direction query parameters. + /// If you omit the sort direction in a pair, the API uses the natural + /// sorting direction of the server attribute that is provided as the + /// sort_key. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filter results to only show zones that have a status matching the + /// filter + #[builder(default, setter(into))] + status: Option>, + + /// Filter results to only show zones that have a ttl matching the filter + #[builder(default)] + ttl: Option, + + /// ID for the zone + #[builder(default, setter(into))] + zone_id: 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> { + /// Add a single header to the Recordset. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "recordsets".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("data", self.data.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("ttl", self.ttl); + params.push_opt("type", self._type.as_ref()); + params.push_opt("zone_id", self.zone_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Dns + } + + fn response_key(&self) -> Option> { + Some("recordsets".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Dns + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "recordsets" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/recordsets".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "recordsets": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/recordsets".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "recordsets": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/reverse.rs b/sdk/dns/src/v2/reverse.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/reverse.rs rename to sdk/dns/src/v2/reverse.rs diff --git a/openstack_sdk/src/api/dns/v2/reverse/floatingip.rs b/sdk/dns/src/v2/reverse/floatingip.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/reverse/floatingip.rs rename to sdk/dns/src/v2/reverse/floatingip.rs diff --git a/sdk/dns/src/v2/reverse/floatingip/get.rs b/sdk/dns/src/v2/reverse/floatingip/get.rs new file mode 100644 index 000000000..011b0932f --- /dev/null +++ b/sdk/dns/src/v2/reverse/floatingip/get.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Shows a particular FloatingIP PTR +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// fip_key parameter for /v2/reverse/floatingips/{fip_key} API + #[builder(default, setter(into))] + fip_key: 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 Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "reverse/floatingips/{fip_key}", + fip_key = self.fip_key.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/reverse/floatingips/{fip_key}", + fip_key = "fip_key", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().fip_key("fip_key").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/reverse/floatingips/{fip_key}", + fip_key = "fip_key", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .fip_key("fip_key") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/reverse/floatingip/list.rs b/sdk/dns/src/v2/reverse/floatingip/list.rs new file mode 100644 index 000000000..356399405 --- /dev/null +++ b/sdk/dns/src/v2/reverse/floatingip/list.rs @@ -0,0 +1,179 @@ +// 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 FloatingIP PTR records +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "reverse/floatingips".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Dns + } + + fn response_key(&self) -> Option> { + Some("floatingips".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Dns + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floatingips" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/reverse/floatingips".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingips": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/reverse/floatingips".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingips": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/reverse/floatingip/set.rs b/sdk/dns/src/v2/reverse/floatingip/set.rs new file mode 100644 index 000000000..0ccb5ef10 --- /dev/null +++ b/sdk/dns/src/v2/reverse/floatingip/set.rs @@ -0,0 +1,226 @@ +// 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 a PTR record for the given FloatingIP. The domain if it does not exist +//! will be provisioned automatically. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The floatingip address for this PTR record. + #[builder(default, setter(into))] + pub(crate) address: Option>, + + /// Description for this PTR record + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Domain name for this PTR record + #[builder(default, setter(into))] + pub(crate) ptrdname: Option>>, + + /// Time to live for this PTR record + #[builder(default, setter(into))] + pub(crate) ttl: Option, + + /// fip_key parameter for /v2/reverse/floatingips/{fip_key} API + #[builder(default, setter(into))] + fip_key: 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 Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "reverse/floatingips/{fip_key}", + fip_key = self.fip_key.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.address { + params.push("address", serde_json::to_value(val)?); + } + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self.ptrdname { + params.push("ptrdname", serde_json::to_value(val)?); + } + if let Some(val) = &self.ttl { + params.push("ttl", serde_json::to_value(val)?); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH).path(format!( + "/reverse/floatingips/{fip_key}", + fip_key = "fip_key", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().fip_key("fip_key").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!( + "/reverse/floatingips/{fip_key}", + fip_key = "fip_key", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .fip_key("fip_key") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/service_status.rs b/sdk/dns/src/v2/service_status.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/service_status.rs rename to sdk/dns/src/v2/service_status.rs diff --git a/sdk/dns/src/v2/service_status/get.rs b/sdk/dns/src/v2/service_status/get.rs new file mode 100644 index 000000000..c70451517 --- /dev/null +++ b/sdk/dns/src/v2/service_status/get.rs @@ -0,0 +1,190 @@ +// 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 status of a service. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_id parameter for /v2/service_statuses/{service_id} API + #[builder(default, setter(into))] + service_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 Service_Status. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "service_statuses/{service_id}", + service_id = self.service_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/service_statuses/{service_id}", + service_id = "service_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().service_id("service_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/service_statuses/{service_id}", + service_id = "service_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() + .service_id("service_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/service_status/list.rs b/sdk/dns/src/v2/service_status/list.rs new file mode 100644 index 000000000..025578f57 --- /dev/null +++ b/sdk/dns/src/v2/service_status/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 all Services and statuses. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Service_Status. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "service_statuses".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/service_statuses".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/service_statuses".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/tld.rs b/sdk/dns/src/v2/tld.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/tld.rs rename to sdk/dns/src/v2/tld.rs diff --git a/sdk/dns/src/v2/tld/create.rs b/sdk/dns/src/v2/tld/create.rs new file mode 100644 index 000000000..401ce2c08 --- /dev/null +++ b/sdk/dns/src/v2/tld/create.rs @@ -0,0 +1,202 @@ +// 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 tld +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Tld. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "tlds".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/tlds".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/tlds".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tld/delete.rs b/sdk/dns/src/v2/tld/delete.rs new file mode 100644 index 000000000..97c20d6e2 --- /dev/null +++ b/sdk/dns/src/v2/tld/delete.rs @@ -0,0 +1,181 @@ +// 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 tld +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// tld_id parameter for /v2/tlds/{tld_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<'a> RequestBuilder<'a> { + /// Add a single header to the Tld. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("tlds/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/tlds/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/tlds/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tld/get.rs b/sdk/dns/src/v2/tld/get.rs new file mode 100644 index 000000000..d32644eb0 --- /dev/null +++ b/sdk/dns/src/v2/tld/get.rs @@ -0,0 +1,181 @@ +// 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 a tld +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// tld_id parameter for /v2/tlds/{tld_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<'a> RequestBuilder<'a> { + /// Add a single header to the Tld. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("tlds/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/tlds/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/tlds/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tld/list.rs b/sdk/dns/src/v2/tld/list.rs new file mode 100644 index 000000000..bd18d1cab --- /dev/null +++ b/sdk/dns/src/v2/tld/list.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`. + +//! List the tlds associated with the Project +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Tld. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "tlds".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path("/tlds".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/tlds".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tld/set.rs b/sdk/dns/src/v2/tld/set.rs new file mode 100644 index 000000000..810b2f263 --- /dev/null +++ b/sdk/dns/src/v2/tld/set.rs @@ -0,0 +1,208 @@ +// 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 a tld +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// tld_id parameter for /v2/tlds/{tld_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Tld. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("tlds/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/tlds/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/tlds/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/tsigkey.rs b/sdk/dns/src/v2/tsigkey.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/tsigkey.rs rename to sdk/dns/src/v2/tsigkey.rs diff --git a/sdk/dns/src/v2/tsigkey/create.rs b/sdk/dns/src/v2/tsigkey/create.rs new file mode 100644 index 000000000..59e0af89b --- /dev/null +++ b/sdk/dns/src/v2/tsigkey/create.rs @@ -0,0 +1,202 @@ +// 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 Tsigkey +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Tsigkey. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "tsigkeys".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/tsigkeys".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/tsigkeys".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tsigkey/delete.rs b/sdk/dns/src/v2/tsigkey/delete.rs new file mode 100644 index 000000000..2b15db718 --- /dev/null +++ b/sdk/dns/src/v2/tsigkey/delete.rs @@ -0,0 +1,181 @@ +// 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 tsigkey +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// tsigkey_id parameter for /v2/tsigkeys/{tsigkey_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<'a> RequestBuilder<'a> { + /// Add a single header to the Tsigkey. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("tsigkeys/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/tsigkeys/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/tsigkeys/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tsigkey/get.rs b/sdk/dns/src/v2/tsigkey/get.rs new file mode 100644 index 000000000..a5ba3972d --- /dev/null +++ b/sdk/dns/src/v2/tsigkey/get.rs @@ -0,0 +1,181 @@ +// 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 a tsigkey +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// tsigkey_id parameter for /v2/tsigkeys/{tsigkey_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<'a> RequestBuilder<'a> { + /// Add a single header to the Tsigkey. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("tsigkeys/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/tsigkeys/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/tsigkeys/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tsigkey/list.rs b/sdk/dns/src/v2/tsigkey/list.rs new file mode 100644 index 000000000..9cb9621f5 --- /dev/null +++ b/sdk/dns/src/v2/tsigkey/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 all tsigkeys +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Tsigkey. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "tsigkeys".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/tsigkeys".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/tsigkeys".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/tsigkey/set.rs b/sdk/dns/src/v2/tsigkey/set.rs new file mode 100644 index 000000000..c5d2398a2 --- /dev/null +++ b/sdk/dns/src/v2/tsigkey/set.rs @@ -0,0 +1,208 @@ +// 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 the attribute(s) of an existing tsigkey +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// tsigkey_id parameter for /v2/tsigkeys/{tsigkey_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Tsigkey. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("tsigkeys/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/tsigkeys/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/tsigkeys/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone.rs b/sdk/dns/src/v2/zone.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone.rs rename to sdk/dns/src/v2/zone.rs diff --git a/sdk/dns/src/v2/zone/create.rs b/sdk/dns/src/v2/zone/create.rs new file mode 100644 index 000000000..bcb521473 --- /dev/null +++ b/sdk/dns/src/v2/zone/create.rs @@ -0,0 +1,266 @@ +// 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 zone +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Type { + #[serde(rename = "CATALOG")] + Catalog, + #[serde(rename = "PRIMARY")] + Primary, + #[serde(rename = "SECONDARY")] + Secondary, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Key:Value pairs of information about this zone, and the pool the user + /// would like to place the zone in. This information can be used by the + /// scheduler to place zones on the correct pool. + #[builder(default, private, setter(into, name = "_attributes"))] + pub(crate) attributes: Option, Cow<'a, str>>>, + + /// Description for this zone + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// e-mail for the zone. Used in SOA records for the zone. Mandatory for + /// PRIMARY zones, forbidden for SECONDARY zones. + #[builder(default, setter(into))] + pub(crate) email: Option>, + + /// Mandatory for secondary zones. The servers to slave from to get DNS + /// information + #[builder(default, setter(into))] + pub(crate) masters: Option>>, + + /// DNS Name for the zone + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// TTL (Time to Live) for the zone. + #[builder(default, setter(into))] + pub(crate) ttl: Option, + + /// Type of zone. PRIMARY is controlled by Designate, SECONDARY zones are + /// slaved from another DNS Server. Defaults to PRIMARY + #[builder(default)] + pub(crate) _type: 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> { + /// Key:Value pairs of information about this zone, and the pool the user + /// would like to place the zone in. This information can be used by the + /// scheduler to place zones on the correct pool. + pub fn attributes(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.attributes + .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 Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "zones".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.attributes { + params.push("attributes", serde_json::to_value(val)?); + } + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self.email { + params.push("email", serde_json::to_value(val)?); + } + if let Some(val) = &self.masters { + params.push("masters", serde_json::to_value(val)?); + } + if let Some(val) = &self.name { + params.push("name", serde_json::to_value(val)?); + } + if let Some(val) = &self.ttl { + params.push("ttl", serde_json::to_value(val)?); + } + if let Some(val) = &self._type { + params.push("type", serde_json::to_value(val)?); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/zones".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/zones".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/delete.rs b/sdk/dns/src/v2/zone/delete.rs new file mode 100644 index 000000000..be48c95c8 --- /dev/null +++ b/sdk/dns/src/v2/zone/delete.rs @@ -0,0 +1,181 @@ +// 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 zone +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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} 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<'a> RequestBuilder<'a> { + /// Add a single header to the Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/zones/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/zones/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/find.rs b/sdk/dns/src/v2/zone/find.rs new file mode 100644 index 000000000..65c21f1fd --- /dev/null +++ b/sdk/dns/src/v2/zone/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::zone::{get as Get, list as List}; + +/// Find for zone 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/dns/src/v2/zone/get.rs b/sdk/dns/src/v2/zone/get.rs new file mode 100644 index 000000000..ecc970b98 --- /dev/null +++ b/sdk/dns/src/v2/zone/get.rs @@ -0,0 +1,181 @@ +// 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 a zone +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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} 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<'a> RequestBuilder<'a> { + /// Add a single header to the Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/list.rs b/sdk/dns/src/v2/zone/list.rs new file mode 100644 index 000000000..2bb7e8db6 --- /dev/null +++ b/sdk/dns/src/v2/zone/list.rs @@ -0,0 +1,249 @@ +// 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 zones +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filter results to only show zones that have a type matching the filter + #[builder(default, setter(into))] + _type: Option>, + + /// Filter results to only show zones that have a description matching the + /// filter + #[builder(default, setter(into))] + description: Option>, + + /// Filter results to only show zones that have an email matching the + /// filter + #[builder(default, setter(into))] + email: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Filter results to only show zones that have a name matching the filter + #[builder(default, setter(into))] + name: Option>, + + /// Sorts the response by the requested sort direction. A valid value is + /// asc (ascending) or desc (descending). Default is asc. You can specify + /// multiple pairs of sort key and sort direction query parameters. If you + /// omit the sort direction in a pair, the API uses the natural sorting + /// direction of the server attribute that is provided as the sort_key. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts the response by the this attribute value. Default is id. You can + /// specify multiple pairs of sort key and sort direction query parameters. + /// If you omit the sort direction in a pair, the API uses the natural + /// sorting direction of the server attribute that is provided as the + /// sort_key. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filter results to only show zones that have a status matching the + /// filter + #[builder(default, setter(into))] + status: Option>, + + /// Filter results to only show zones that have a ttl matching the filter + #[builder(default)] + ttl: 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> { + /// Add a single header to the Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "zones".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("description", self.description.as_ref()); + params.push_opt("email", self.email.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("ttl", self.ttl); + params.push_opt("type", self._type.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Dns + } + + fn response_key(&self) -> Option> { + Some("zones".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Dns + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "zones" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "zones": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "zones": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/nameserver.rs b/sdk/dns/src/v2/zone/nameserver.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/nameserver.rs rename to sdk/dns/src/v2/zone/nameserver.rs diff --git a/sdk/dns/src/v2/zone/nameserver/list.rs b/sdk/dns/src/v2/zone/nameserver/list.rs new file mode 100644 index 000000000..29c399804 --- /dev/null +++ b/sdk/dns/src/v2/zone/nameserver/list.rs @@ -0,0 +1,188 @@ +// 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "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> { + Some("nameservers".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Dns + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "nameservers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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!({ "nameservers": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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!({ "nameservers": {} })); + }); + + let endpoint = Request::builder() + .zone_id("zone_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("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.rs b/sdk/dns/src/v2/zone/recordset.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/recordset.rs rename to sdk/dns/src/v2/zone/recordset.rs diff --git a/sdk/dns/src/v2/zone/recordset/create.rs b/sdk/dns/src/v2/zone/recordset/create.rs new file mode 100644 index 000000000..fa78b91c9 --- /dev/null +++ b/sdk/dns/src/v2/zone/recordset/create.rs @@ -0,0 +1,264 @@ +// 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 recordset in a zone +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "A")] + A, + #[serde(rename = "AAAA")] + Aaaa, + #[serde(rename = "CAA")] + Caa, + #[serde(rename = "CERT")] + Cert, + #[serde(rename = "CNAME")] + Cname, + #[serde(rename = "MX")] + Mx, + #[serde(rename = "NAPTR")] + Naptr, + #[serde(rename = "NS")] + Ns, + #[serde(rename = "PTR")] + Ptr, + #[serde(rename = "SOA")] + Soa, + #[serde(rename = "SPF")] + Spf, + #[serde(rename = "SRV")] + Srv, + #[serde(rename = "SSHFP")] + Sshfp, + #[serde(rename = "TXT")] + Txt, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Description for this recordset + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// DNS Name for the recordset + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of data for this recordset. Each item will be a separate record + /// in Designate These items should conform to the DNS spec for the record + /// type - e.g. A records must be IPv4 addresses, CNAME records must be a + /// hostname. + #[builder(default, setter(into))] + pub(crate) records: Option>>, + + /// TTL (Time to Live) for the recordset. + #[builder(default, setter(into))] + pub(crate) ttl: Option, + + /// They RRTYPE of the recordset. + #[builder(default)] + pub(crate) _type: Option, + + /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "zones/{zone_id}/recordsets", + zone_id = self.zone_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self.name { + params.push("name", serde_json::to_value(val)?); + } + if let Some(val) = &self.records { + params.push("records", serde_json::to_value(val)?); + } + if let Some(val) = &self.ttl { + params.push("ttl", serde_json::to_value(val)?); + } + if let Some(val) = &self._type { + params.push("type", serde_json::to_value(val)?); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/zones/{zone_id}/recordsets", 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/zones/{zone_id}/recordsets", 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/recordset/delete.rs b/sdk/dns/src/v2/zone/recordset/delete.rs new file mode 100644 index 000000000..ea1598814 --- /dev/null +++ b/sdk/dns/src/v2/zone/recordset/delete.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`. + +//! Delete a recordset +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// recordset_id parameter for + /// /v2/zones/{zone_id}/recordsets/{recordset_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/{zone_id}/recordsets/{id}", + id = self.id.as_ref(), + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/zones/{zone_id}/recordsets/{id}", + id = "id", + zone_id = "zone_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .zone_id("zone_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/zones/{zone_id}/recordsets/{id}", + id = "id", + 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() + .id("id") + .zone_id("zone_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/recordset/find.rs b/sdk/dns/src/v2/zone/recordset/find.rs new file mode 100644 index 000000000..b99a9bd5b --- /dev/null +++ b/sdk/dns/src/v2/zone/recordset/find.rs @@ -0,0 +1,96 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::zone::recordset::{get as Get, list as List}; + +/// Find for zone/recordset by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[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 Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.zone_id(self.zone_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + let mut ep = List::Request::builder(); + ep.zone_id(self.zone_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/dns/src/v2/zone/recordset/get.rs b/sdk/dns/src/v2/zone/recordset/get.rs new file mode 100644 index 000000000..f89ba5b77 --- /dev/null +++ b/sdk/dns/src/v2/zone/recordset/get.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 an single recordset +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// recordset_id parameter for + /// /v2/zones/{zone_id}/recordsets/{recordset_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/{zone_id}/recordsets/{id}", + id = self.id.as_ref(), + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/zones/{zone_id}/recordsets/{id}", + id = "id", + zone_id = "zone_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .zone_id("zone_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/zones/{zone_id}/recordsets/{id}", + id = "id", + 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() + .id("id") + .zone_id("zone_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/recordset/list.rs b/sdk/dns/src/v2/zone/recordset/list.rs new file mode 100644 index 000000000..cfd237f83 --- /dev/null +++ b/sdk/dns/src/v2/zone/recordset/list.rs @@ -0,0 +1,258 @@ +// 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`. + +//! This lists all recordsets in a zone +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filter results to only show zones that have a type matching the filter + #[builder(default, setter(into))] + _type: Option>, + + /// Filter results to only show recordsets that have a record with data + /// matching the filter + #[builder(default, setter(into))] + data: Option>, + + /// Filter results to only show zones that have a description matching the + /// filter + #[builder(default, setter(into))] + description: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Filter results to only show zones that have a name matching the filter + #[builder(default, setter(into))] + name: Option>, + + /// Sorts the response by the requested sort direction. A valid value is + /// asc (ascending) or desc (descending). Default is asc. You can specify + /// multiple pairs of sort key and sort direction query parameters. If you + /// omit the sort direction in a pair, the API uses the natural sorting + /// direction of the server attribute that is provided as the sort_key. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts the response by the this attribute value. Default is id. You can + /// specify multiple pairs of sort key and sort direction query parameters. + /// If you omit the sort direction in a pair, the API uses the natural + /// sorting direction of the server attribute that is provided as the + /// sort_key. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filter results to only show zones that have a status matching the + /// filter + #[builder(default, setter(into))] + status: Option>, + + /// Filter results to only show zones that have a ttl matching the filter + #[builder(default)] + ttl: Option, + + /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/{zone_id}/recordsets", + zone_id = self.zone_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("data", self.data.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("ttl", self.ttl); + params.push_opt("type", self._type.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Dns + } + + fn response_key(&self) -> Option> { + Some("recordsets".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Dns + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "recordsets" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .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().zone_id("zone_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/{zone_id}/recordsets", zone_id = "zone_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "recordsets": {} })); + }); + + let endpoint = Request::builder() + .zone_id("zone_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/recordset/set.rs b/sdk/dns/src/v2/zone/recordset/set.rs new file mode 100644 index 000000000..0cf3a9e65 --- /dev/null +++ b/sdk/dns/src/v2/zone/recordset/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 a recordset +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Description for this recordset + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// A list of data for this recordset. Each item will be a separate record + /// in Designate These items should conform to the DNS spec for the record + /// type - e.g. A records must be IPv4 addresses, CNAME records must be a + /// hostname. + #[builder(default, setter(into))] + pub(crate) records: Option>>, + + /// TTL (Time to Live) for the recordset. + #[builder(default, setter(into))] + pub(crate) ttl: Option, + + /// recordset_id parameter for + /// /v2/zones/{zone_id}/recordsets/{recordset_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// zone_id parameter for /v2/zones/{zone_id}/recordsets/{recordset_id} 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 Recordset. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "zones/{zone_id}/recordsets/{id}", + id = self.id.as_ref(), + zone_id = self.zone_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self.records { + params.push("records", serde_json::to_value(val)?); + } + if let Some(val) = &self.ttl { + params.push("ttl", serde_json::to_value(val)?); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/zones/{zone_id}/recordsets/{id}", + id = "id", + zone_id = "zone_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .zone_id("zone_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/zones/{zone_id}/recordsets/{id}", + id = "id", + 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() + .id("id") + .zone_id("zone_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/set.rs b/sdk/dns/src/v2/zone/set.rs new file mode 100644 index 000000000..f00fce0d7 --- /dev/null +++ b/sdk/dns/src/v2/zone/set.rs @@ -0,0 +1,210 @@ +// 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 the attribute(s) for an existing zone. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Description for this zone + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// e-mail for the zone. Used in SOA records for the zone. Forbidden for + /// SECONDARY zones. + #[builder(default, setter(into))] + pub(crate) email: Option>, + + /// TTL (Time to Live) for the zone. + #[builder(default, setter(into))] + pub(crate) ttl: Option, + + /// zone_id parameter for /v2/zones/{zone_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<'a> RequestBuilder<'a> { + /// Add a single header to the Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self.email { + params.push("email", serde_json::to_value(val)?); + } + if let Some(val) = &self.ttl { + params.push("ttl", serde_json::to_value(val)?); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/zones/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/zones/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/share.rs b/sdk/dns/src/v2/zone/share.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/share.rs rename to sdk/dns/src/v2/zone/share.rs diff --git a/sdk/dns/src/v2/zone/share/create.rs b/sdk/dns/src/v2/zone/share/create.rs new file mode 100644 index 000000000..d706b0c8a --- /dev/null +++ b/sdk/dns/src/v2/zone/share/create.rs @@ -0,0 +1,216 @@ +// 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`. + +//! Share a zone with another project. +//! +//! **New in version 2.1** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The project ID the zone will be shared with. + /// + /// **New in version 2.1** + #[builder(setter(into))] + pub(crate) target_project_id: Cow<'a, str>, + + /// zone_id parameter for /v2/zones/{zone_id}/shares 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 Share. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("zones/{zone_id}/shares", zone_id = self.zone_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "target_project_id", + serde_json::to_value(&self.target_project_id)?, + ); + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .target_project_id("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Dns + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .target_project_id("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/zones/{zone_id}/shares", zone_id = "zone_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_id("zone_id") + .target_project_id("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/zones/{zone_id}/shares", 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") + .target_project_id("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/share/delete.rs b/sdk/dns/src/v2/zone/share/delete.rs new file mode 100644 index 000000000..0e9901630 --- /dev/null +++ b/sdk/dns/src/v2/zone/share/delete.rs @@ -0,0 +1,205 @@ +// 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 zone share. +//! +//! **New in version 2.1** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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}/shares API + #[builder(default, setter(into))] + zone_id: Cow<'a, str>, + + /// zone_share_id parameter for /v2/zones/{zone_id}/shares/{zone_share_id} + /// API + #[builder(default, setter(into))] + zone_share_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 Share. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/{zone_id}/shares/{zone_share_id}", + zone_id = self.zone_id.as_ref(), + zone_share_id = self.zone_share_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/zones/{zone_id}/shares/{zone_share_id}", + zone_id = "zone_id", + zone_share_id = "zone_share_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_id("zone_id") + .zone_share_id("zone_share_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/zones/{zone_id}/shares/{zone_share_id}", + zone_id = "zone_id", + zone_share_id = "zone_share_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") + .zone_share_id("zone_share_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/share/get.rs b/sdk/dns/src/v2/zone/share/get.rs new file mode 100644 index 000000000..ffe70b4c9 --- /dev/null +++ b/sdk/dns/src/v2/zone/share/get.rs @@ -0,0 +1,205 @@ +// 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 a single zone share. +//! +//! **New in version 2.1** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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}/shares API + #[builder(default, setter(into))] + zone_id: Cow<'a, str>, + + /// zone_share_id parameter for /v2/zones/{zone_id}/shares/{zone_share_id} + /// API + #[builder(default, setter(into))] + zone_share_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 Share. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/{zone_id}/shares/{zone_share_id}", + zone_id = self.zone_id.as_ref(), + zone_share_id = self.zone_share_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/zones/{zone_id}/shares/{zone_share_id}", + zone_id = "zone_id", + zone_share_id = "zone_share_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_id("zone_id") + .zone_share_id("zone_share_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/zones/{zone_id}/shares/{zone_share_id}", + zone_id = "zone_id", + zone_share_id = "zone_share_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") + .zone_share_id("zone_share_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/share/list.rs b/sdk/dns/src/v2/zone/share/list.rs new file mode 100644 index 000000000..2155590f3 --- /dev/null +++ b/sdk/dns/src/v2/zone/share/list.rs @@ -0,0 +1,208 @@ +// 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 zone shares. +//! +//! **New in version 2.1** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Filter results to only show resources that have a matching + /// target_project_id + #[builder(default, setter(into))] + target_project_id: Option>, + + /// zone_id parameter for /v2/zones/{zone_id}/shares 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 Share. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/{zone_id}/shares", zone_id = self.zone_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("target_project_id", self.target_project_id.as_ref()); + + params + } + + 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)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/{zone_id}/shares", 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/{zone_id}/shares", 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/task.rs b/sdk/dns/src/v2/zone/task.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/task.rs rename to sdk/dns/src/v2/zone/task.rs diff --git a/openstack_sdk/src/api/dns/v2/zone/task/abandon.rs b/sdk/dns/src/v2/zone/task/abandon.rs similarity index 99% rename from openstack_sdk/src/api/dns/v2/zone/task/abandon.rs rename to sdk/dns/src/v2/zone/task/abandon.rs index 2aa957b8b..bf68a40f9 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/abandon.rs +++ b/sdk/dns/src/v2/zone/task/abandon.rs @@ -145,7 +145,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/dns/v2/zone/task/export.rs b/sdk/dns/src/v2/zone/task/export.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/task/export.rs rename to sdk/dns/src/v2/zone/task/export.rs diff --git a/sdk/dns/src/v2/zone/task/export/create.rs b/sdk/dns/src/v2/zone/task/export/create.rs new file mode 100644 index 000000000..a0fd0b9b2 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/export/create.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Export a zone. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// zone_id parameter for /v2/zones/{zone_id}/tasks/export API + #[builder(default, setter(into))] + zone_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Export. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "zones/{zone_id}/tasks/export", + zone_id = self.zone_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/zones/{zone_id}/tasks/export", + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/zones/{zone_id}/tasks/export", + 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/export/delete.rs b/sdk/dns/src/v2/zone/task/export/delete.rs new file mode 100644 index 000000000..185a0b7f4 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/export/delete.rs @@ -0,0 +1,196 @@ +// 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`. + +//! This will just delete the record of the zone export, not the exported zone. +//! +//! The zone will have to be deleted from the zone delete API +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// zone_export_id parameter for /v2/zones/tasks/exports/{zone_export_id} + /// API + #[builder(default, setter(into))] + zone_export_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 Export. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/tasks/exports/{zone_export_id}", + zone_export_id = self.zone_export_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/zones/tasks/exports/{zone_export_id}", + zone_export_id = "zone_export_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_export_id("zone_export_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/zones/tasks/exports/{zone_export_id}", + zone_export_id = "zone_export_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_export_id("zone_export_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/export/export.rs b/sdk/dns/src/v2/zone/task/export/export.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/task/export/export.rs rename to sdk/dns/src/v2/zone/task/export/export.rs diff --git a/sdk/dns/src/v2/zone/task/export/export/get.rs b/sdk/dns/src/v2/zone/task/export/export/get.rs new file mode 100644 index 000000000..439f517db --- /dev/null +++ b/sdk/dns/src/v2/zone/task/export/export/get.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// export_id parameter for /v2/zones/tasks/exports/{export_id}/export 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<'a> RequestBuilder<'a> { + /// Add a single header to the Export. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/tasks/exports/{id}/export", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/exports/{id}/export", 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/exports/{id}/export", 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/export/get.rs b/sdk/dns/src/v2/zone/task/export/get.rs new file mode 100644 index 000000000..8a7bb6f13 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/export/get.rs @@ -0,0 +1,181 @@ +// 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 Zone Exports +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// export_id parameter for /v2/zones/tasks/exports/{export_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<'a> RequestBuilder<'a> { + /// Add a single header to the Export. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/tasks/exports/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/exports/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/exports/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/export/list.rs b/sdk/dns/src/v2/zone/task/export/list.rs new file mode 100644 index 000000000..0ce76b04e --- /dev/null +++ b/sdk/dns/src/v2/zone/task/export/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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Export. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "zones/tasks/exports".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/exports".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/exports".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/import.rs b/sdk/dns/src/v2/zone/task/import.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/task/import.rs rename to sdk/dns/src/v2/zone/task/import.rs diff --git a/sdk/dns/src/v2/zone/task/import/create.rs b/sdk/dns/src/v2/zone/task/import/create.rs new file mode 100644 index 000000000..ff75ba6d9 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/import/create.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Import a zone. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Import. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "zones/tasks/imports".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/zones/tasks/imports".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/zones/tasks/imports".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/import/delete.rs b/sdk/dns/src/v2/zone/task/import/delete.rs new file mode 100644 index 000000000..fe0a304ec --- /dev/null +++ b/sdk/dns/src/v2/zone/task/import/delete.rs @@ -0,0 +1,196 @@ +// 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`. + +//! This will just delete the record of the zone import, not the imported zone. +//! +//! The zone will have to be deleted from the zone delete API +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// zone_import_id parameter for /v2/zones/tasks/imports/{zone_import_id} + /// API + #[builder(default, setter(into))] + zone_import_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 Import. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/tasks/imports/{zone_import_id}", + zone_import_id = self.zone_import_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/zones/tasks/imports/{zone_import_id}", + zone_import_id = "zone_import_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_import_id("zone_import_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/zones/tasks/imports/{zone_import_id}", + zone_import_id = "zone_import_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_import_id("zone_import_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/import/get.rs b/sdk/dns/src/v2/zone/task/import/get.rs new file mode 100644 index 000000000..609e373c2 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/import/get.rs @@ -0,0 +1,181 @@ +// 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 Zone Imports +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// import_id parameter for /v2/zones/tasks/imports/{import_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<'a> RequestBuilder<'a> { + /// Add a single header to the Import. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/tasks/imports/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/imports/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/imports/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/import/list.rs b/sdk/dns/src/v2/zone/task/import/list.rs new file mode 100644 index 000000000..25e7dde87 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/import/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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Import. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "zones/tasks/imports".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/imports".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/imports".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/pool_move.rs b/sdk/dns/src/v2/zone/task/pool_move.rs similarity index 99% rename from openstack_sdk/src/api/dns/v2/zone/task/pool_move.rs rename to sdk/dns/src/v2/zone/task/pool_move.rs index ff96523e1..1fbe97a10 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/pool_move.rs +++ b/sdk/dns/src/v2/zone/task/pool_move.rs @@ -146,7 +146,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_accept.rs b/sdk/dns/src/v2/zone/task/transfer_accept.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/task/transfer_accept.rs rename to sdk/dns/src/v2/zone/task/transfer_accept.rs diff --git a/sdk/dns/src/v2/zone/task/transfer_accept/create.rs b/sdk/dns/src/v2/zone/task/transfer_accept/create.rs new file mode 100644 index 000000000..d9e9de4d2 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_accept/create.rs @@ -0,0 +1,202 @@ +// 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`. + +//! This accepts an offer of a ownership transfer +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Transfer_Accept. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "zones/tasks/transfer_accepts".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/zones/tasks/transfer_accepts".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/zones/tasks/transfer_accepts".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/transfer_accept/get.rs b/sdk/dns/src/v2/zone/task/transfer_accept/get.rs new file mode 100644 index 000000000..4c605e51c --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_accept/get.rs @@ -0,0 +1,182 @@ +// 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 transfer_accepts +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// transfer_accept_id parameter for + /// /v2/zones/tasks/transfer_accepts/{transfer_accept_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<'a> RequestBuilder<'a> { + /// Add a single header to the Transfer_Accept. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("zones/tasks/transfer_accepts/{id}", id = self.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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/transfer_accepts/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/zones/tasks/transfer_accepts/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/transfer_accept/list.rs b/sdk/dns/src/v2/zone/task/transfer_accept/list.rs new file mode 100644 index 000000000..f4ff94542 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_accept/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`. + +//! This will list all your accepted ownership transfer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Transfer_Accept. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "zones/tasks/transfer_accepts".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/transfer_accepts".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/transfer_accepts".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/transfer_request.rs b/sdk/dns/src/v2/zone/task/transfer_request.rs similarity index 100% rename from openstack_sdk/src/api/dns/v2/zone/task/transfer_request.rs rename to sdk/dns/src/v2/zone/task/transfer_request.rs diff --git a/sdk/dns/src/v2/zone/task/transfer_request/create.rs b/sdk/dns/src/v2/zone/task/transfer_request/create.rs new file mode 100644 index 000000000..62125dac4 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_request/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`. + +//! This creates an offer to transfer the zone to a different project. The +//! request can be scoped to single project if the `project_id` parameter is +//! supplied. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// zone_id parameter for /v2/zones/{zone_id}/tasks/transfer_requests API + #[builder(default, setter(into))] + zone_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Transfer_Request. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "zones/{zone_id}/tasks/transfer_requests", + zone_id = self.zone_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/zones/{zone_id}/tasks/transfer_requests", + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/zones/{zone_id}/tasks/transfer_requests", + 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/transfer_request/delete.rs b/sdk/dns/src/v2/zone/task/transfer_request/delete.rs new file mode 100644 index 000000000..fd43ed33b --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_request/delete.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// zone_transfer_request_id parameter for + /// /v2/zones/tasks/transfer_requests/{zone_transfer_request_id} API + #[builder(default, setter(into))] + zone_transfer_request_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 Transfer_Request. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = self.zone_transfer_request_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = "zone_transfer_request_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_transfer_request_id("zone_transfer_request_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = "zone_transfer_request_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_transfer_request_id("zone_transfer_request_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/transfer_request/get.rs b/sdk/dns/src/v2/zone/task/transfer_request/get.rs new file mode 100644 index 000000000..ef0d99d8c --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_request/get.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// zone_transfer_request_id parameter for + /// /v2/zones/tasks/transfer_requests/{zone_transfer_request_id} API + #[builder(default, setter(into))] + zone_transfer_request_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 Transfer_Request. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = self.zone_transfer_request_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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = "zone_transfer_request_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_transfer_request_id("zone_transfer_request_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = "zone_transfer_request_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_transfer_request_id("zone_transfer_request_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/transfer_request/list.rs b/sdk/dns/src/v2/zone/task/transfer_request/list.rs new file mode 100644 index 000000000..1fb151d76 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_request/list.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`. + +//! This will list all your outgoing requests, and any incoming requests that +//! have been scoped to your project. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Transfer_Request. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "zones/tasks/transfer_requests".to_string().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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/transfer_requests".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/zones/tasks/transfer_requests".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/dns/src/v2/zone/task/transfer_request/set.rs b/sdk/dns/src/v2/zone/task/transfer_request/set.rs new file mode 100644 index 000000000..56a6def01 --- /dev/null +++ b/sdk/dns/src/v2/zone/task/transfer_request/set.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// zone_transfer_request_id parameter for + /// /v2/zones/tasks/transfer_requests/{zone_transfer_request_id} API + #[builder(default, setter(into))] + zone_transfer_request_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Transfer_Request. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = self.zone_transfer_request_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH).path(format!( + "/zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = "zone_transfer_request_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .zone_transfer_request_id("zone_transfer_request_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!( + "/zones/tasks/transfer_requests/{zone_transfer_request_id}", + zone_transfer_request_id = "zone_transfer_request_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_transfer_request_id("zone_transfer_request_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/dns/v2/zone/task/xfr.rs b/sdk/dns/src/v2/zone/task/xfr.rs similarity index 99% rename from openstack_sdk/src/api/dns/v2/zone/task/xfr.rs rename to sdk/dns/src/v2/zone/task/xfr.rs index 6299a8dc9..d80cc61ae 100644 --- a/openstack_sdk/src/api/dns/v2/zone/task/xfr.rs +++ b/sdk/dns/src/v2/zone/task/xfr.rs @@ -143,7 +143,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/identity/Cargo.toml b/sdk/identity/Cargo.toml new file mode 100644 index 000000000..55adb5762 --- /dev/null +++ b/sdk/identity/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "openstack-sdk-identity" +description = "OpenStack SDK Identity service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +secrecy.workspace = true +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/identity/src/lib.rs b/sdk/identity/src/lib.rs new file mode 100644 index 000000000..25c571137 --- /dev/null +++ b/sdk/identity/src/lib.rs @@ -0,0 +1,17 @@ +// 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 +// +//! # OpenStack SDK `Identity` Service bindings +pub mod v3; +pub mod v4; diff --git a/openstack_sdk/src/api/identity/v3.rs b/sdk/identity/src/v3.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3.rs rename to sdk/identity/src/v3.rs diff --git a/openstack_sdk/src/api/identity/v3/auth.rs b/sdk/identity/src/v3/auth.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth.rs rename to sdk/identity/src/v3/auth.rs diff --git a/openstack_sdk/src/api/identity/v3/auth/catalog.rs b/sdk/identity/src/v3/auth/catalog.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/catalog.rs rename to sdk/identity/src/v3/auth/catalog.rs diff --git a/sdk/identity/src/v3/auth/catalog/head.rs b/sdk/identity/src/v3/auth/catalog/head.rs new file mode 100644 index 000000000..54496e444 --- /dev/null +++ b/sdk/identity/src/v3/auth/catalog/head.rs @@ -0,0 +1,171 @@ +// 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 service catalog for token. +//! +//! GET/HEAD /v3/auth/catalog +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Catalog. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/catalog".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/catalog".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/catalog".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/catalog/list.rs b/sdk/identity/src/v3/auth/catalog/list.rs new file mode 100644 index 000000000..368c403c0 --- /dev/null +++ b/sdk/identity/src/v3/auth/catalog/list.rs @@ -0,0 +1,187 @@ +// 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`. + +//! New in version 3.3 +//! +//! This call returns a service catalog for the X-Auth-Token provided in the +//! request, even if the token does not contain a catalog itself (for example, +//! if it was generated using ?nocatalog). +//! +//! The structure of the catalog object is identical to that contained in a +//! token. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_catalog` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Catalog. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/catalog".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("catalog".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "catalog" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/catalog".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "catalog": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/catalog".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "catalog": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/domain.rs b/sdk/identity/src/v3/auth/domain.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/domain.rs rename to sdk/identity/src/v3/auth/domain.rs diff --git a/sdk/identity/src/v3/auth/domain/head.rs b/sdk/identity/src/v3/auth/domain/head.rs new file mode 100644 index 000000000..c263b52fc --- /dev/null +++ b/sdk/identity/src/v3/auth/domain/head.rs @@ -0,0 +1,171 @@ +// 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 possible domain scopes for token. +//! +//! GET/HEAD /v3/auth/domains GET/HEAD /v3/OS-FEDERATION/domains +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/domains".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/domains".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/domains".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/domain/list.rs b/sdk/identity/src/v3/auth/domain/list.rs new file mode 100644 index 000000000..abf376cea --- /dev/null +++ b/sdk/identity/src/v3/auth/domain/list.rs @@ -0,0 +1,185 @@ +// 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`. + +//! New in version 3.3 +//! +//! This call returns the list of domains that are available to be scoped to +//! based on the X-Auth-Token provided in the request. +//! +//! The structure is the same as listing domains. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_domains` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/domains".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("domains".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "domains" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/domains".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domains": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/domains".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domains": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation.rs b/sdk/identity/src/v3/auth/os_federation.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/os_federation.rs rename to sdk/identity/src/v3/auth/os_federation.rs diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider.rs b/sdk/identity/src/v3/auth/os_federation/identity_provider.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider.rs rename to sdk/identity/src/v3/auth/os_federation/identity_provider.rs diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol.rs b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol.rs rename to sdk/identity/src/v3/auth/os_federation/identity_provider/protocol.rs diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso.rs b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/os_federation/identity_provider/protocol/websso.rs rename to sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso.rs diff --git a/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/create.rs b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/create.rs new file mode 100644 index 000000000..f71c06e3d --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/create.rs @@ -0,0 +1,210 @@ +// 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`. + +//! POST operation on +//! /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso + /// API + #[builder(default, setter(into))] + idp_id: Cow<'a, str>, + + /// protocol_id parameter for + /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso + /// API + #[builder(default, setter(into))] + protocol_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 Websso. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = self.idp_id.as_ref(), + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = "idp_id", + protocol_id = "protocol_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = "idp_id", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/get.rs b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/get.rs new file mode 100644 index 000000000..2bfab7dc2 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/get.rs @@ -0,0 +1,210 @@ +// 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 operation on +//! /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso + /// API + #[builder(default, setter(into))] + idp_id: Cow<'a, str>, + + /// protocol_id parameter for + /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso + /// API + #[builder(default, setter(into))] + protocol_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 Websso. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = self.idp_id.as_ref(), + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = "idp_id", + protocol_id = "protocol_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = "idp_id", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/head.rs b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/head.rs new file mode 100644 index 000000000..507a1e039 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/identity_provider/protocol/websso/head.rs @@ -0,0 +1,202 @@ +// 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`. + +//! HEAD operation on +//! /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso + /// API + #[builder(default, setter(into))] + idp_id: Cow<'a, str>, + + /// protocol_id parameter for + /// /v3/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso + /// API + #[builder(default, setter(into))] + protocol_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 Websso. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = self.idp_id.as_ref(), + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = "idp_id", + protocol_id = "protocol_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/auth/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/websso", + idp_id = "idp_id", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2.rs b/sdk/identity/src/v3/auth/os_federation/saml2.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/os_federation/saml2.rs rename to sdk/identity/src/v3/auth/os_federation/saml2.rs diff --git a/sdk/identity/src/v3/auth/os_federation/saml2/create.rs b/sdk/identity/src/v3/auth/os_federation/saml2/create.rs new file mode 100644 index 000000000..ef8d55a66 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/saml2/create.rs @@ -0,0 +1,555 @@ +// 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`. + +//! Exchange a scoped token for a SAML assertion. +//! +//! POST /v3/auth/OS-FEDERATION/saml2 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::serialize_sensitive_optional_string; +use openstack_sdk_core::api::common::serialize_sensitive_string; +use secrecy::SecretString; +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `domain` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Domain<'a> { + /// User Domain ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// User Domain Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// A user object, required if an application credential is identified by name +/// and not ID. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The user ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// An application credential object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ApplicationCredential<'a> { + /// The ID of the application credential used for authentication. If not + /// provided, the application credential must be identified by its name and + /// its owning user. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The name of the application credential used for authentication. If + /// provided, must be accompanied by a user object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The secret for authenticating the application credential. + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) secret: SecretString, + + /// A user object, required if an application credential is identified by + /// name and not ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Methods { + #[serde(rename = "application_credential")] + ApplicationCredential, + #[serde(rename = "password")] + Password, + #[serde(rename = "token")] + Token, + #[serde(rename = "totp")] + Totp, +} + +/// A `user` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PasswordUser<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The ID of the user. Required if you do not specify the user name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name. Required if you do not specify the ID of the user. If + /// you specify the user name, you must also specify the domain, by ID or + /// name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// User Password + #[serde( + serialize_with = "serialize_sensitive_optional_string", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) password: Option, +} + +/// The `password` object, contains the authentication information. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Password<'a> { + /// A `user` object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +/// A `token` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Token { + /// Authorization Token value + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) id: SecretString, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct TotpUser<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The user ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// MFA passcode + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) passcode: SecretString, +} + +/// Multi Factor Authentication information +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Totp<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) user: TotpUser<'a>, +} + +/// An `identity` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Identity<'a> { + /// An application credential object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) application_credential: Option>, + + /// The authentication method. For password authentication, specify + /// `password`. + #[serde()] + #[builder(setter(into))] + pub(crate) methods: Vec, + + /// The `password` object, contains the authentication information. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) password: Option>, + + /// A `token` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) token: Option, + + /// Multi Factor Authentication information + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) totp: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsTrustTrust<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ScopeDomain<'a> { + /// Domain id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Domain name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ProjectDomain<'a> { + /// Project domain Id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Project domain Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Project<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// Project Id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Project Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct System { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) all: Option, +} + +/// The authorization scope, including the system (Since v3.10), a project, or +/// a domain (Since v3.4). If multiple scopes are specified in the same request +/// (e.g. project and domain or domain and system) an HTTP 400 Bad Request will +/// be returned, as a token cannot be simultaneously scoped to multiple +/// authorization targets. An ID is sufficient to uniquely identify a project +/// but if a project is specified by name, then the domain of the project must +/// also be specified in order to uniquely identify the project by name. A +/// domain scope may be specified by either the domain’s ID or name with +/// equivalent results. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Scope<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde(rename = "OS-TRUST:trust", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) os_trust_trust: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) system: Option, +} + +/// An `auth` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Auth<'a> { + /// An `identity` object. + #[serde()] + #[builder(setter(into))] + pub(crate) identity: Identity<'a>, + + /// The authorization scope, including the system (Since v3.10), a project, + /// or a domain (Since v3.4). If multiple scopes are specified in the same + /// request (e.g. project and domain or domain and system) an HTTP 400 Bad + /// Request will be returned, as a token cannot be simultaneously scoped to + /// multiple authorization targets. An ID is sufficient to uniquely + /// identify a project but if a project is specified by name, then the + /// domain of the project must also be specified in order to uniquely + /// identify the project by name. A domain scope may be specified by either + /// the domain’s ID or name with equivalent results. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) scope: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `auth` object. + #[builder(setter(into))] + pub(crate) auth: Auth<'a>, + + #[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 Saml2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/OS-FEDERATION/saml2".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("auth", serde_json::to_value(&self.auth)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap() + ) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap() + ) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auth/OS-FEDERATION/saml2".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auth/OS-FEDERATION/saml2".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() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp.rs b/sdk/identity/src/v3/auth/os_federation/saml2/ecp.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/os_federation/saml2/ecp.rs rename to sdk/identity/src/v3/auth/os_federation/saml2/ecp.rs diff --git a/sdk/identity/src/v3/auth/os_federation/saml2/ecp/create.rs b/sdk/identity/src/v3/auth/os_federation/saml2/ecp/create.rs new file mode 100644 index 000000000..b49b31d66 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/saml2/ecp/create.rs @@ -0,0 +1,555 @@ +// 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`. + +//! Exchange a scoped token for an ECP assertion. +//! +//! POST /v3/auth/OS-FEDERATION/saml2/ecp +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::serialize_sensitive_optional_string; +use openstack_sdk_core::api::common::serialize_sensitive_string; +use secrecy::SecretString; +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `domain` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Domain<'a> { + /// User Domain ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// User Domain Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// A user object, required if an application credential is identified by name +/// and not ID. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The user ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// An application credential object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ApplicationCredential<'a> { + /// The ID of the application credential used for authentication. If not + /// provided, the application credential must be identified by its name and + /// its owning user. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The name of the application credential used for authentication. If + /// provided, must be accompanied by a user object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The secret for authenticating the application credential. + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) secret: SecretString, + + /// A user object, required if an application credential is identified by + /// name and not ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Methods { + #[serde(rename = "application_credential")] + ApplicationCredential, + #[serde(rename = "password")] + Password, + #[serde(rename = "token")] + Token, + #[serde(rename = "totp")] + Totp, +} + +/// A `user` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PasswordUser<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The ID of the user. Required if you do not specify the user name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name. Required if you do not specify the ID of the user. If + /// you specify the user name, you must also specify the domain, by ID or + /// name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// User Password + #[serde( + serialize_with = "serialize_sensitive_optional_string", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) password: Option, +} + +/// The `password` object, contains the authentication information. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Password<'a> { + /// A `user` object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +/// A `token` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Token { + /// Authorization Token value + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) id: SecretString, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct TotpUser<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The user ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// MFA passcode + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) passcode: SecretString, +} + +/// Multi Factor Authentication information +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Totp<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) user: TotpUser<'a>, +} + +/// An `identity` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Identity<'a> { + /// An application credential object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) application_credential: Option>, + + /// The authentication method. For password authentication, specify + /// `password`. + #[serde()] + #[builder(setter(into))] + pub(crate) methods: Vec, + + /// The `password` object, contains the authentication information. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) password: Option>, + + /// A `token` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) token: Option, + + /// Multi Factor Authentication information + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) totp: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsTrustTrust<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ScopeDomain<'a> { + /// Domain id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Domain name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ProjectDomain<'a> { + /// Project domain Id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Project domain Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Project<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// Project Id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Project Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct System { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) all: Option, +} + +/// The authorization scope, including the system (Since v3.10), a project, or +/// a domain (Since v3.4). If multiple scopes are specified in the same request +/// (e.g. project and domain or domain and system) an HTTP 400 Bad Request will +/// be returned, as a token cannot be simultaneously scoped to multiple +/// authorization targets. An ID is sufficient to uniquely identify a project +/// but if a project is specified by name, then the domain of the project must +/// also be specified in order to uniquely identify the project by name. A +/// domain scope may be specified by either the domain’s ID or name with +/// equivalent results. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Scope<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde(rename = "OS-TRUST:trust", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) os_trust_trust: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) system: Option, +} + +/// An `auth` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Auth<'a> { + /// An `identity` object. + #[serde()] + #[builder(setter(into))] + pub(crate) identity: Identity<'a>, + + /// The authorization scope, including the system (Since v3.10), a project, + /// or a domain (Since v3.4). If multiple scopes are specified in the same + /// request (e.g. project and domain or domain and system) an HTTP 400 Bad + /// Request will be returned, as a token cannot be simultaneously scoped to + /// multiple authorization targets. An ID is sufficient to uniquely + /// identify a project but if a project is specified by name, then the + /// domain of the project must also be specified in order to uniquely + /// identify the project by name. A domain scope may be specified by either + /// the domain’s ID or name with equivalent results. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) scope: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `auth` object. + #[builder(setter(into))] + pub(crate) auth: Auth<'a>, + + #[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 Ecp. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/OS-FEDERATION/saml2/ecp".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("auth", serde_json::to_value(&self.auth)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap() + ) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap() + ) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auth/OS-FEDERATION/saml2/ecp".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auth/OS-FEDERATION/saml2/ecp".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() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/saml2/ecp/get.rs b/sdk/identity/src/v3/auth/os_federation/saml2/ecp/get.rs new file mode 100644 index 000000000..e7d84cd92 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/saml2/ecp/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 operation on /v3/auth/OS-FEDERATION/saml2/ecp +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Ecp. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/OS-FEDERATION/saml2/ecp".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/OS-FEDERATION/saml2/ecp".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/OS-FEDERATION/saml2/ecp".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/saml2/ecp/head.rs b/sdk/identity/src/v3/auth/os_federation/saml2/ecp/head.rs new file mode 100644 index 000000000..e024e88a4 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/saml2/ecp/head.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`. + +//! HEAD operation on /v3/auth/OS-FEDERATION/saml2/ecp +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Ecp. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/OS-FEDERATION/saml2/ecp".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/OS-FEDERATION/saml2/ecp".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/OS-FEDERATION/saml2/ecp".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/saml2/get.rs b/sdk/identity/src/v3/auth/os_federation/saml2/get.rs new file mode 100644 index 000000000..b7973babc --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/saml2/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 operation on /v3/auth/OS-FEDERATION/saml2 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Saml2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/OS-FEDERATION/saml2".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/OS-FEDERATION/saml2".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/OS-FEDERATION/saml2".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/saml2/head.rs b/sdk/identity/src/v3/auth/os_federation/saml2/head.rs new file mode 100644 index 000000000..1854177c5 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/saml2/head.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`. + +//! HEAD operation on /v3/auth/OS-FEDERATION/saml2 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Saml2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/OS-FEDERATION/saml2".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/OS-FEDERATION/saml2".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/OS-FEDERATION/saml2".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/os_federation/websso.rs b/sdk/identity/src/v3/auth/os_federation/websso.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/os_federation/websso.rs rename to sdk/identity/src/v3/auth/os_federation/websso.rs diff --git a/sdk/identity/src/v3/auth/os_federation/websso/create.rs b/sdk/identity/src/v3/auth/os_federation/websso/create.rs new file mode 100644 index 000000000..7af3cf49f --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/websso/create.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`. + +//! POST operation on /v3/auth/OS-FEDERATION/websso/{protocol_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// protocol_id parameter for /v3/auth/OS-FEDERATION/websso/{protocol_id} + /// API + #[builder(default, setter(into))] + protocol_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 Websso. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = "protocol_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .protocol_id("protocol_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/websso/get.rs b/sdk/identity/src/v3/auth/os_federation/websso/get.rs new file mode 100644 index 000000000..7fd6f24de --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/websso/get.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`. + +//! GET operation on /v3/auth/OS-FEDERATION/websso/{protocol_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// protocol_id parameter for /v3/auth/OS-FEDERATION/websso/{protocol_id} + /// API + #[builder(default, setter(into))] + protocol_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 Websso. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = "protocol_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .protocol_id("protocol_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/os_federation/websso/head.rs b/sdk/identity/src/v3/auth/os_federation/websso/head.rs new file mode 100644 index 000000000..2fafa0055 --- /dev/null +++ b/sdk/identity/src/v3/auth/os_federation/websso/head.rs @@ -0,0 +1,189 @@ +// 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`. + +//! HEAD operation on /v3/auth/OS-FEDERATION/websso/{protocol_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// protocol_id parameter for /v3/auth/OS-FEDERATION/websso/{protocol_id} + /// API + #[builder(default, setter(into))] + protocol_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 Websso. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = "protocol_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .protocol_id("protocol_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/auth/OS-FEDERATION/websso/{protocol_id}", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/project.rs b/sdk/identity/src/v3/auth/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/project.rs rename to sdk/identity/src/v3/auth/project.rs diff --git a/openstack_sdk/src/api/identity/v3/auth/project/check.rs b/sdk/identity/src/v3/auth/project/check.rs similarity index 98% rename from openstack_sdk/src/api/identity/v3/auth/project/check.rs rename to sdk/identity/src/v3/auth/project/check.rs index 6bb0b2ba0..9a27f9a70 100644 --- a/openstack_sdk/src/api/identity/v3/auth/project/check.rs +++ b/sdk/identity/src/v3/auth/project/check.rs @@ -92,7 +92,7 @@ impl RestEndpoint for Request { mod tests { use super::*; use crate::api::{self, Query, RawQuery}; - use crate::test::client::MockServerClient; + use openstack_sdk_core::test::client::MockServerClient; use crate::types::ServiceType; use http::{HeaderName, HeaderValue}; use serde::Deserialize; diff --git a/sdk/identity/src/v3/auth/project/head.rs b/sdk/identity/src/v3/auth/project/head.rs new file mode 100644 index 000000000..c22c1935f --- /dev/null +++ b/sdk/identity/src/v3/auth/project/head.rs @@ -0,0 +1,171 @@ +// 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 possible project scopes for token. +//! +//! GET/HEAD /v3/auth/projects GET/HEAD /v3/OS-FEDERATION/projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/projects".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/projects".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/projects".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/project/list.rs b/sdk/identity/src/v3/auth/project/list.rs new file mode 100644 index 000000000..9da86ae12 --- /dev/null +++ b/sdk/identity/src/v3/auth/project/list.rs @@ -0,0 +1,186 @@ +// 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`. + +//! New in version 3.3 +//! +//! This call returns the list of projects that are available to be scoped to +//! based on the X-Auth-Token provided in the request. +//! +//! The structure of the response is exactly the same as listing projects for a +//! user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/projects".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("projects".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "projects" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/projects".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/projects".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/system.rs b/sdk/identity/src/v3/auth/system.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/system.rs rename to sdk/identity/src/v3/auth/system.rs diff --git a/sdk/identity/src/v3/auth/system/head.rs b/sdk/identity/src/v3/auth/system/head.rs new file mode 100644 index 000000000..d32f0d35f --- /dev/null +++ b/sdk/identity/src/v3/auth/system/head.rs @@ -0,0 +1,171 @@ +// 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 possible system scopes for token. +//! +//! GET/HEAD /v3/auth/system +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 System. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/system".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/system".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/system".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/system/list.rs b/sdk/identity/src/v3/auth/system/list.rs new file mode 100644 index 000000000..3456911cd --- /dev/null +++ b/sdk/identity/src/v3/auth/system/list.rs @@ -0,0 +1,183 @@ +// 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`. + +//! New in version 3.10 +//! +//! This call returns the list of systems that are available to be scoped to +//! based on the X-Auth-Token provided in the request. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_system` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 System. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/system".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("system".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "system" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/system".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "system": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/system".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "system": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/token.rs b/sdk/identity/src/v3/auth/token.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/token.rs rename to sdk/identity/src/v3/auth/token.rs diff --git a/sdk/identity/src/v3/auth/token/create.rs b/sdk/identity/src/v3/auth/token/create.rs new file mode 100644 index 000000000..b818150e2 --- /dev/null +++ b/sdk/identity/src/v3/auth/token/create.rs @@ -0,0 +1,562 @@ +// 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`. + +//! Authenticates an identity and generates a token. Uses the password +//! authentication method. Authorization is unscoped. +//! +//! The request body must include a payload that specifies the authentication +//! method, which is `password`, and the user, by ID or name, and password +//! credentials. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::serialize_sensitive_optional_string; +use openstack_sdk_core::api::common::serialize_sensitive_string; +use secrecy::SecretString; +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `domain` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Domain<'a> { + /// User Domain ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// User Domain Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// A user object, required if an application credential is identified by name +/// and not ID. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The user ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// An application credential object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ApplicationCredential<'a> { + /// The ID of the application credential used for authentication. If not + /// provided, the application credential must be identified by its name and + /// its owning user. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The name of the application credential used for authentication. If + /// provided, must be accompanied by a user object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The secret for authenticating the application credential. + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) secret: SecretString, + + /// A user object, required if an application credential is identified by + /// name and not ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Methods { + #[serde(rename = "application_credential")] + ApplicationCredential, + #[serde(rename = "password")] + Password, + #[serde(rename = "token")] + Token, + #[serde(rename = "totp")] + Totp, +} + +/// A `user` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PasswordUser<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The ID of the user. Required if you do not specify the user name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name. Required if you do not specify the ID of the user. If + /// you specify the user name, you must also specify the domain, by ID or + /// name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// User Password + #[serde( + serialize_with = "serialize_sensitive_optional_string", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) password: Option, +} + +/// The `password` object, contains the authentication information. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Password<'a> { + /// A `user` object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +/// A `token` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Token { + /// Authorization Token value + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) id: SecretString, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct TotpUser<'a> { + /// A `domain` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// The user ID + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The user name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// MFA passcode + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) passcode: SecretString, +} + +/// Multi Factor Authentication information +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Totp<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) user: TotpUser<'a>, +} + +/// An `identity` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Identity<'a> { + /// An application credential object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) application_credential: Option>, + + /// The authentication method. For password authentication, specify + /// `password`. + #[serde()] + #[builder(setter(into))] + pub(crate) methods: Vec, + + /// The `password` object, contains the authentication information. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) password: Option>, + + /// A `token` object + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) token: Option, + + /// Multi Factor Authentication information + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) totp: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct OsTrustTrust<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ScopeDomain<'a> { + /// Domain id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Domain name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ProjectDomain<'a> { + /// Project domain Id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Project domain Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Project<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + /// Project Id + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Project Name + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct System { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) all: Option, +} + +/// The authorization scope, including the system (Since v3.10), a project, or +/// a domain (Since v3.4). If multiple scopes are specified in the same request +/// (e.g. project and domain or domain and system) an HTTP 400 Bad Request will +/// be returned, as a token cannot be simultaneously scoped to multiple +/// authorization targets. An ID is sufficient to uniquely identify a project +/// but if a project is specified by name, then the domain of the project must +/// also be specified in order to uniquely identify the project by name. A +/// domain scope may be specified by either the domain’s ID or name with +/// equivalent results. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Scope<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde(rename = "OS-TRUST:trust", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) os_trust_trust: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) system: Option, +} + +/// An `auth` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Auth<'a> { + /// An `identity` object. + #[serde()] + #[builder(setter(into))] + pub(crate) identity: Identity<'a>, + + /// The authorization scope, including the system (Since v3.10), a project, + /// or a domain (Since v3.4). If multiple scopes are specified in the same + /// request (e.g. project and domain or domain and system) an HTTP 400 Bad + /// Request will be returned, as a token cannot be simultaneously scoped to + /// multiple authorization targets. An ID is sufficient to uniquely + /// identify a project but if a project is specified by name, then the + /// domain of the project must also be specified in order to uniquely + /// identify the project by name. A domain scope may be specified by either + /// the domain’s ID or name with equivalent results. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) scope: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `auth` object. + #[builder(setter(into))] + pub(crate) auth: Auth<'a>, + + #[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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("auth", serde_json::to_value(&self.auth)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap() + ) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap() + ) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auth/tokens".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auth/tokens".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .auth( + AuthBuilder::default() + .identity( + IdentityBuilder::default() + .methods(Vec::from([Methods::ApplicationCredential])) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/token/delete.rs b/sdk/identity/src/v3/auth/token/delete.rs new file mode 100644 index 000000000..bc2bff454 --- /dev/null +++ b/sdk/identity/src/v3/auth/token/delete.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Revokes a token. +//! +//! This call is similar to the HEAD `/auth/tokens` call except that the +//! `X-Subject-Token` token is immediately not valid, regardless of the +//! `expires_at` attribute value. An additional `X-Auth-Token` is not required. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/auth/tokens".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/auth/tokens".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/token/get.rs b/sdk/identity/src/v3/auth/token/get.rs new file mode 100644 index 000000000..e45a5e256 --- /dev/null +++ b/sdk/identity/src/v3/auth/token/get.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Validates and shows information for a token, including its expiration date +//! and authorization scope. +//! +//! Pass your own token in the `X-Auth-Token` request header. +//! +//! Pass the token that you want to validate in the `X-Subject-Token` request +//! header. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/tokens".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/tokens".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/token/head.rs b/sdk/identity/src/v3/auth/token/head.rs new file mode 100644 index 000000000..927b23825 --- /dev/null +++ b/sdk/identity/src/v3/auth/token/head.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`. + +//! Validates a token. +//! +//! This call is similar to `GET /auth/tokens` but no response body is provided +//! even in the `X-Subject-Token` header. +//! +//! The Identity API returns the same response as when the subject token was +//! issued by `POST /auth/tokens` even if an error occurs because the token is +//! not valid. An HTTP `204` response code indicates that the `X-Subject-Token` +//! is valid. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/tokens".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/tokens".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/auth/token/os_pki.rs b/sdk/identity/src/v3/auth/token/os_pki.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/token/os_pki.rs rename to sdk/identity/src/v3/auth/token/os_pki.rs diff --git a/openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked.rs b/sdk/identity/src/v3/auth/token/os_pki/revoked.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/auth/token/os_pki/revoked.rs rename to sdk/identity/src/v3/auth/token/os_pki/revoked.rs diff --git a/sdk/identity/src/v3/auth/token/os_pki/revoked/get.rs b/sdk/identity/src/v3/auth/token/os_pki/revoked/get.rs new file mode 100644 index 000000000..7589c0a01 --- /dev/null +++ b/sdk/identity/src/v3/auth/token/os_pki/revoked/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`. + +//! Lists revoked PKI tokens. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/tokens/OS-PKI/revoked` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Revoked. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auth/tokens/OS-PKI/revoked".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/tokens/OS-PKI/revoked".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auth/tokens/OS-PKI/revoked".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/auth/token/os_pki/revoked/head.rs b/sdk/identity/src/v3/auth/token/os_pki/revoked/head.rs new file mode 100644 index 000000000..ccfc31208 --- /dev/null +++ b/sdk/identity/src/v3/auth/token/os_pki/revoked/head.rs @@ -0,0 +1,171 @@ +// 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`. + +//! Deprecated; get revoked token list. +//! +//! GET/HEAD /v3/auth/tokens/OS-PKI/revoked +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Revoked. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "auth/tokens/OS-PKI/revoked".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/tokens/OS-PKI/revoked".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/auth/tokens/OS-PKI/revoked".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/credential.rs b/sdk/identity/src/v3/credential.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/credential.rs rename to sdk/identity/src/v3/credential.rs diff --git a/sdk/identity/src/v3/credential/create.rs b/sdk/identity/src/v3/credential/create.rs new file mode 100644 index 000000000..89e3fa9d6 --- /dev/null +++ b/sdk/identity/src/v3/credential/create.rs @@ -0,0 +1,294 @@ +// 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`. + +//! Creates a credential. +//! +//! The following example shows how to create an EC2-style credential. The +//! credential blob is a string that contains a JSON-serialized dictionary with +//! the `access` and `secret` keys. This format is required when you specify +//! the `ec2` type. To specify other credentials, such as `access_key`, change +//! the type and contents of the data blob. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/credentials` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `credential` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Credential<'a> { + /// The credential itself, as a serialized blob. + #[serde()] + #[builder(setter(into))] + pub(crate) blob: Cow<'a, str>, + + /// The UUID for the credential. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The ID for the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>>, + + /// The credential type, such as `ec2` or `cert`. The implementation + /// determines the list of supported types. + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, + + /// The ID of the user who owns the credential. + #[serde()] + #[builder(setter(into))] + pub(crate) user_id: Cow<'a, str>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> CredentialBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `credential` object. + #[builder(setter(into))] + pub(crate) credential: Credential<'a>, + + #[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 Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "credentials".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("credential", serde_json::to_value(&self.credential)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("credential".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .credential( + CredentialBuilder::default() + ._type("foo") + .blob("foo") + .user_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .credential( + CredentialBuilder::default() + ._type("foo") + .blob("foo") + .user_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "credential" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/credentials".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credential": {} })); + }); + + let endpoint = Request::builder() + .credential( + CredentialBuilder::default() + ._type("foo") + .blob("foo") + .user_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/credentials".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credential": {} })); + }); + + let endpoint = Request::builder() + .credential( + CredentialBuilder::default() + ._type("foo") + .blob("foo") + .user_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/credential/delete.rs b/sdk/identity/src/v3/credential/delete.rs new file mode 100644 index 000000000..1a0a2d7aa --- /dev/null +++ b/sdk/identity/src/v3/credential/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes a credential. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/credential` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { + /// Add a single header to the Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("credentials/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/credentials/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/credentials/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/credential/get.rs b/sdk/identity/src/v3/credential/get.rs new file mode 100644 index 000000000..587f43495 --- /dev/null +++ b/sdk/identity/src/v3/credential/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a credential. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/credential` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { + /// Add a single header to the Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("credentials/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("credential".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "credential" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/credentials/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credential": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/credentials/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credential": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/credential/head.rs b/sdk/identity/src/v3/credential/head.rs new file mode 100644 index 000000000..2ba3c3e0b --- /dev/null +++ b/sdk/identity/src/v3/credential/head.rs @@ -0,0 +1,178 @@ +// 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 existing credentials. +//! +//! GET /v3/credentials/{credential_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { + /// Add a single header to the Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("credentials/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/credentials/{id}", id = "id",)); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/credentials/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/credential/list.rs b/sdk/identity/src/v3/credential/list.rs new file mode 100644 index 000000000..19d6a3e78 --- /dev/null +++ b/sdk/identity/src/v3/credential/list.rs @@ -0,0 +1,198 @@ +// 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`. + +//! Lists all credentials. +//! +//! Optionally, you can include the `user_id` or `type` query parameter in the +//! URI to filter the response by a user or credential type. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/credentials` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The credential type, such as ec2 or cert. The implementation determines + /// the list of supported types. + #[builder(default, setter(into))] + _type: Option>, + + /// Filters the response by a user ID. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "credentials".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("type", self._type.as_ref()); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("credentials".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "credentials" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/credentials".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credentials": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/credentials".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credentials": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/credential/set.rs b/sdk/identity/src/v3/credential/set.rs new file mode 100644 index 000000000..36333670f --- /dev/null +++ b/sdk/identity/src/v3/credential/set.rs @@ -0,0 +1,261 @@ +// 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`. + +//! Updates a credential. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/credential` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `credential` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Credential<'a> { + /// The credential itself, as a serialized blob. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) blob: Option>, + + /// The ID for the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>>, + + /// The credential type, such as `ec2` or `cert`. The implementation + /// determines the list of supported types. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _type: Option>, + + /// The ID of the user who owns the credential. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user_id: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> CredentialBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `credential` object. + #[builder(setter(into))] + pub(crate) credential: Credential<'a>, + + /// credential_id parameter for /v3/credentials/{credential_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<'a> RequestBuilder<'a> { + /// Add a single header to the Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("credentials/{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("credential", serde_json::to_value(&self.credential)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("credential".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .credential(CredentialBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .credential(CredentialBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "credential" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/credentials/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credential": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .credential(CredentialBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/credentials/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "credential": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .credential(CredentialBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/domain.rs b/sdk/identity/src/v3/domain.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain.rs rename to sdk/identity/src/v3/domain.rs diff --git a/openstack_sdk/src/api/identity/v3/domain/config.rs b/sdk/identity/src/v3/domain/config.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain/config.rs rename to sdk/identity/src/v3/domain/config.rs diff --git a/sdk/identity/src/v3/domain/config/default.rs b/sdk/identity/src/v3/domain/config/default.rs new file mode 100644 index 000000000..a780ce97b --- /dev/null +++ b/sdk/identity/src/v3/domain/config/default.rs @@ -0,0 +1,181 @@ +// 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`. + +//! The default configuration settings for the options that can be overridden +//! can be retrieved. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Config. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "domains/config/default".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/domains/config/default".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/domains/config/default".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/delete_all.rs b/sdk/identity/src/v3/domain/config/delete_all.rs new file mode 100644 index 000000000..409dd69a2 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/delete_all.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Deletes a domain configuration. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_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 Config. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config", + domain_id = self.domain_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().domain_id("domain_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_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() + .domain_id("domain_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group.rs b/sdk/identity/src/v3/domain/config/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain/config/group.rs rename to sdk/identity/src/v3/domain/config/group.rs diff --git a/sdk/identity/src/v3/domain/config/group/default.rs b/sdk/identity/src/v3/domain/config/group/default.rs new file mode 100644 index 000000000..d7709e10e --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/default.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Reads the default configuration settings for a specific group. +//! +//! The API supports only the `identity` and `ldap` groups. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group parameter for /v3/domains/config/{group}/{option}/default API + #[builder(default, setter(into))] + group: 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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/config/{group}/default", + group = self.group.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/domains/config/{group}/default", group = "group",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder().group("group").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/domains/config/{group}/default", group = "group",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .group("group") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/delete.rs b/sdk/identity/src/v3/domain/config/group/delete.rs new file mode 100644 index 000000000..9cc9430a2 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/delete.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`. + +//! Deletes a domain group configuration. +//! +//! The API supports only the `identity` and `ldap` groups. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: 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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config/{group}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/get.rs b/sdk/identity/src/v3/domain/config/group/get.rs new file mode 100644 index 000000000..fcb11b4a4 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/get.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`. + +//! Shows details for a domain group configuration. +//! +//! The API supports only the `identity` and `ldap` groups. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: 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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config/{group}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/head.rs b/sdk/identity/src/v3/domain/config/group/head.rs new file mode 100644 index 000000000..fbd5c99d4 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/head.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Check if config option exists. +//! +//! GET/HEAD /v3/domains/{domain_id}/config GET/HEAD +//! /v3/domains/{domain_id}/config/{group} GET/HEAD +//! /v3/domains/{domain_id}/config/{group}/{option} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: 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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/config/{group}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/domain/config/group/option.rs b/sdk/identity/src/v3/domain/config/group/option.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain/config/group/option.rs rename to sdk/identity/src/v3/domain/config/group/option.rs diff --git a/sdk/identity/src/v3/domain/config/group/option/default.rs b/sdk/identity/src/v3/domain/config/group/option/default.rs new file mode 100644 index 000000000..455e03e6a --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/option/default.rs @@ -0,0 +1,212 @@ +// 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`. + +//! Reads the default configuration setting for an option within a group. +//! +//! The API supports only the `identity` and `ldap` groups. For the `ldap` +//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, +//! a valid value is `driver`. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group parameter for /v3/domains/config/{group}/{option}/default API + #[builder(default, setter(into))] + group: Cow<'a, str>, + + /// option parameter for /v3/domains/config/{group}/{option}/default API + #[builder(default, setter(into))] + option: 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 Option. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/config/{group}/{option}/default", + group = self.group.as_ref(), + option = self.option.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/config/{group}/{option}/default", + group = "group", + option = "option", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .group("group") + .option("option") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/config/{group}/{option}/default", + group = "group", + option = "option", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .group("group") + .option("option") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/option/delete.rs b/sdk/identity/src/v3/domain/config/group/option/delete.rs new file mode 100644 index 000000000..261821c56 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/option/delete.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Deletes a domain group option configuration. +//! +//! The API supports only the `identity` and `ldap` groups. For the `ldap` +//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, +//! a valid value is `driver`. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: Cow<'a, str>, + + /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + option: 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 Option. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config/{group}/{option}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + option = self.option.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/option/get.rs b/sdk/identity/src/v3/domain/config/group/option/get.rs new file mode 100644 index 000000000..188a22861 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/option/get.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Shows details for a domain group option configuration. +//! +//! The API supports only the `identity` and `ldap` groups. For the `ldap` +//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, +//! a valid value is `driver`. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: Cow<'a, str>, + + /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + option: 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 Option. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config/{group}/{option}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + option = self.option.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/option/head.rs b/sdk/identity/src/v3/domain/config/group/option/head.rs new file mode 100644 index 000000000..0af8cb76c --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/option/head.rs @@ -0,0 +1,215 @@ +// 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`. + +//! Check if config option exists. +//! +//! GET/HEAD /v3/domains/{domain_id}/config GET/HEAD +//! /v3/domains/{domain_id}/config/{group} GET/HEAD +//! /v3/domains/{domain_id}/config/{group}/{option} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: Cow<'a, str>, + + /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + option: 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 Option. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/config/{group}/{option}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + option = self.option.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/option/set.rs b/sdk/identity/src/v3/domain/config/group/option/set.rs new file mode 100644 index 000000000..02123bbb1 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/option/set.rs @@ -0,0 +1,261 @@ +// 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`. + +//! Updates a domain group option configuration. +//! +//! The API supports only the `identity` and `ldap` groups. For the `ldap` +//! group, a valid value is `url` or `user_tree_dn`. For the `identity` group, +//! a valid value is `driver`. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `config` object. + #[builder(private, setter(into, name = "_config"))] + pub(crate) config: BTreeMap, Value>, + + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: Cow<'a, str>, + + /// option parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + option: 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> { + /// A `config` object. + pub fn config(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.config + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Option. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config/{group}/{option}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + option = self.option.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("config", serde_json::to_value(&self.config)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .config(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .config(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH).path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .config(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!( + "/domains/{domain_id}/config/{group}/{option}", + domain_id = "domain_id", + group = "group", + option = "option", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .option("option") + .config(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/group/set.rs b/sdk/identity/src/v3/domain/config/group/set.rs new file mode 100644 index 000000000..d66d5b59d --- /dev/null +++ b/sdk/identity/src/v3/domain/config/group/set.rs @@ -0,0 +1,274 @@ +// 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`. + +//! Updates a domain group configuration. +//! +//! The API supports only the `identity` and `ldap` groups. If you try to set +//! configuration options for other groups, this call fails with the +//! `Forbidden (403)` response code. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config_default` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `config` object. + #[builder(private, setter(into, name = "_config"))] + pub(crate) config: BTreeMap, BTreeMap, Value>>, + + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group parameter for /v3/domains/{domain_id}/config/{group}/{option} API + #[builder(default, setter(into))] + group: 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> { + /// A `config` object. + pub fn config(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Iterator, + K1: Into>, + V1: Into, + { + self.config + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| { + ( + k.into(), + BTreeMap::from_iter(v.into_iter().map(|(k1, v1)| (k1.into(), v1.into()))), + ) + })); + self + } + + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config/{group}", + domain_id = self.domain_id.as_ref(), + group = self.group.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("config", serde_json::to_value(&self.config)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())) + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())) + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH).path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!( + "/domains/{domain_id}/config/{group}", + domain_id = "domain_id", + group = "group", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group("group") + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/head.rs b/sdk/identity/src/v3/domain/config/head.rs new file mode 100644 index 000000000..6fe8e4eb1 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/head.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Check if config option exists. +//! +//! GET/HEAD /v3/domains/{domain_id}/config GET/HEAD +//! /v3/domains/{domain_id}/config/{group} GET/HEAD +//! /v3/domains/{domain_id}/config/{group}/{option} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_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 Config. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/config", + domain_id = self.domain_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().domain_id("domain_id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/list.rs b/sdk/identity/src/v3/domain/config/list.rs new file mode 100644 index 000000000..2239f11de --- /dev/null +++ b/sdk/identity/src/v3/domain/config/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`. + +//! Shows details for a domain configuration. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_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 Config. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config", + domain_id = self.domain_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder().domain_id("domain_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/replace.rs b/sdk/identity/src/v3/domain/config/replace.rs new file mode 100644 index 000000000..9449f4bc5 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/replace.rs @@ -0,0 +1,261 @@ +// 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`. + +//! Creates a domain configuration. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `config` object. + #[builder(private, setter(into, name = "_config"))] + pub(crate) config: BTreeMap, BTreeMap, Value>>, + + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_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> { + /// A `config` object. + pub fn config(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Iterator, + K1: Into>, + V1: Into, + { + self.config + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| { + ( + k.into(), + BTreeMap::from_iter(v.into_iter().map(|(k1, v1)| (k1.into(), v1.into()))), + ) + })); + self + } + + /// Add a single header to the Config. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/config", + domain_id = self.domain_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("config", serde_json::to_value(&self.config)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())) + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())) + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/config/set.rs b/sdk/identity/src/v3/domain/config/set.rs new file mode 100644 index 000000000..546feb8d9 --- /dev/null +++ b/sdk/identity/src/v3/domain/config/set.rs @@ -0,0 +1,261 @@ +// 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`. + +//! Updates a domain configuration. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_config` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `config` object. + #[builder(private, setter(into, name = "_config"))] + pub(crate) config: BTreeMap, BTreeMap, Value>>, + + /// domain_id parameter for /v3/domains/{domain_id}/config/{group}/{option} + /// API + #[builder(default, setter(into))] + domain_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> { + /// A `config` object. + pub fn config(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Iterator, + K1: Into>, + V1: Into, + { + self.config + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| { + ( + k.into(), + BTreeMap::from_iter(v.into_iter().map(|(k1, v1)| (k1.into(), v1.into()))), + ) + })); + self + } + + /// Add a single header to the Config. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/config", + domain_id = self.domain_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("config", serde_json::to_value(&self.config)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("config".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())) + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())) + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "config" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH).path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!( + "/domains/{domain_id}/config", + domain_id = "domain_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "config": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .config( + BTreeMap::>::new() + .into_iter() + .map(|(k, v)| (k, v.into_iter())), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/create.rs b/sdk/identity/src/v3/domain/create.rs new file mode 100644 index 000000000..5e3b39a8f --- /dev/null +++ b/sdk/identity/src/v3/domain/create.rs @@ -0,0 +1,263 @@ +// 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`. + +//! Creates a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domains` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The resource options for the domain. Available resource options are +/// `immutable`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) immutable: Option, +} + +/// A `domain` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Domain<'a> { + /// The description of the domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// If set to `true`, domain is created enabled. If set to `false`, domain + /// is created disabled. The default is `true`. + /// + /// Users can only authorize against an enabled domain (and any of its + /// projects). In addition, users can only authenticate if the domain that + /// owns them is also enabled. Disabling a domain prevents both of these + /// things. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The ID of the domain. A domain created this way will not use an + /// auto-generated ID, but will use the ID passed in instead. Identifiers + /// passed in this way must conform to the existing ID generation scheme: + /// UUID4 without dashes. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) explicit_domain_id: Option>, + + /// The name of the domain. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The resource options for the domain. Available resource options are + /// `immutable`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `domain` object + #[builder(setter(into))] + pub(crate) domain: Domain<'a>, + + #[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 Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "domains".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("domain", serde_json::to_value(&self.domain)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("domain".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .domain(DomainBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .domain(DomainBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "domain" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/domains".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domain": {} })); + }); + + let endpoint = Request::builder() + .domain(DomainBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/domains".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domain": {} })); + }); + + let endpoint = Request::builder() + .domain(DomainBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/delete.rs b/sdk/identity/src/v3/domain/delete.rs new file mode 100644 index 000000000..bb0ab0f60 --- /dev/null +++ b/sdk/identity/src/v3/domain/delete.rs @@ -0,0 +1,192 @@ +// 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`. + +//! Deletes a domain. To minimize the risk of accidentally deleting a domain, +//! you must first disable the domain by using the update domain method. +//! +//! When you delete a domain, this call also deletes all entities owned by it, +//! such as users, groups, and projects, and any credentials and granted roles +//! that relate to those entities. +//! +//! If you try to delete an enabled domain, this call returns the +//! `Forbidden (403)` response code. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { + /// Add a single header to the Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("domains/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/domains/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/domains/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/find.rs b/sdk/identity/src/v3/domain/find.rs new file mode 100644 index 000000000..ed0fb439d --- /dev/null +++ b/sdk/identity/src/v3/domain/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v3::domain::{get as Get, list as List}; + +/// Find for domain 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/identity/src/v3/domain/get.rs b/sdk/identity/src/v3/domain/get.rs new file mode 100644 index 000000000..b1af72ad7 --- /dev/null +++ b/sdk/identity/src/v3/domain/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domains` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { + /// Add a single header to the Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("domains/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("domain".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "domain" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/domains/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domain": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/domains/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domain": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/domain/group.rs b/sdk/identity/src/v3/domain/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain/group.rs rename to sdk/identity/src/v3/domain/group.rs diff --git a/openstack_sdk/src/api/identity/v3/domain/group/role.rs b/sdk/identity/src/v3/domain/group/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain/group/role.rs rename to sdk/identity/src/v3/domain/group/role.rs diff --git a/sdk/identity/src/v3/domain/group/role/delete.rs b/sdk/identity/src/v3/domain/group/role/delete.rs new file mode 100644 index 000000000..95d6d2b8e --- /dev/null +++ b/sdk/identity/src/v3/domain/group/role/delete.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Unassigns a role from a group on a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_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() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/group/role/get.rs b/sdk/identity/src/v3/domain/group/role/get.rs new file mode 100644 index 000000000..c3df8332c --- /dev/null +++ b/sdk/identity/src/v3/domain/group/role/get.rs @@ -0,0 +1,216 @@ +// 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`. + +//! Check if a group has a specific role on a domain. +//! +//! GET/HEAD /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_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() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/group/role/head.rs b/sdk/identity/src/v3/domain/group/role/head.rs new file mode 100644 index 000000000..9b9653d30 --- /dev/null +++ b/sdk/identity/src/v3/domain/group/role/head.rs @@ -0,0 +1,212 @@ +// 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`. + +//! Validates that a group has a role assignment on a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_id", + id = "id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/group/role/list.rs b/sdk/identity/src/v3/domain/group/role/list.rs new file mode 100644 index 000000000..67baf8c0f --- /dev/null +++ b/sdk/identity/src/v3/domain/group/role/list.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Lists role assignments for a group on a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_roles` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/groups/{group_id}/roles", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("roles".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "roles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/{domain_id}/groups/{group_id}/roles", + domain_id = "domain_id", + group_id = "group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/{domain_id}/groups/{group_id}/roles", + domain_id = "domain_id", + group_id = "group_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/group/role/set.rs b/sdk/identity/src/v3/domain/group/role/set.rs new file mode 100644 index 000000000..0b07e2315 --- /dev/null +++ b/sdk/identity/src/v3/domain/group/role/set.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Assigns a role to a group on a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/domains/{domain_id}/groups/{group_id}/roles/{id}", + domain_id = "domain_id", + group_id = "group_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() + .domain_id("domain_id") + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/head.rs b/sdk/identity/src/v3/domain/head.rs new file mode 100644 index 000000000..744b7da2f --- /dev/null +++ b/sdk/identity/src/v3/domain/head.rs @@ -0,0 +1,178 @@ +// 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 domain +//! +//! GET/HEAD /v3/domains/{domain_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { + /// Add a single header to the Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("domains/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/domains/{id}", id = "id",)); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/domains/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/list.rs b/sdk/identity/src/v3/domain/list.rs new file mode 100644 index 000000000..895458648 --- /dev/null +++ b/sdk/identity/src/v3/domain/list.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`. + +//! Lists all domains. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domains` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// If set to true, then only domains that are enabled will be returned, if + /// set to false only that are disabled will be returned. Any value other + /// than 0, including no value, will be interpreted as true. + #[builder(default)] + enabled: Option, + + #[builder(default)] + limit: Option, + + /// ID of the last fetched entry + #[builder(default, setter(into))] + marker: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "domains".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("enabled", self.enabled); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("domains".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "domains" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/domains".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domains": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/domains".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domains": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/set.rs b/sdk/identity/src/v3/domain/set.rs new file mode 100644 index 000000000..060583b6a --- /dev/null +++ b/sdk/identity/src/v3/domain/set.rs @@ -0,0 +1,263 @@ +// 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`. + +//! Updates a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The resource options for the domain. Available resource options are +/// `immutable`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) immutable: Option, +} + +/// A `domain` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Domain<'a> { + /// The new description of the domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// If set to `true`, domain is enabled. If set to `false`, domain is + /// disabled. The default is `true`. + /// + /// Users can only authorize against an enabled domain (and any of its + /// projects). In addition, users can only authenticate if the domain that + /// owns them is also enabled. Disabling a domain prevents both of these + /// things. When you disable a domain, all tokens that are authorized for + /// that domain become invalid. However, if you reenable the domain, these + /// tokens become valid again, providing that they haven’t expired. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The new name of the domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The resource options for the domain. Available resource options are + /// `immutable`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `domain` object + #[builder(setter(into))] + pub(crate) domain: Domain<'a>, + + /// domain_id parameter for /v3/domains/{domain_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<'a> RequestBuilder<'a> { + /// Add a single header to the Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("domains/{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("domain", serde_json::to_value(&self.domain)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("domain".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .domain(DomainBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .domain(DomainBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "domain" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/domains/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domain": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .domain(DomainBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/domains/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domain": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .domain(DomainBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/domain/user.rs b/sdk/identity/src/v3/domain/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain/user.rs rename to sdk/identity/src/v3/domain/user.rs diff --git a/openstack_sdk/src/api/identity/v3/domain/user/role.rs b/sdk/identity/src/v3/domain/user/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/domain/user/role.rs rename to sdk/identity/src/v3/domain/user/role.rs diff --git a/sdk/identity/src/v3/domain/user/role/delete.rs b/sdk/identity/src/v3/domain/user/role/delete.rs new file mode 100644 index 000000000..46132961a --- /dev/null +++ b/sdk/identity/src/v3/domain/user/role/delete.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Unassigns a role from a user on a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_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() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/user/role/get.rs b/sdk/identity/src/v3/domain/user/role/get.rs new file mode 100644 index 000000000..aae834494 --- /dev/null +++ b/sdk/identity/src/v3/domain/user/role/get.rs @@ -0,0 +1,216 @@ +// 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`. + +//! Check if a user has a specific role on the domain. +//! +//! GET/HEAD /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_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() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/user/role/head.rs b/sdk/identity/src/v3/domain/user/role/head.rs new file mode 100644 index 000000000..91e502530 --- /dev/null +++ b/sdk/identity/src/v3/domain/user/role/head.rs @@ -0,0 +1,212 @@ +// 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`. + +//! Validates that a user has a role assignment on a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/user/role/list.rs b/sdk/identity/src/v3/domain/user/role/list.rs new file mode 100644 index 000000000..5bf169e87 --- /dev/null +++ b/sdk/identity/src/v3/domain/user/role/list.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Lists role assignments for a user on a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/domain_user_roles` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "domains/{domain_id}/users/{user_id}/roles", + domain_id = self.domain_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("roles".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "roles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/domains/{domain_id}/users/{user_id}/roles", + domain_id = "domain_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/domains/{domain_id}/users/{user_id}/roles", + domain_id = "domain_id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/domain/user/role/set.rs b/sdk/identity/src/v3/domain/user/role/set.rs new file mode 100644 index 000000000..26a8c27e0 --- /dev/null +++ b/sdk/identity/src/v3/domain/user/role/set.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Assigns a role to a user on a domain. +//! +//! Relationship: +//! `https://developer.openstack.org/api-ref/identity/v3/index.html#assign-role-to-user-on-domain` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/domains/{domain_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = self.domain_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/domains/{domain_id}/users/{user_id}/roles/{id}", + domain_id = "domain_id", + id = "id", + user_id = "user_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() + .domain_id("domain_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/ec2token.rs b/sdk/identity/src/v3/ec2token.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/ec2token.rs rename to sdk/identity/src/v3/ec2token.rs diff --git a/sdk/identity/src/v3/ec2token/create.rs b/sdk/identity/src/v3/ec2token/create.rs new file mode 100644 index 000000000..fb29f5065 --- /dev/null +++ b/sdk/identity/src/v3/ec2token/create.rs @@ -0,0 +1,204 @@ +// 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`. + +//! Authenticate ec2 token. +//! +//! POST /v3/ec2tokens +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Ec2Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "ec2tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/ec2tokens".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/ec2tokens".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/ec2token/get.rs b/sdk/identity/src/v3/ec2token/get.rs new file mode 100644 index 000000000..287f1791c --- /dev/null +++ b/sdk/identity/src/v3/ec2token/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 operation on /v3/ec2tokens +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Ec2Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "ec2tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/ec2tokens".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/ec2tokens".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/ec2token/head.rs b/sdk/identity/src/v3/ec2token/head.rs new file mode 100644 index 000000000..6cc95254b --- /dev/null +++ b/sdk/identity/src/v3/ec2token/head.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`. + +//! HEAD operation on /v3/ec2tokens +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Ec2Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "ec2tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/ec2tokens".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/ec2tokens".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/endpoint.rs b/sdk/identity/src/v3/endpoint.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/endpoint.rs rename to sdk/identity/src/v3/endpoint.rs diff --git a/sdk/identity/src/v3/endpoint/create.rs b/sdk/identity/src/v3/endpoint/create.rs new file mode 100644 index 000000000..a4cffae97 --- /dev/null +++ b/sdk/identity/src/v3/endpoint/create.rs @@ -0,0 +1,328 @@ +// 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`. + +//! Creates an endpoint. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoints` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Interface { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "internal")] + Internal, + #[serde(rename = "public")] + Public, +} + +/// An `endpoint` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Endpoint<'a> { + /// The endpoint description. It is returned only when set on the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Defines whether the endpoint appears in the service catalog: - `false`. + /// The endpoint does not appear in the service catalog. - `true`. The + /// endpoint appears in the service catalog. Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The endpoint ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The interface type, which describes the visibility of the endpoint. + /// Value is: - `public`. Visible by end users on a publicly available + /// network interface. - `internal`. Visible by end users on an unmetered + /// internal network interface. - `admin`. Visible by administrative users + /// on a secure network interface. + #[serde()] + #[builder()] + pub(crate) interface: Interface, + + /// (Deprecated) The endpoint name. The field will only be returned in + /// responses when set on the resource. + /// + /// This field is deprecated as it provides no value. Endpoints are better + /// described by the combination of service, region and interface they + /// describe or by their ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// (Deprecated in v3.2) The geographic location of the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region: Option>>, + + /// (Since v3.2) The ID of the region that contains the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region_id: Option>>, + + /// The UUID of the service to which the endpoint belongs. + #[serde()] + #[builder(setter(into))] + pub(crate) service_id: Cow<'a, str>, + + /// The endpoint URL. + #[serde()] + #[builder(setter(into))] + pub(crate) url: Cow<'a, str>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> EndpointBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `endpoint` object. + #[builder(setter(into))] + pub(crate) endpoint: Endpoint<'a>, + + #[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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "endpoints".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("endpoint", serde_json::to_value(&self.endpoint)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoint".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .endpoint( + EndpointBuilder::default() + .interface(Interface::Admin) + .service_id("foo") + .url("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .endpoint( + EndpointBuilder::default() + .interface(Interface::Admin) + .service_id("foo") + .url("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "endpoint" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/endpoints".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint": {} })); + }); + + let endpoint = Request::builder() + .endpoint( + EndpointBuilder::default() + .interface(Interface::Admin) + .service_id("foo") + .url("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/endpoints".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint": {} })); + }); + + let endpoint = Request::builder() + .endpoint( + EndpointBuilder::default() + .interface(Interface::Admin) + .service_id("foo") + .url("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/endpoint/delete.rs b/sdk/identity/src/v3/endpoint/delete.rs new file mode 100644 index 000000000..281613d29 --- /dev/null +++ b/sdk/identity/src/v3/endpoint/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes an endpoint. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoint` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for /v3/endpoints/{endpoint_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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("endpoints/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/endpoints/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/endpoints/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/endpoint/get.rs b/sdk/identity/src/v3/endpoint/get.rs new file mode 100644 index 000000000..e782bfb19 --- /dev/null +++ b/sdk/identity/src/v3/endpoint/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for an endpoint. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoints` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for /v3/endpoints/{endpoint_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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("endpoints/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoint".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "endpoint" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/endpoints/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/endpoints/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/endpoint/head.rs b/sdk/identity/src/v3/endpoint/head.rs new file mode 100644 index 000000000..10a3694e5 --- /dev/null +++ b/sdk/identity/src/v3/endpoint/head.rs @@ -0,0 +1,194 @@ +// 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 endpoints. +//! +//! GET /v3/endpoints +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The interface type, which describes the visibility of the endpoint. + /// Value is: -public. Visible by end users on a publicly available network + /// interface. -internal. Visible by end users on an unmetered internal + /// network interface.-admin. Visible by administrative users on a secure + /// network interface. + #[builder(default, setter(into))] + interface: Option>, + + /// (Since v3.2) The ID of the region that contains the service endpoint. + #[builder(default, setter(into))] + region_id: Option>, + + /// The UUID of the service to which the endpoint belongs + #[builder(default, setter(into))] + service_id: 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> { + /// Add a single header to the Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "endpoints".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("interface", self.interface.as_ref()); + params.push_opt("region_id", self.region_id.as_ref()); + params.push_opt("service_id", self.service_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/endpoints".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/endpoints".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/endpoint/list.rs b/sdk/identity/src/v3/endpoint/list.rs new file mode 100644 index 000000000..43461a806 --- /dev/null +++ b/sdk/identity/src/v3/endpoint/list.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`. + +//! Lists all available endpoints. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoints` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The interface type, which describes the visibility of the endpoint. + /// Value is: -public. Visible by end users on a publicly available network + /// interface. -internal. Visible by end users on an unmetered internal + /// network interface.-admin. Visible by administrative users on a secure + /// network interface. + #[builder(default, setter(into))] + interface: Option>, + + /// (Since v3.2) The ID of the region that contains the service endpoint. + #[builder(default, setter(into))] + region_id: Option>, + + /// The UUID of the service to which the endpoint belongs + #[builder(default, setter(into))] + service_id: 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> { + /// Add a single header to the Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "endpoints".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("interface", self.interface.as_ref()); + params.push_opt("region_id", self.region_id.as_ref()); + params.push_opt("service_id", self.service_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoints".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "endpoints" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/endpoints".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoints": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/endpoints".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoints": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy.rs b/sdk/identity/src/v3/endpoint/os_endpoint_policy.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy.rs rename to sdk/identity/src/v3/endpoint/os_endpoint_policy.rs diff --git a/openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy.rs b/sdk/identity/src/v3/endpoint/os_endpoint_policy/policy.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/endpoint/os_endpoint_policy/policy.rs rename to sdk/identity/src/v3/endpoint/os_endpoint_policy/policy.rs diff --git a/sdk/identity/src/v3/endpoint/os_endpoint_policy/policy/get.rs b/sdk/identity/src/v3/endpoint/os_endpoint_policy/policy/get.rs new file mode 100644 index 000000000..4ed6f958e --- /dev/null +++ b/sdk/identity/src/v3/endpoint/os_endpoint_policy/policy/get.rs @@ -0,0 +1,194 @@ +// 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 operation on /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy API + #[builder(default, setter(into))] + endpoint_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 Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", + endpoint_id = self.endpoint_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", + endpoint_id = "endpoint_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .endpoint_id("endpoint_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", + endpoint_id = "endpoint_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() + .endpoint_id("endpoint_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/endpoint/os_endpoint_policy/policy/head.rs b/sdk/identity/src/v3/endpoint/os_endpoint_policy/policy/head.rs new file mode 100644 index 000000000..273cb8dec --- /dev/null +++ b/sdk/identity/src/v3/endpoint/os_endpoint_policy/policy/head.rs @@ -0,0 +1,189 @@ +// 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`. + +//! HEAD operation on /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy API + #[builder(default, setter(into))] + endpoint_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 Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", + endpoint_id = self.endpoint_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", + endpoint_id = "endpoint_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_id("endpoint_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/policy", + endpoint_id = "endpoint_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_id("endpoint_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/endpoint/set.rs b/sdk/identity/src/v3/endpoint/set.rs new file mode 100644 index 000000000..226f61980 --- /dev/null +++ b/sdk/identity/src/v3/endpoint/set.rs @@ -0,0 +1,301 @@ +// 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`. + +//! Updates an endpoint. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/endpoint` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Interface { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "internal")] + Internal, + #[serde(rename = "public")] + Public, +} + +/// An `endpoint` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Endpoint<'a> { + /// The endpoint description. It is returned only when set on the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Indicates whether the endpoint appears in the service catalog: - + /// `false`. The endpoint does not appear in the service catalog. - `true`. + /// The endpoint appears in the service catalog. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The interface type, which describes the visibility of the endpoint. + /// Value is: - `public`. Visible by end users on a publicly available + /// network interface. - `internal`. Visible by end users on an unmetered + /// internal network interface. - `admin`. Visible by administrative users + /// on a secure network interface. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) interface: Option, + + /// (Deprecated) The endpoint name. The field will only be returned in + /// responses when set on the resource. + /// + /// This field is deprecated as it provides no value. Endpoints are better + /// described by the combination of service, region and interface they + /// describe or by their ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// (Deprecated in v3.2) The geographic location of the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region: Option>>, + + /// (Since v3.2) The ID of the region that contains the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region_id: Option>>, + + /// The UUID of the service to which the endpoint belongs. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_id: Option>, + + /// The endpoint URL. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> EndpointBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `endpoint` object. + #[builder(setter(into))] + pub(crate) endpoint: Endpoint<'a>, + + /// endpoint_id parameter for /v3/endpoints/{endpoint_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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("endpoints/{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("endpoint", serde_json::to_value(&self.endpoint)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoint".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .endpoint(EndpointBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .endpoint(EndpointBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "endpoint" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/endpoints/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .endpoint(EndpointBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/endpoints/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .endpoint(EndpointBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/group.rs b/sdk/identity/src/v3/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/group.rs rename to sdk/identity/src/v3/group.rs diff --git a/sdk/identity/src/v3/group/create.rs b/sdk/identity/src/v3/group/create.rs new file mode 100644 index 000000000..ffb5981d0 --- /dev/null +++ b/sdk/identity/src/v3/group/create.rs @@ -0,0 +1,252 @@ +// 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`. + +//! Creates a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/groups` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `group` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Group<'a> { + /// The description of the group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the domain of the group. If the domain ID is not provided in + /// the request, the Identity service will attempt to pull the domain ID + /// from the token used in the request. Note that this requires the use of + /// a domain-scoped token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>, + + /// The name of the group. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> GroupBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `group` object + #[builder(setter(into))] + pub(crate) group: Group<'a>, + + #[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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("group", serde_json::to_value(&self.group)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("group".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .group(GroupBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .group(GroupBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .group(GroupBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .group(GroupBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/delete.rs b/sdk/identity/src/v3/group/delete.rs new file mode 100644 index 000000000..a03bee417 --- /dev/null +++ b/sdk/identity/src/v3/group/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/group` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/groups/{group_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<'a> RequestBuilder<'a> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/groups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/groups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/find.rs b/sdk/identity/src/v3/group/find.rs new file mode 100644 index 000000000..d74dfaf77 --- /dev/null +++ b/sdk/identity/src/v3/group/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::group::{get as Get, list as List}; + +/// Find for group 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate group in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // group 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/identity/src/v3/group/get.rs b/sdk/identity/src/v3/group/get.rs new file mode 100644 index 000000000..c33f46dd8 --- /dev/null +++ b/sdk/identity/src/v3/group/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/group` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/groups/{group_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<'a> RequestBuilder<'a> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("group".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/head.rs b/sdk/identity/src/v3/group/head.rs new file mode 100644 index 000000000..d0b91f05c --- /dev/null +++ b/sdk/identity/src/v3/group/head.rs @@ -0,0 +1,206 @@ +// 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 groups. +//! +//! GET/HEAD /groups +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + #[builder(default)] + limit: Option, + + /// ID of the last fetched entry + #[builder(default, setter(into))] + marker: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: Option>, + + /// Sort direction. A valid value is asc (ascending) or desc (descending). + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts resources by attribute. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/groups".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/list.rs b/sdk/identity/src/v3/group/list.rs new file mode 100644 index 000000000..21ba768d5 --- /dev/null +++ b/sdk/identity/src/v3/group/list.rs @@ -0,0 +1,215 @@ +// 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`. + +//! Lists groups. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/groups` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + #[builder(default)] + limit: Option, + + /// ID of the last fetched entry + #[builder(default, setter(into))] + marker: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: Option>, + + /// Sort direction. A valid value is asc (ascending) or desc (descending). + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts resources by attribute. + #[builder(default, setter(into))] + sort_key: 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> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("groups".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/set.rs b/sdk/identity/src/v3/group/set.rs new file mode 100644 index 000000000..02c1c0b8a --- /dev/null +++ b/sdk/identity/src/v3/group/set.rs @@ -0,0 +1,253 @@ +// 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`. + +//! Updates a group. +//! +//! If the back-end driver does not support this functionality, the call +//! returns the `Not Implemented (501)` response code. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/group` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `group` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Group<'a> { + /// The new description of the group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The new name of the group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> GroupBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `group` object + #[builder(setter(into))] + pub(crate) group: Group<'a>, + + /// group_id parameter for /v3/groups/{group_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<'a> RequestBuilder<'a> { + /// Add a single header to the Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("groups/{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("group", serde_json::to_value(&self.group)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("group".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .group(GroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .group(GroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .group(GroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .group(GroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/group/user.rs b/sdk/identity/src/v3/group/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/group/user.rs rename to sdk/identity/src/v3/group/user.rs diff --git a/sdk/identity/src/v3/group/user/delete.rs b/sdk/identity/src/v3/group/user/delete.rs new file mode 100644 index 000000000..5f6f2d84c --- /dev/null +++ b/sdk/identity/src/v3/group/user/delete.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Removes a user from a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_user` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "groups/{group_id}/users/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_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() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/user/get.rs b/sdk/identity/src/v3/group/user/get.rs new file mode 100644 index 000000000..dcf928011 --- /dev/null +++ b/sdk/identity/src/v3/group/user/get.rs @@ -0,0 +1,204 @@ +// 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`. + +//! Check if a user is in a group. +//! +//! GET/HEAD /groups/{group_id}/users/{user_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "groups/{group_id}/users/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_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() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/user/head.rs b/sdk/identity/src/v3/group/user/head.rs new file mode 100644 index 000000000..1b2546edc --- /dev/null +++ b/sdk/identity/src/v3/group/user/head.rs @@ -0,0 +1,200 @@ +// 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`. + +//! Validates that a user belongs to a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_user` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "groups/{group_id}/users/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/user/list.rs b/sdk/identity/src/v3/group/user/list.rs new file mode 100644 index 000000000..5cbe1df21 --- /dev/null +++ b/sdk/identity/src/v3/group/user/list.rs @@ -0,0 +1,198 @@ +// 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`. + +//! Lists the users that belong to a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_users` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// Filter results based on which user passwords have expired. The query + /// should include an operator and a timestamp with a colon (:) separating + /// the two, for example: `password_expires_at={operator}:{timestamp}`. + /// Valid operators are: `lt`, `lte`, `gt`, `gte`, `eq`, and `neq`. Valid + /// timestamps are of the form: YYYY-MM-DDTHH:mm:ssZ. + #[builder(default, setter(into))] + password_expires_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("groups/{group_id}/users", group_id = self.group_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("password_expires_at", self.password_expires_at.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("users".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "users" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/groups/{group_id}/users", group_id = "group_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "users": {} })); + }); + + let endpoint = Request::builder().group_id("group_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/groups/{group_id}/users", group_id = "group_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "users": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/group/user/set.rs b/sdk/identity/src/v3/group/user/set.rs new file mode 100644 index 000000000..d09ed806d --- /dev/null +++ b/sdk/identity/src/v3/group/user/set.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Adds a user to a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/group_user` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/groups/{group_id}/users/{user_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// user_id parameter for /v3/groups/{group_id}/users/{user_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "groups/{group_id}/users/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/groups/{group_id}/users/{id}", + group_id = "group_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() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/limit.rs b/sdk/identity/src/v3/limit.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/limit.rs rename to sdk/identity/src/v3/limit.rs diff --git a/sdk/identity/src/v3/limit/create.rs b/sdk/identity/src/v3/limit/create.rs new file mode 100644 index 000000000..9ff8de0e9 --- /dev/null +++ b/sdk/identity/src/v3/limit/create.rs @@ -0,0 +1,268 @@ +// 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`. + +//! Creates limits. It supports to create more than one limit in one request. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/limits` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Limits<'a> { + /// The limit description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The name of the domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>>, + + /// The ID for the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>>, + + /// The ID of the region that contains the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region_id: Option>>, + + /// The override limit. + #[serde()] + #[builder(setter(into))] + pub(crate) resource_limit: i32, + + /// The resource name. + #[serde()] + #[builder(setter(into))] + pub(crate) resource_name: Cow<'a, str>, + + /// The UUID of the service to which the limit belongs. + #[serde()] + #[builder(setter(into))] + pub(crate) service_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A list of `limits` objects + #[builder(setter(into))] + pub(crate) limits: Vec>, + + #[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 Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "limits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("limits", serde_json::to_value(&self.limits)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("limits".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .limits(Vec::from([LimitsBuilder::default() + .resource_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .limits(Vec::from([LimitsBuilder::default() + .resource_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "limits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/limits".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder() + .limits(Vec::from([LimitsBuilder::default() + .resource_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/limits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder() + .limits(Vec::from([LimitsBuilder::default() + .resource_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/limit/delete.rs b/sdk/identity/src/v3/limit/delete.rs new file mode 100644 index 000000000..789245842 --- /dev/null +++ b/sdk/identity/src/v3/limit/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes a limit. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { + /// Add a single header to the Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("limits/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/limits/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/limits/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/limit/get.rs b/sdk/identity/src/v3/limit/get.rs new file mode 100644 index 000000000..c27299daf --- /dev/null +++ b/sdk/identity/src/v3/limit/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a limit. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { + /// Add a single header to the Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("limits/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("limit".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "limit" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/limits/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limit": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/limits/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limit": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/limit/head.rs b/sdk/identity/src/v3/limit/head.rs new file mode 100644 index 000000000..a916ea2c2 --- /dev/null +++ b/sdk/identity/src/v3/limit/head.rs @@ -0,0 +1,178 @@ +// 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 an existing limit. +//! +//! GET /v3/limits/{limit_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { + /// Add a single header to the Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("limits/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/limits/{id}", id = "id",)); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/limits/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/limit/list.rs b/sdk/identity/src/v3/limit/list.rs new file mode 100644 index 000000000..e1de1b1fe --- /dev/null +++ b/sdk/identity/src/v3/limit/list.rs @@ -0,0 +1,209 @@ +// 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`. + +//! Lists Limits. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/limits` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + /// The ID of the project. + #[builder(default, setter(into))] + project_id: Option>, + + /// The ID of the region. + #[builder(default, setter(into))] + region_id: Option>, + + /// The resource name. + #[builder(default, setter(into))] + resource_name: Option>, + + /// Filters the response by a service ID. + #[builder(default, setter(into))] + service_id: 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> { + /// Add a single header to the Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "limits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("region_id", self.region_id.as_ref()); + params.push_opt("resource_name", self.resource_name.as_ref()); + params.push_opt("service_id", self.service_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("limits".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "limits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limits": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/limit/model.rs b/sdk/identity/src/v3/limit/model.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/limit/model.rs rename to sdk/identity/src/v3/limit/model.rs diff --git a/sdk/identity/src/v3/limit/model/get.rs b/sdk/identity/src/v3/limit/model/get.rs new file mode 100644 index 000000000..b2b1433cf --- /dev/null +++ b/sdk/identity/src/v3/limit/model/get.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`. + +//! Return the configured limit enforcement model. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit_model` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Model. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "limits/model".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("model".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "model" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits/model".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "model": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/limits/model".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "model": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/limit/model/head.rs b/sdk/identity/src/v3/limit/model/head.rs new file mode 100644 index 000000000..b8ddcba73 --- /dev/null +++ b/sdk/identity/src/v3/limit/model/head.rs @@ -0,0 +1,171 @@ +// 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 enforcement model. +//! +//! GET /v3/limits/model +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Model. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "limits/model".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/limits/model".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/limits/model".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/limit/set.rs b/sdk/identity/src/v3/limit/set.rs new file mode 100644 index 000000000..e501d209b --- /dev/null +++ b/sdk/identity/src/v3/limit/set.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Updates the specified limit. It only supports to update `resource_limit` or +//! `description` for the limit. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/limit` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `limit` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Limit<'a> { + /// The limit description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The override limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) resource_limit: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `limit` object + #[builder(setter(into))] + pub(crate) limit: Limit<'a>, + + /// limit_id parameter for /v3/limits/{limit_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<'a> RequestBuilder<'a> { + /// Add a single header to the Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("limits/{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("limit", serde_json::to_value(&self.limit)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("limit".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .limit(LimitBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .limit(LimitBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "limit" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/limits/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limit": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .limit(LimitBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/limits/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "limit": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .limit(LimitBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter.rs b/sdk/identity/src/v3/os_ep_filter.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter.rs rename to sdk/identity/src/v3/os_ep_filter.rs diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint.rs b/sdk/identity/src/v3/os_ep_filter/endpoint.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint.rs rename to sdk/identity/src/v3/os_ep_filter/endpoint.rs diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project.rs b/sdk/identity/src/v3/os_ep_filter/endpoint/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint/project.rs rename to sdk/identity/src/v3/os_ep_filter/endpoint/project.rs diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint/project/get.rs b/sdk/identity/src/v3/os_ep_filter/endpoint/project/get.rs new file mode 100644 index 000000000..befbf5328 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint/project/get.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Return a list of projects associated with the endpoint. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/OS-EP-FILTER/endpoints/{endpoint_id}/projects API + #[builder(default, setter(into))] + endpoint_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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/endpoints/{endpoint_id}/projects", + endpoint_id = self.endpoint_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", + endpoint_id = "endpoint_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .endpoint_id("endpoint_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", + endpoint_id = "endpoint_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() + .endpoint_id("endpoint_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint/project/head.rs b/sdk/identity/src/v3/os_ep_filter/endpoint/project/head.rs new file mode 100644 index 000000000..5f8a8f8ad --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint/project/head.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Return a list of projects associated with the endpoint. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/OS-EP-FILTER/endpoints/{endpoint_id}/projects API + #[builder(default, setter(into))] + endpoint_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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-EP-FILTER/endpoints/{endpoint_id}/projects", + endpoint_id = self.endpoint_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", + endpoint_id = "endpoint_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_id("endpoint_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-EP-FILTER/endpoints/{endpoint_id}/projects", + endpoint_id = "endpoint_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_id("endpoint_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group.rs rename to sdk/identity/src/v3/os_ep_filter/endpoint_group.rs diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/create.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/create.rs new file mode 100644 index 000000000..03b4908f7 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/create.rs @@ -0,0 +1,300 @@ +// 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 endpoint groups. +//! +//! POST /v3/OS-EP-FILTER/endpoint_groups +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Interface { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "internal")] + Internal, + #[serde(rename = "public")] + Public, +} + +/// Describes the filtering performed by the endpoint group. The filter used +/// must be an endpoint property, such as interface, service_id, region, and +/// enabled. Note that if using interface as a filter, the only available +/// values are public, internal, and admin. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Filters<'a> { + /// Indicates whether the endpoint appears in the service catalog -false. + /// The endpoint does not appear in the service catalog. -true. The + /// endpoint appears in the service catalog. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The interface type, which describes the visibility of the endpoint. + /// Value is: -public. Visible by end users on a publicly available network + /// interface. -internal. Visible by end users on an unmetered internal + /// network interface. -admin. Visible by administrative users on a secure + /// network interface. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) interface: Option, + + /// (Since v3.2) The ID of the region that contains the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region_id: Option>>, + + /// The UUID of the service to which the endpoint belongs + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_id: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct EndpointGroup<'a> { + /// The endpoint group description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Describes the filtering performed by the endpoint group. The filter + /// used must be an endpoint property, such as interface, service_id, + /// region, and enabled. Note that if using interface as a filter, the only + /// available values are public, internal, and admin. + #[serde()] + #[builder(setter(into))] + pub(crate) filters: Filters<'a>, + + /// The name of the endpoint group. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) endpoint_group: EndpointGroup<'a>, + + #[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 Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-EP-FILTER/endpoint_groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "endpoint_group", + serde_json::to_value(&self.endpoint_group)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoint_group".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .endpoint_group( + EndpointGroupBuilder::default() + .filters(FiltersBuilder::default().build().unwrap()) + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .endpoint_group( + EndpointGroupBuilder::default() + .filters(FiltersBuilder::default().build().unwrap()) + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "endpoint_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-EP-FILTER/endpoint_groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group( + EndpointGroupBuilder::default() + .filters(FiltersBuilder::default().build().unwrap()) + .name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-EP-FILTER/endpoint_groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group( + EndpointGroupBuilder::default() + .filters(FiltersBuilder::default().build().unwrap()) + .name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/delete.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/delete.rs new file mode 100644 index 000000000..4cd593fa1 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/delete.rs @@ -0,0 +1,182 @@ +// 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 operation on /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-EP-FILTER/endpoint_groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-EP-FILTER/endpoint_groups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-EP-FILTER/endpoint_groups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/endpoint.rs rename to sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint.rs diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint/get.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint/get.rs new file mode 100644 index 000000000..3535ab058 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint/get.rs @@ -0,0 +1,195 @@ +// 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 operation on +//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints API + #[builder(default, setter(into))] + endpoint_group_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", + endpoint_group_id = self.endpoint_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", + endpoint_group_id = "endpoint_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", + endpoint_group_id = "endpoint_group_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() + .endpoint_group_id("endpoint_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint/head.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint/head.rs new file mode 100644 index 000000000..6dfb33152 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/endpoint/head.rs @@ -0,0 +1,190 @@ +// 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`. + +//! HEAD operation on +//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints API + #[builder(default, setter(into))] + endpoint_group_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", + endpoint_group_id = self.endpoint_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", + endpoint_group_id = "endpoint_group_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/endpoints", + endpoint_group_id = "endpoint_group_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/get.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/get.rs new file mode 100644 index 000000000..f9da6a3d9 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/get.rs @@ -0,0 +1,187 @@ +// 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 Endpoint Group +//! +//! GET /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-EP-FILTER/endpoint_groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoint_group".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "endpoint_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/head.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/head.rs new file mode 100644 index 000000000..c21033d2f --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/head.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`. + +//! List all endpoint groups. +//! +//! GET /v3/OS-EP-FILTER/endpoint_groups +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The name of the endpoint group. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-EP-FILTER/endpoint_groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("name", self.name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-EP-FILTER/endpoint_groups".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-EP-FILTER/endpoint_groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/list.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/list.rs new file mode 100644 index 000000000..4726a0aa7 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/list.rs @@ -0,0 +1,188 @@ +// 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 endpoint groups. +//! +//! GET /v3/OS-EP-FILTER/endpoint_groups +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The name of the endpoint group. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-EP-FILTER/endpoint_groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("name", self.name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoint_groups".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "endpoint_groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-EP-FILTER/endpoint_groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-EP-FILTER/endpoint_groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/endpoint_group/project.rs rename to sdk/identity/src/v3/os_ep_filter/endpoint_group/project.rs diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/delete.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/delete.rs new file mode 100644 index 000000000..5ba271b27 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/delete.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`. + +//! DELETE operation on +//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} + /// API + #[builder(default, setter(into))] + endpoint_group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_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<'a> RequestBuilder<'a> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = self.endpoint_group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_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() + .endpoint_group_id("endpoint_group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/get.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/get.rs new file mode 100644 index 000000000..6b53ad802 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/get.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`. + +//! GET operation on +//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} + /// API + #[builder(default, setter(into))] + endpoint_group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_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<'a> RequestBuilder<'a> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = self.endpoint_group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_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() + .endpoint_group_id("endpoint_group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/head.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/head.rs new file mode 100644 index 000000000..b55f76e6a --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/head.rs @@ -0,0 +1,202 @@ +// 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`. + +//! HEAD operation on +//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} + /// API + #[builder(default, setter(into))] + endpoint_group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_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<'a> RequestBuilder<'a> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = self.endpoint_group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_id", + id = "id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .id("id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/list.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/list.rs new file mode 100644 index 000000000..be3961f59 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/list.rs @@ -0,0 +1,196 @@ +// 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 operation on +//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} + /// API + #[builder(default, setter(into))] + endpoint_group_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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects", + endpoint_group_id = self.endpoint_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects", + endpoint_group_id = "endpoint_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects", + endpoint_group_id = "endpoint_group_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() + .endpoint_group_id("endpoint_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/set.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/set.rs new file mode 100644 index 000000000..ad1ce41bf --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/project/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`. + +//! PUT operation on +//! /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} + /// API + #[builder(default, setter(into))] + endpoint_group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{project_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = self.endpoint_group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group_id("endpoint_group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-EP-FILTER/endpoint_groups/{endpoint_group_id}/projects/{id}", + endpoint_group_id = "endpoint_group_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() + .endpoint_group_id("endpoint_group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/endpoint_group/set.rs b/sdk/identity/src/v3/os_ep_filter/endpoint_group/set.rs new file mode 100644 index 000000000..a5bd8410f --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/endpoint_group/set.rs @@ -0,0 +1,283 @@ +// 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 existing endpoint groups +//! +//! PATCH /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Interface { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "internal")] + Internal, + #[serde(rename = "public")] + Public, +} + +/// Describes the filtering performed by the endpoint group. The filter used +/// must be an endpoint property, such as interface, service_id, region, and +/// enabled. Note that if using interface as a filter, the only available +/// values are public, internal, and admin. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Filters<'a> { + /// Indicates whether the endpoint appears in the service catalog -false. + /// The endpoint does not appear in the service catalog. -true. The + /// endpoint appears in the service catalog. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The interface type, which describes the visibility of the endpoint. + /// Value is: -public. Visible by end users on a publicly available network + /// interface. -internal. Visible by end users on an unmetered internal + /// network interface. -admin. Visible by administrative users on a secure + /// network interface. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) interface: Option, + + /// (Since v3.2) The ID of the region that contains the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region_id: Option>>, + + /// The UUID of the service to which the endpoint belongs + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_id: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct EndpointGroup<'a> { + /// The endpoint group description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Describes the filtering performed by the endpoint group. The filter + /// used must be an endpoint property, such as interface, service_id, + /// region, and enabled. Note that if using interface as a filter, the only + /// available values are public, internal, and admin. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) filters: Option>, + + /// The name of the endpoint group. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) endpoint_group: EndpointGroup<'a>, + + /// endpoint_group_id parameter for + /// /v3/OS-EP-FILTER/endpoint_groups/{endpoint_group_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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-EP-FILTER/endpoint_groups/{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( + "endpoint_group", + serde_json::to_value(&self.endpoint_group)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("endpoint_group".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "endpoint_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-EP-FILTER/endpoint_groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project.rs b/sdk/identity/src/v3/os_ep_filter/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/project.rs rename to sdk/identity/src/v3/os_ep_filter/project.rs diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint.rs rename to sdk/identity/src/v3/os_ep_filter/project/endpoint.rs diff --git a/sdk/identity/src/v3/os_ep_filter/project/endpoint/delete.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint/delete.rs new file mode 100644 index 000000000..9d0fd7c88 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/project/endpoint/delete.rs @@ -0,0 +1,205 @@ +// 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 operation on +//! /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API + #[builder(default, setter(into))] + project_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = self.id.as_ref(), + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = "id", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .project_id("project_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = "id", + project_id = "project_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") + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/project/endpoint/get.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint/get.rs new file mode 100644 index 000000000..5b977861d --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/project/endpoint/get.rs @@ -0,0 +1,205 @@ +// 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 operation on +//! /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API + #[builder(default, setter(into))] + project_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = self.id.as_ref(), + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = "id", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .project_id("project_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = "id", + project_id = "project_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") + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/project/endpoint/head.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint/head.rs new file mode 100644 index 000000000..9f2770859 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/project/endpoint/head.rs @@ -0,0 +1,186 @@ +// 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`. + +//! HEAD operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoints +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API + #[builder(default, setter(into))] + project_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-EP-FILTER/projects/{project_id}/endpoints", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints", + project_id = "project_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/project/endpoint/list.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint/list.rs new file mode 100644 index 000000000..756cd7499 --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/project/endpoint/list.rs @@ -0,0 +1,191 @@ +// 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 operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoints +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API + #[builder(default, setter(into))] + project_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/projects/{project_id}/endpoints", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints", + project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/project/endpoint/set.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint/set.rs new file mode 100644 index 000000000..833b6902c --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/project/endpoint/set.rs @@ -0,0 +1,232 @@ +// 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`. + +//! PUT operation on +//! /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoints API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = self.id.as_ref(), + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = "id", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .project_id("project_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoints/{id}", + id = "id", + project_id = "project_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") + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint_group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_ep_filter/project/endpoint_group.rs rename to sdk/identity/src/v3/os_ep_filter/project/endpoint_group.rs diff --git a/sdk/identity/src/v3/os_ep_filter/project/endpoint_group/get.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint_group/get.rs new file mode 100644 index 000000000..784dfd3fc --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/project/endpoint_group/get.rs @@ -0,0 +1,191 @@ +// 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 operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups API + #[builder(default, setter(into))] + project_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 Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-EP-FILTER/projects/{project_id}/endpoint_groups", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", + project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_ep_filter/project/endpoint_group/head.rs b/sdk/identity/src/v3/os_ep_filter/project/endpoint_group/head.rs new file mode 100644 index 000000000..a33df766c --- /dev/null +++ b/sdk/identity/src/v3/os_ep_filter/project/endpoint_group/head.rs @@ -0,0 +1,186 @@ +// 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`. + +//! HEAD operation on /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-EP-FILTER/projects/{project_id}/endpoint_groups API + #[builder(default, setter(into))] + project_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 Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-EP-FILTER/projects/{project_id}/endpoint_groups", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", + project_id = "project_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-EP-FILTER/projects/{project_id}/endpoint_groups", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_federation.rs b/sdk/identity/src/v3/os_federation.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation.rs rename to sdk/identity/src/v3/os_federation.rs diff --git a/openstack_sdk/src/api/identity/v3/os_federation/domain.rs b/sdk/identity/src/v3/os_federation/domain.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/domain.rs rename to sdk/identity/src/v3/os_federation/domain.rs diff --git a/sdk/identity/src/v3/os_federation/domain/head.rs b/sdk/identity/src/v3/os_federation/domain/head.rs new file mode 100644 index 000000000..e3e0ff3c1 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/domain/head.rs @@ -0,0 +1,171 @@ +// 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 possible domain scopes for token. +//! +//! GET/HEAD /v3/auth/domains GET/HEAD /v3/OS-FEDERATION/domains +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-FEDERATION/domains".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/domains".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/domains".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/domain/list.rs b/sdk/identity/src/v3/os_federation/domain/list.rs new file mode 100644 index 000000000..6846fa1c9 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/domain/list.rs @@ -0,0 +1,179 @@ +// 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 possible domain scopes for token. +//! +//! GET/HEAD /v3/auth/domains GET/HEAD /v3/OS-FEDERATION/domains +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Domain. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-FEDERATION/domains".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("domains".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "domains" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/domains".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domains": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/domains".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "domains": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider.rs b/sdk/identity/src/v3/os_federation/identity_provider.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/identity_provider.rs rename to sdk/identity/src/v3/os_federation/identity_provider.rs diff --git a/sdk/identity/src/v3/os_federation/identity_provider/create.rs b/sdk/identity/src/v3/os_federation/identity_provider/create.rs new file mode 100644 index 000000000..062a97a96 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/create.rs @@ -0,0 +1,258 @@ +// 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 an idp resource for federated authentication. +//! +//! PUT /OS-FEDERATION/identity_providers/{idp_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct IdentityProvider<'a> { + /// The length of validity in minutes for group memberships carried over + /// through mapping and persisted in the database. If left unset, the + /// default value configured in keystone will be used, if enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) authorization_ttl: Option>, + + /// The identity provider description + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of a domain that is associated with the identity provider. + /// Federated users that authenticate with the identity provider will be + /// created under the domain specified. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>>, + + /// Whether the identity provider is enabled or not + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// List of the unique identity provider's remote IDs + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_ids: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) identity_provider: IdentityProvider<'a>, + + /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API + #[builder(default, setter(into))] + idp_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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-FEDERATION/identity_providers/{idp_id}", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "identity_provider", + serde_json::to_value(&self.identity_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_provider".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "identity_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/delete.rs b/sdk/identity/src/v3/os_federation/identity_provider/delete.rs new file mode 100644 index 000000000..c9121bb93 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/delete.rs @@ -0,0 +1,190 @@ +// 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 operation on /v3/OS-FEDERATION/identity_providers/{idp_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API + #[builder(default, setter(into))] + idp_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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_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() + .idp_id("idp_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/get.rs b/sdk/identity/src/v3/os_federation/identity_provider/get.rs new file mode 100644 index 000000000..31661133f --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/get.rs @@ -0,0 +1,195 @@ +// 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 an IDP resource. +//! +//! GET/HEAD /OS-FEDERATION/identity_providers/{idp_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API + #[builder(default, setter(into))] + idp_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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_provider".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "identity_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/head.rs b/sdk/identity/src/v3/os_federation/identity_provider/head.rs new file mode 100644 index 000000000..0962ea12b --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/head.rs @@ -0,0 +1,185 @@ +// 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 identity providers. +//! +//! GET/HEAD /OS-FEDERATION/identity_providers +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Whether the identity provider is enabled or not + #[builder(default)] + enabled: Option, + + /// The identity provider ID + #[builder(default, setter(into))] + id: 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> { + /// Add a single header to the Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-FEDERATION/identity_providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("enabled", self.enabled); + params.push_opt("id", self.id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/identity_providers".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/identity_providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/list.rs b/sdk/identity/src/v3/os_federation/identity_provider/list.rs new file mode 100644 index 000000000..37241a48a --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/list.rs @@ -0,0 +1,193 @@ +// 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 identity providers. +//! +//! GET/HEAD /OS-FEDERATION/identity_providers +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Whether the identity provider is enabled or not + #[builder(default)] + enabled: Option, + + /// The identity provider ID + #[builder(default, setter(into))] + id: 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> { + /// Add a single header to the Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-FEDERATION/identity_providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("enabled", self.enabled); + params.push_opt("id", self.id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_providers".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "identity_providers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/identity_providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_providers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/identity_providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_providers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol.rs rename to sdk/identity/src/v3/os_federation/identity_provider/protocol.rs diff --git a/openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/identity_provider/protocol/auth.rs rename to sdk/identity/src/v3/os_federation/identity_provider/protocol/auth.rs diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/create.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/create.rs new file mode 100644 index 000000000..6369556b8 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/create.rs @@ -0,0 +1,239 @@ +// 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`. + +//! Authenticate from dedicated uri endpoint. +//! +//! POST /OS-FEDERATION/identity_providers/ +//! {idp_id}/protocols/{protocol_id}/auth +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth + /// API + #[builder(default, setter(into))] + idp_id: Cow<'a, str>, + + /// protocol_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth + /// API + #[builder(default, setter(into))] + protocol_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Auth. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = self.idp_id.as_ref(), + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = "idp_id", + protocol_id = "protocol_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = "idp_id", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/get.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/get.rs new file mode 100644 index 000000000..835d41b64 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/get.rs @@ -0,0 +1,212 @@ +// 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`. + +//! Authenticate from dedicated uri endpoint. +//! +//! GET/HEAD /OS-FEDERATION/identity_providers/ +//! {idp_id}/protocols/{protocol_id}/auth +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth + /// API + #[builder(default, setter(into))] + idp_id: Cow<'a, str>, + + /// protocol_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth + /// API + #[builder(default, setter(into))] + protocol_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 Auth. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = self.idp_id.as_ref(), + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("token".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "token" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = "idp_id", + protocol_id = "protocol_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = "idp_id", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "token": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/head.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/head.rs new file mode 100644 index 000000000..c66fd893c --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/auth/head.rs @@ -0,0 +1,204 @@ +// 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`. + +//! Authenticate from dedicated uri endpoint. +//! +//! GET/HEAD /OS-FEDERATION/identity_providers/ +//! {idp_id}/protocols/{protocol_id}/auth +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth + /// API + #[builder(default, setter(into))] + idp_id: Cow<'a, str>, + + /// protocol_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth + /// API + #[builder(default, setter(into))] + protocol_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 Auth. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = self.idp_id.as_ref(), + protocol_id = self.protocol_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = "idp_id", + protocol_id = "protocol_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id}/auth", + idp_id = "idp_id", + protocol_id = "protocol_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .protocol_id("protocol_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/create.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/create.rs new file mode 100644 index 000000000..2ec1b48d8 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/create.rs @@ -0,0 +1,266 @@ +// 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 protocol for an IDP. +//! +//! PUT /OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Protocol<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) mapping_id: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_id_attribute: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) protocol: Protocol<'a>, + + /// protocol_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API + #[builder(default, setter(into))] + idp_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 Protocol. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = self.idp_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("protocol", serde_json::to_value(&self.protocol)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("protocol".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "protocol" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocol": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .id("id") + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocol": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .id("id") + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/delete.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/delete.rs new file mode 100644 index 000000000..e18d77215 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/delete.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`. + +//! Delete a protocol from an IDP. +//! +//! DELETE /OS-FEDERATION/identity_providers/ {idp_id}/protocols/{protocol_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// protocol_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API + #[builder(default, setter(into))] + idp_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 Protocol. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = self.idp_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_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() + .idp_id("idp_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/get.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/get.rs new file mode 100644 index 000000000..6f126786d --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/get.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`. + +//! Get protocols for an IDP. +//! +//! HEAD/GET /OS-FEDERATION/identity_providers/ +//! {idp_id}/protocols/{protocol_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// protocol_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API + #[builder(default, setter(into))] + idp_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 Protocol. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = self.idp_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("protocol".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "protocol" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocol": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocol": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/head.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/head.rs new file mode 100644 index 000000000..3095bf43c --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/head.rs @@ -0,0 +1,188 @@ +// 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 protocols for an IDP. +//! +//! HEAD/GET /OS-FEDERATION/identity_providers/{idp_id}/protocols +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API + #[builder(default, setter(into))] + idp_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 Protocol. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols", + idp_id = "idp_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols", + idp_id = "idp_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/list.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/list.rs new file mode 100644 index 000000000..30db6541c --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/list.rs @@ -0,0 +1,196 @@ +// 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 protocols for an IDP. +//! +//! HEAD/GET /OS-FEDERATION/identity_providers/{idp_id}/protocols +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API + #[builder(default, setter(into))] + idp_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 Protocol. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("protocols".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "protocols" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocols": {} })); + }); + + let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols", + idp_id = "idp_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocols": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/protocol/set.rs b/sdk/identity/src/v3/os_federation/identity_provider/protocol/set.rs new file mode 100644 index 000000000..2a6dc2afc --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/protocol/set.rs @@ -0,0 +1,266 @@ +// 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 protocol for an IDP. +//! +//! PATCH /OS-FEDERATION/identity_providers/ {idp_id}/protocols/{protocol_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Protocol<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) mapping_id: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_id_attribute: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) protocol: Protocol<'a>, + + /// protocol_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols/{protocol_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// idp_id parameter for + /// /v3/OS-FEDERATION/identity_providers/{idp_id}/protocols API + #[builder(default, setter(into))] + idp_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 Protocol. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = self.idp_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("protocol", serde_json::to_value(&self.protocol)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("protocol".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "protocol" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocol": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .id("id") + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}/protocols/{id}", + idp_id = "idp_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "protocol": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .id("id") + .protocol( + ProtocolBuilder::default() + .mapping_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/identity_provider/set.rs b/sdk/identity/src/v3/os_federation/identity_provider/set.rs new file mode 100644 index 000000000..eaf45e75e --- /dev/null +++ b/sdk/identity/src/v3/os_federation/identity_provider/set.rs @@ -0,0 +1,249 @@ +// 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`. + +//! PATCH operation on /v3/OS-FEDERATION/identity_providers/{idp_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct IdentityProvider<'a> { + /// The length of validity in minutes for group memberships carried over + /// through mapping and persisted in the database. If left unset, the + /// default value configured in keystone will be used, if enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) authorization_ttl: Option>, + + /// The identity provider description + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Whether the identity provider is enabled or not + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// List of the unique identity provider's remote IDs + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_ids: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) identity_provider: IdentityProvider<'a>, + + /// idp_id parameter for /v3/OS-FEDERATION/identity_providers/{idp_id} API + #[builder(default, setter(into))] + idp_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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/identity_providers/{idp_id}", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "identity_provider", + serde_json::to_value(&self.identity_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_provider".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "identity_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH).path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!( + "/OS-FEDERATION/identity_providers/{idp_id}", + idp_id = "idp_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .identity_provider(IdentityProviderBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/mapping.rs b/sdk/identity/src/v3/os_federation/mapping.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/mapping.rs rename to sdk/identity/src/v3/os_federation/mapping.rs diff --git a/sdk/identity/src/v3/os_federation/mapping/create.rs b/sdk/identity/src/v3/os_federation/mapping/create.rs new file mode 100644 index 000000000..b0d366931 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/mapping/create.rs @@ -0,0 +1,503 @@ +// 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 mapping. +//! +//! PUT /OS-FEDERATION/mappings/{mapping_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Domain<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Group<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct GroupStruct<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) domain: Domain<'a>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LocalGroup<'a> { + F1(Group<'a>), + F2(GroupStruct<'a>), +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Roles<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Projects<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) roles: Vec>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "ephemeral")] + Ephemeral, + #[serde(rename = "local")] + Local, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) email: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Local<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group_ids: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) groups: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) projects: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteAnyOneOfRegexType<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) any_one_of: Vec>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteBlacklistRegexType<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) blacklist: Vec>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteNotAnyOfRegexType<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) not_any_of: Vec>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteRegexTypeWhitelist<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) whitelist: Vec>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteType<'a> { + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum RulesRemote<'a> { + F1(RemoteAnyOneOfRegexType<'a>), + F2(RemoteBlacklistRegexType<'a>), + F3(RemoteNotAnyOfRegexType<'a>), + F4(RemoteRegexTypeWhitelist<'a>), + F5(RemoteType<'a>), +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Rules<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) local: Vec>, + + #[serde()] + #[builder(setter(into))] + pub(crate) remote: Vec>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Mapping<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) rules: Vec>, + + /// Mapping schema version + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) schema_version: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) mapping: Mapping<'a>, + + /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("OS-FEDERATION/mappings/{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("mapping", serde_json::to_value(&self.mapping)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mapping".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap() + )])) + .build() + .unwrap()])) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap() + )])) + .build() + .unwrap()])) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "mapping" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap(), + )])) + .build() + .unwrap()])) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap(), + )])) + .build() + .unwrap()])) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/mapping/delete.rs b/sdk/identity/src/v3/os_federation/mapping/delete.rs new file mode 100644 index 000000000..7da0dc2fc --- /dev/null +++ b/sdk/identity/src/v3/os_federation/mapping/delete.rs @@ -0,0 +1,183 @@ +// 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 mapping. +//! +//! DELETE /OS-FEDERATION/mappings/{mapping_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-FEDERATION/mappings/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-FEDERATION/mappings/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-FEDERATION/mappings/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/mapping/get.rs b/sdk/identity/src/v3/os_federation/mapping/get.rs new file mode 100644 index 000000000..52bc8723a --- /dev/null +++ b/sdk/identity/src/v3/os_federation/mapping/get.rs @@ -0,0 +1,184 @@ +// 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 operation on /v3/OS-FEDERATION/mappings/{mapping_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-FEDERATION/mappings/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mapping".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "mapping" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/mapping/head.rs b/sdk/identity/src/v3/os_federation/mapping/head.rs new file mode 100644 index 000000000..95173710a --- /dev/null +++ b/sdk/identity/src/v3/os_federation/mapping/head.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`. + +//! HEAD operation on /v3/OS-FEDERATION/mappings +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-FEDERATION/mappings".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/mappings".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/mappings".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/mapping/list.rs b/sdk/identity/src/v3/os_federation/mapping/list.rs new file mode 100644 index 000000000..71d31447f --- /dev/null +++ b/sdk/identity/src/v3/os_federation/mapping/list.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`. + +//! GET operation on /v3/OS-FEDERATION/mappings +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-FEDERATION/mappings".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mappings".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "mappings" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/mappings".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mappings": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/mappings".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mappings": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/mapping/set.rs b/sdk/identity/src/v3/os_federation/mapping/set.rs new file mode 100644 index 000000000..91a4cb4fa --- /dev/null +++ b/sdk/identity/src/v3/os_federation/mapping/set.rs @@ -0,0 +1,503 @@ +// 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 an attribute mapping for identity federation. +//! +//! PATCH /OS-FEDERATION/mappings/{mapping_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Domain<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Group<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct GroupStruct<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) domain: Domain<'a>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum LocalGroup<'a> { + F1(Group<'a>), + F2(GroupStruct<'a>), +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Roles<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Projects<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) roles: Vec>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "ephemeral")] + Ephemeral, + #[serde(rename = "local")] + Local, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) email: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Local<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) group_ids: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) groups: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) projects: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteAnyOneOfRegexType<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) any_one_of: Vec>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteBlacklistRegexType<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) blacklist: Vec>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteNotAnyOfRegexType<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) not_any_of: Vec>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteRegexTypeWhitelist<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) regex: Option, + + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) whitelist: Vec>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RemoteType<'a> { + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +#[serde(untagged)] +pub enum RulesRemote<'a> { + F1(RemoteAnyOneOfRegexType<'a>), + F2(RemoteBlacklistRegexType<'a>), + F3(RemoteNotAnyOfRegexType<'a>), + F4(RemoteRegexTypeWhitelist<'a>), + F5(RemoteType<'a>), +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Rules<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) local: Vec>, + + #[serde()] + #[builder(setter(into))] + pub(crate) remote: Vec>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Mapping<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) rules: Vec>, + + /// Mapping schema version + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) schema_version: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) mapping: Mapping<'a>, + + /// mapping_id parameter for /v3/OS-FEDERATION/mappings/{mapping_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<'a> RequestBuilder<'a> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-FEDERATION/mappings/{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("mapping", serde_json::to_value(&self.mapping)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mapping".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap() + )])) + .build() + .unwrap()])) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap() + )])) + .build() + .unwrap()])) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "mapping" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap(), + )])) + .build() + .unwrap()])) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-FEDERATION/mappings/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .mapping( + MappingBuilder::default() + .rules(Vec::from([RulesBuilder::default() + .local(Vec::from([LocalBuilder::default().build().unwrap()])) + .remote(Vec::from([RulesRemote::F1( + RemoteAnyOneOfRegexTypeBuilder::default() + ._type("foo") + .any_one_of(Vec::from(["foo".into()])) + .build() + .unwrap(), + )])) + .build() + .unwrap()])) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/project.rs b/sdk/identity/src/v3/os_federation/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/project.rs rename to sdk/identity/src/v3/os_federation/project.rs diff --git a/sdk/identity/src/v3/os_federation/project/head.rs b/sdk/identity/src/v3/os_federation/project/head.rs new file mode 100644 index 000000000..24c3a1020 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/project/head.rs @@ -0,0 +1,171 @@ +// 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 possible project scopes for token. +//! +//! GET/HEAD /v3/auth/projects GET/HEAD /v3/OS-FEDERATION/projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-FEDERATION/projects".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/projects".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/projects".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/project/list.rs b/sdk/identity/src/v3/os_federation/project/list.rs new file mode 100644 index 000000000..e9a663c4d --- /dev/null +++ b/sdk/identity/src/v3/os_federation/project/list.rs @@ -0,0 +1,179 @@ +// 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 possible project scopes for token. +//! +//! GET/HEAD /v3/auth/projects GET/HEAD /v3/OS-FEDERATION/projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-FEDERATION/projects".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("projects".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "projects" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/projects".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/projects".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/saml2.rs b/sdk/identity/src/v3/os_federation/saml2.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/saml2.rs rename to sdk/identity/src/v3/os_federation/saml2.rs diff --git a/openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata.rs b/sdk/identity/src/v3/os_federation/saml2/metadata.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/saml2/metadata.rs rename to sdk/identity/src/v3/os_federation/saml2/metadata.rs diff --git a/sdk/identity/src/v3/os_federation/saml2/metadata/get.rs b/sdk/identity/src/v3/os_federation/saml2/metadata/get.rs new file mode 100644 index 000000000..74335d69c --- /dev/null +++ b/sdk/identity/src/v3/os_federation/saml2/metadata/get.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`. + +//! Get SAML2 metadata. +//! +//! GET/HEAD /OS-FEDERATION/saml2/metadata +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-FEDERATION/saml2/metadata".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/saml2/metadata".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/saml2/metadata".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/saml2/metadata/head.rs b/sdk/identity/src/v3/os_federation/saml2/metadata/head.rs new file mode 100644 index 000000000..dff7c4951 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/saml2/metadata/head.rs @@ -0,0 +1,171 @@ +// 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 SAML2 metadata. +//! +//! GET/HEAD /OS-FEDERATION/saml2/metadata +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Metadata. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-FEDERATION/saml2/metadata".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/saml2/metadata".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/saml2/metadata".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_federation/service_provider.rs b/sdk/identity/src/v3/os_federation/service_provider.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_federation/service_provider.rs rename to sdk/identity/src/v3/os_federation/service_provider.rs diff --git a/sdk/identity/src/v3/os_federation/service_provider/create.rs b/sdk/identity/src/v3/os_federation/service_provider/create.rs new file mode 100644 index 000000000..da15a52ba --- /dev/null +++ b/sdk/identity/src/v3/os_federation/service_provider/create.rs @@ -0,0 +1,274 @@ +// 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 service provider. +//! +//! PUT /OS-FEDERATION/service_providers/{service_provider_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ServiceProvider<'a> { + /// The URL to authenticate against + #[serde()] + #[builder(setter(into))] + pub(crate) auth_url: Cow<'a, str>, + + /// The description of the service provider + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Whether the service provider is enabled or not + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The prefix of the RelayState SAML attribute + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) relay_state_prefix: Option>>, + + /// The service provider's URL + #[serde()] + #[builder(setter(into))] + pub(crate) sp_url: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) service_provider: ServiceProvider<'a>, + + /// service_provider_id parameter for + /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-FEDERATION/service_providers/{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( + "service_provider", + serde_json::to_value(&self.service_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("service_provider".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_provider( + ServiceProviderBuilder::default() + .auth_url("foo") + .sp_url("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_provider( + ServiceProviderBuilder::default() + .auth_url("foo") + .sp_url("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_provider( + ServiceProviderBuilder::default() + .auth_url("foo") + .sp_url("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_provider( + ServiceProviderBuilder::default() + .auth_url("foo") + .sp_url("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/service_provider/delete.rs b/sdk/identity/src/v3/os_federation/service_provider/delete.rs new file mode 100644 index 000000000..269d5b3c0 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/service_provider/delete.rs @@ -0,0 +1,188 @@ +// 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 service provider. +//! +//! DELETE /OS-FEDERATION/service_providers/{service_provider_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_provider_id parameter for + /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/service_providers/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-FEDERATION/service_providers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-FEDERATION/service_providers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/service_provider/get.rs b/sdk/identity/src/v3/os_federation/service_provider/get.rs new file mode 100644 index 000000000..8584d869c --- /dev/null +++ b/sdk/identity/src/v3/os_federation/service_provider/get.rs @@ -0,0 +1,191 @@ +// 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 a service provider. +//! +//! GET/HEAD /OS-FEDERATION/service_providers/{service_provider_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_provider_id parameter for + /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/service_providers/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("service_provider".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/service_provider/head.rs b/sdk/identity/src/v3/os_federation/service_provider/head.rs new file mode 100644 index 000000000..3c6bb92c7 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/service_provider/head.rs @@ -0,0 +1,185 @@ +// 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 service providers. +//! +//! GET/HEAD /OS-FEDERATION/service_providers +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Whether the service provider is enabled or not + #[builder(default)] + enabled: Option, + + /// The service provider ID + #[builder(default, setter(into))] + id: 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> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-FEDERATION/service_providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("enabled", self.enabled); + params.push_opt("id", self.id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/service_providers".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-FEDERATION/service_providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/service_provider/list.rs b/sdk/identity/src/v3/os_federation/service_provider/list.rs new file mode 100644 index 000000000..308c5779d --- /dev/null +++ b/sdk/identity/src/v3/os_federation/service_provider/list.rs @@ -0,0 +1,193 @@ +// 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 service providers. +//! +//! GET/HEAD /OS-FEDERATION/service_providers +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Whether the service provider is enabled or not + #[builder(default)] + enabled: Option, + + /// The service provider ID + #[builder(default, setter(into))] + id: 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> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-FEDERATION/service_providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("enabled", self.enabled); + params.push_opt("id", self.id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("service_providers".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_providers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/service_providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_providers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-FEDERATION/service_providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_providers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_federation/service_provider/set.rs b/sdk/identity/src/v3/os_federation/service_provider/set.rs new file mode 100644 index 000000000..0eea44778 --- /dev/null +++ b/sdk/identity/src/v3/os_federation/service_provider/set.rs @@ -0,0 +1,250 @@ +// 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 a service provider. +//! +//! PATCH /OS-FEDERATION/service_providers/{service_provider_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ServiceProvider<'a> { + /// The URL to authenticate against + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) auth_url: Option>, + + /// The description of the service provider + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Whether the service provider is enabled or not + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The prefix of the RelayState SAML attribute + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) relay_state_prefix: Option>>, + + /// The service provider's URL + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) sp_url: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) service_provider: ServiceProvider<'a>, + + /// service_provider_id parameter for + /// /v3/OS-FEDERATION/service_providers/{service_provider_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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-FEDERATION/service_providers/{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( + "service_provider", + serde_json::to_value(&self.service_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("service_provider".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_provider(ServiceProviderBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_provider(ServiceProviderBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_provider(ServiceProviderBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-FEDERATION/service_providers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_provider(ServiceProviderBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit.rs b/sdk/identity/src/v3/os_inherit.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit.rs rename to sdk/identity/src/v3/os_inherit.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain.rs b/sdk/identity/src/v3/os_inherit/domain.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/domain.rs rename to sdk/identity/src/v3/os_inherit/domain.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group.rs b/sdk/identity/src/v3/os_inherit/domain/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/domain/group.rs rename to sdk/identity/src/v3/os_inherit/domain/group.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role.rs b/sdk/identity/src/v3/os_inherit/domain/group/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role.rs rename to sdk/identity/src/v3/os_inherit/domain/group/role.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project.rs b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/domain/group/role/inherited_to_project.rs rename to sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project.rs diff --git a/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/delete.rs b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/delete.rs new file mode 100644 index 000000000..9286ea4d5 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/delete.rs @@ -0,0 +1,220 @@ +// 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`. + +//! Revokes an inherited project role from a group in a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_group_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + role_id = self.role_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_id", + role_id = "role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .role_id("role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_id", + role_id = "role_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() + .domain_id("domain_id") + .group_id("group_id") + .role_id("role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/get.rs b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/get.rs new file mode 100644 index 000000000..fcc126e18 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/get.rs @@ -0,0 +1,210 @@ +// 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`. + +//! The list only contains those role assignments to the domain that were +//! specified as being inherited to projects within that domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_group_roles_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_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() + .domain_id("domain_id") + .group_id("group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/head.rs b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/head.rs new file mode 100644 index 000000000..661de7e8f --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/head.rs @@ -0,0 +1,204 @@ +// 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 roles (inherited) for a group on a domain. +//! +//! GET/HEAD /OS-INHERIT/domains/{domain_id}/groups/{group_id} +//! /roles/inherited_to_projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/inherited_to_projects.rs b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/inherited_to_projects.rs new file mode 100644 index 000000000..7c743aab1 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/group/role/inherited_to_project/inherited_to_projects.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`. + +//! The inherited role is only applied to the owned projects (both existing and +//! future projects), and will not appear as a role in a domain scoped token. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_group_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// group_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + group_id = self.group_id.as_ref(), + role_id = self.role_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_id", + role_id = "role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .group_id("group_id") + .role_id("role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + group_id = "group_id", + role_id = "role_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() + .domain_id("domain_id") + .group_id("group_id") + .role_id("role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user.rs b/sdk/identity/src/v3/os_inherit/domain/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/domain/user.rs rename to sdk/identity/src/v3/os_inherit/domain/user.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role.rs b/sdk/identity/src/v3/os_inherit/domain/user/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role.rs rename to sdk/identity/src/v3/os_inherit/domain/user/role.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project.rs b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/domain/user/role/inherited_to_project.rs rename to sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project.rs diff --git a/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/delete.rs b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/delete.rs new file mode 100644 index 000000000..0e8571434 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/delete.rs @@ -0,0 +1,221 @@ +// 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`. + +//! Revokes an inherited project role from a user in a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_user_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + role_id = self.role_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + role_id = "role_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .role_id("role_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + role_id = "role_id", + user_id = "user_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() + .domain_id("domain_id") + .role_id("role_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/get.rs b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/get.rs new file mode 100644 index 000000000..34f8b05b7 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/get.rs @@ -0,0 +1,210 @@ +// 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`. + +//! The list only contains those role assignments to the domain that were +//! specified as being inherited to projects within that domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_user_roles_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", + domain_id = "domain_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", + domain_id = "domain_id", + user_id = "user_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() + .domain_id("domain_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/head.rs b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/head.rs new file mode 100644 index 000000000..45141e06d --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/head.rs @@ -0,0 +1,204 @@ +// 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 roles (inherited) for a user on a domain. +//! +//! GET/HEAD /OS-INHERIT/domains/{domain_id}/users/{user_id} +//! /roles/inherited_to_projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", + domain_id = "domain_id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects", + domain_id = "domain_id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/inherited_to_projects.rs b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/inherited_to_projects.rs new file mode 100644 index 000000000..21f440ae7 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/domain/user/role/inherited_to_project/inherited_to_projects.rs @@ -0,0 +1,251 @@ +// 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`. + +//! Assigns a role to a user in projects owned by a domain. +//! +//! The inherited role is only applied to the owned projects (both existing and +//! future projects), and will not appear as a role in a domain scoped token. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/domain_user_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// domain_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + domain_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + domain_id = self.domain_id.as_ref(), + role_id = self.role_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + role_id = "role_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .domain_id("domain_id") + .role_id("role_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/domains/{domain_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + domain_id = "domain_id", + role_id = "role_id", + user_id = "user_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() + .domain_id("domain_id") + .role_id("role_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project.rs b/sdk/identity/src/v3/os_inherit/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/project.rs rename to sdk/identity/src/v3/os_inherit/project.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/group.rs b/sdk/identity/src/v3/os_inherit/project/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/project/group.rs rename to sdk/identity/src/v3/os_inherit/project/group.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role.rs b/sdk/identity/src/v3/os_inherit/project/group/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/project/group/role.rs rename to sdk/identity/src/v3/os_inherit/project/group/role.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project.rs b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/project/group/role/inherited_to_project.rs rename to sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project.rs diff --git a/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/delete.rs b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/delete.rs new file mode 100644 index 000000000..f02c7e64f --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/delete.rs @@ -0,0 +1,218 @@ +// 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`. + +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_group_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_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() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/get.rs b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/get.rs new file mode 100644 index 000000000..befb9ec16 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/get.rs @@ -0,0 +1,220 @@ +// 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`. + +//! Check for an inherited grant for a group on a project. +//! +//! GET/HEAD /OS-INHERIT/projects/{project_id}/groups/{group_id} +//! /roles/{role_id}/inherited_to_projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_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() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/head.rs b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/head.rs new file mode 100644 index 000000000..94b5ec218 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/head.rs @@ -0,0 +1,216 @@ +// 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`. + +//! Checks whether a group has a role assignment with the +//! `inherited_to_projects` flag in a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_group_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/inherited_to_projects.rs b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/inherited_to_projects.rs new file mode 100644 index 000000000..080a2bfb1 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/group/role/inherited_to_project/inherited_to_projects.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`. + +//! The inherited role assignment is anchored to a project and applied to its +//! subtree in the projects hierarchy (both existing and future projects). +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_group_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/projects/{project_id}/groups/{group_id}/roles/{role_id}/inherited_to_projects", + group_id = "group_id", + project_id = "project_id", + role_id = "role_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() + .group_id("group_id") + .project_id("project_id") + .role_id("role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/user.rs b/sdk/identity/src/v3/os_inherit/project/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/project/user.rs rename to sdk/identity/src/v3/os_inherit/project/user.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role.rs b/sdk/identity/src/v3/os_inherit/project/user/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/project/user/role.rs rename to sdk/identity/src/v3/os_inherit/project/user/role.rs diff --git a/openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project.rs b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_inherit/project/user/role/inherited_to_project.rs rename to sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project.rs diff --git a/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/delete.rs b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/delete.rs new file mode 100644 index 000000000..9f66c0fb3 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/delete.rs @@ -0,0 +1,218 @@ +// 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`. + +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_user_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + user_id = self.user_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_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() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/get.rs b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/get.rs new file mode 100644 index 000000000..1a7bbb0cc --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/get.rs @@ -0,0 +1,220 @@ +// 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`. + +//! Check for an inherited grant for a user on a project. +//! +//! GET/HEAD /OS-INHERIT/projects/{project_id}/users/{user_id} +//! /roles/{role_id}/inherited_to_projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + user_id = self.user_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_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() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/head.rs b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/head.rs new file mode 100644 index 000000000..579269751 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/head.rs @@ -0,0 +1,216 @@ +// 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`. + +//! Checks whether a user has a role assignment with the +//! `inherited_to_projects` flag in a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_user_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + user_id = self.user_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/inherited_to_projects.rs b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/inherited_to_projects.rs new file mode 100644 index 000000000..9a1ab0ef2 --- /dev/null +++ b/sdk/identity/src/v3/os_inherit/project/user/role/inherited_to_project/inherited_to_projects.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`. + +//! The inherited role assignment is anchored to a project and applied to its +//! subtree in the projects hierarchy (both existing and future projects). +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/ext/OS-INHERIT/1.0/rel/project_user_role_inherited_to_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + role_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects + /// API + #[builder(default, setter(into))] + user_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Inherited_To_Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = self.project_id.as_ref(), + role_id = self.role_id.as_ref(), + user_id = self.user_id.as_ref(), + ).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-INHERIT/projects/{project_id}/users/{user_id}/roles/{role_id}/inherited_to_projects", + project_id = "project_id", + role_id = "role_id", + user_id = "user_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() + .project_id("project_id") + .role_id("role_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1.rs b/sdk/identity/src/v3/os_oauth1.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_oauth1.rs rename to sdk/identity/src/v3/os_oauth1.rs diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/access_token.rs b/sdk/identity/src/v3/os_oauth1/access_token.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_oauth1/access_token.rs rename to sdk/identity/src/v3/os_oauth1/access_token.rs diff --git a/sdk/identity/src/v3/os_oauth1/access_token/create.rs b/sdk/identity/src/v3/os_oauth1/access_token/create.rs new file mode 100644 index 000000000..eeb161ab9 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/access_token/create.rs @@ -0,0 +1,202 @@ +// 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`. + +//! POST operation on /v3/OS-OAUTH1/access_token +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Access_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH1/access_token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH1/access_token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH1/access_token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/access_token/get.rs b/sdk/identity/src/v3/os_oauth1/access_token/get.rs new file mode 100644 index 000000000..a601d7a66 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/access_token/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 operation on /v3/OS-OAUTH1/access_token +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Access_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-OAUTH1/access_token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH1/access_token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH1/access_token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/access_token/head.rs b/sdk/identity/src/v3/os_oauth1/access_token/head.rs new file mode 100644 index 000000000..e3bf91d72 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/access_token/head.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`. + +//! HEAD operation on /v3/OS-OAUTH1/access_token +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Access_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH1/access_token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH1/access_token".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH1/access_token".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/authorize.rs b/sdk/identity/src/v3/os_oauth1/authorize.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_oauth1/authorize.rs rename to sdk/identity/src/v3/os_oauth1/authorize.rs diff --git a/sdk/identity/src/v3/os_oauth1/authorize/set.rs b/sdk/identity/src/v3/os_oauth1/authorize/set.rs new file mode 100644 index 000000000..51f451ce7 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/authorize/set.rs @@ -0,0 +1,221 @@ +// 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`. + +//! PUT operation on /v3/OS-OAUTH1/authorize/{request_token_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// request_token_id parameter for + /// /v3/OS-OAUTH1/authorize/{request_token_id} API + #[builder(default, setter(into))] + request_token_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Authorize. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-OAUTH1/authorize/{request_token_id}", + request_token_id = self.request_token_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/OS-OAUTH1/authorize/{request_token_id}", + request_token_id = "request_token_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .request_token_id("request_token_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/OS-OAUTH1/authorize/{request_token_id}", + request_token_id = "request_token_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() + .request_token_id("request_token_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/consumer.rs b/sdk/identity/src/v3/os_oauth1/consumer.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_oauth1/consumer.rs rename to sdk/identity/src/v3/os_oauth1/consumer.rs diff --git a/sdk/identity/src/v3/os_oauth1/consumer/create.rs b/sdk/identity/src/v3/os_oauth1/consumer/create.rs new file mode 100644 index 000000000..0426ab6b7 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/consumer/create.rs @@ -0,0 +1,202 @@ +// 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`. + +//! POST operation on /v3/OS-OAUTH1/consumers +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Consumer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH1/consumers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH1/consumers".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH1/consumers".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/consumer/delete.rs b/sdk/identity/src/v3/os_oauth1/consumer/delete.rs new file mode 100644 index 000000000..94357071c --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/consumer/delete.rs @@ -0,0 +1,181 @@ +// 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 operation on /v3/OS-OAUTH1/consumers/{consumer_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// consumer_id parameter for /v3/OS-OAUTH1/consumers/{consumer_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<'a> RequestBuilder<'a> { + /// Add a single header to the Consumer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-OAUTH1/consumers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-OAUTH1/consumers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-OAUTH1/consumers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/consumer/get.rs b/sdk/identity/src/v3/os_oauth1/consumer/get.rs new file mode 100644 index 000000000..6b18aafbd --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/consumer/get.rs @@ -0,0 +1,181 @@ +// 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 operation on /v3/OS-OAUTH1/consumers/{consumer_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// consumer_id parameter for /v3/OS-OAUTH1/consumers/{consumer_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<'a> RequestBuilder<'a> { + /// Add a single header to the Consumer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-OAUTH1/consumers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-OAUTH1/consumers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-OAUTH1/consumers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/consumer/head.rs b/sdk/identity/src/v3/os_oauth1/consumer/head.rs new file mode 100644 index 000000000..5248e0948 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/consumer/head.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`. + +//! HEAD operation on /v3/OS-OAUTH1/consumers +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Consumer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH1/consumers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH1/consumers".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH1/consumers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/consumer/list.rs b/sdk/identity/src/v3/os_oauth1/consumer/list.rs new file mode 100644 index 000000000..e62b0c72d --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/consumer/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`. + +//! GET operation on /v3/OS-OAUTH1/consumers +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Consumer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-OAUTH1/consumers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH1/consumers".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH1/consumers".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/consumer/set.rs b/sdk/identity/src/v3/os_oauth1/consumer/set.rs new file mode 100644 index 000000000..7073e4ea4 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/consumer/set.rs @@ -0,0 +1,208 @@ +// 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`. + +//! PATCH operation on /v3/OS-OAUTH1/consumers/{consumer_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// consumer_id parameter for /v3/OS-OAUTH1/consumers/{consumer_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Consumer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("OS-OAUTH1/consumers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-OAUTH1/consumers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/OS-OAUTH1/consumers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth1/request_token.rs b/sdk/identity/src/v3/os_oauth1/request_token.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_oauth1/request_token.rs rename to sdk/identity/src/v3/os_oauth1/request_token.rs diff --git a/sdk/identity/src/v3/os_oauth1/request_token/create.rs b/sdk/identity/src/v3/os_oauth1/request_token/create.rs new file mode 100644 index 000000000..9ebfca6b2 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/request_token/create.rs @@ -0,0 +1,202 @@ +// 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`. + +//! POST operation on /v3/OS-OAUTH1/request_token +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Request_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH1/request_token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH1/request_token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH1/request_token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/request_token/get.rs b/sdk/identity/src/v3/os_oauth1/request_token/get.rs new file mode 100644 index 000000000..e02984e8a --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/request_token/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 operation on /v3/OS-OAUTH1/request_token +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Request_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-OAUTH1/request_token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH1/request_token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH1/request_token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth1/request_token/head.rs b/sdk/identity/src/v3/os_oauth1/request_token/head.rs new file mode 100644 index 000000000..a1eb879bf --- /dev/null +++ b/sdk/identity/src/v3/os_oauth1/request_token/head.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`. + +//! HEAD operation on /v3/OS-OAUTH1/request_token +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Request_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH1/request_token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH1/request_token".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH1/request_token".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2.rs b/sdk/identity/src/v3/os_oauth2.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_oauth2.rs rename to sdk/identity/src/v3/os_oauth2.rs diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2/token.rs b/sdk/identity/src/v3/os_oauth2/token.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_oauth2/token.rs rename to sdk/identity/src/v3/os_oauth2/token.rs diff --git a/sdk/identity/src/v3/os_oauth2/token/create.rs b/sdk/identity/src/v3/os_oauth2/token/create.rs new file mode 100644 index 000000000..4eab63142 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth2/token/create.rs @@ -0,0 +1,204 @@ +// 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 an OAuth2.0 Access Token. +//! +//! POST /v3/OS-OAUTH2/token +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH2/token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH2/token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-OAUTH2/token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth2/token/delete.rs b/sdk/identity/src/v3/os_oauth2/token/delete.rs new file mode 100644 index 000000000..dbc43dd85 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth2/token/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`. + +//! The method is not allowed. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-OAUTH2/token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/OS-OAUTH2/token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/OS-OAUTH2/token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth2/token/get.rs b/sdk/identity/src/v3/os_oauth2/token/get.rs new file mode 100644 index 000000000..1861c1242 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth2/token/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`. + +//! The method is not allowed. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-OAUTH2/token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH2/token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-OAUTH2/token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth2/token/head.rs b/sdk/identity/src/v3/os_oauth2/token/head.rs new file mode 100644 index 000000000..b4c47a100 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth2/token/head.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`. + +//! The method is not allowed. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH2/token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH2/token".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-OAUTH2/token".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_oauth2/token/set.rs b/sdk/identity/src/v3/os_oauth2/token/set.rs new file mode 100644 index 000000000..3212b2097 --- /dev/null +++ b/sdk/identity/src/v3/os_oauth2/token/set.rs @@ -0,0 +1,202 @@ +// 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`. + +//! The method is not allowed. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-OAUTH2/token".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path("/OS-OAUTH2/token".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path("/OS-OAUTH2/token".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_oauth2/token/token.rs b/sdk/identity/src/v3/os_oauth2/token/token.rs similarity index 98% rename from openstack_sdk/src/api/identity/v3/os_oauth2/token/token.rs rename to sdk/identity/src/v3/os_oauth2/token/token.rs index 16e86339d..a33aa33aa 100644 --- a/openstack_sdk/src/api/identity/v3/os_oauth2/token/token.rs +++ b/sdk/identity/src/v3/os_oauth2/token/token.rs @@ -133,7 +133,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/identity/v3/os_revoke.rs b/sdk/identity/src/v3/os_revoke.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_revoke.rs rename to sdk/identity/src/v3/os_revoke.rs diff --git a/openstack_sdk/src/api/identity/v3/os_revoke/event.rs b/sdk/identity/src/v3/os_revoke/event.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_revoke/event.rs rename to sdk/identity/src/v3/os_revoke/event.rs diff --git a/sdk/identity/src/v3/os_revoke/event/get.rs b/sdk/identity/src/v3/os_revoke/event/get.rs new file mode 100644 index 000000000..4e89370cb --- /dev/null +++ b/sdk/identity/src/v3/os_revoke/event/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 operation on /v3/OS-REVOKE/events +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Event. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-REVOKE/events".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-REVOKE/events".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-REVOKE/events".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_revoke/event/head.rs b/sdk/identity/src/v3/os_revoke/event/head.rs new file mode 100644 index 000000000..56e5e8035 --- /dev/null +++ b/sdk/identity/src/v3/os_revoke/event/head.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`. + +//! HEAD operation on /v3/OS-REVOKE/events +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Event. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-REVOKE/events".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-REVOKE/events".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-REVOKE/events".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_simple_cert.rs b/sdk/identity/src/v3/os_simple_cert.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_simple_cert.rs rename to sdk/identity/src/v3/os_simple_cert.rs diff --git a/openstack_sdk/src/api/identity/v3/os_simple_cert/ca.rs b/sdk/identity/src/v3/os_simple_cert/ca.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_simple_cert/ca.rs rename to sdk/identity/src/v3/os_simple_cert/ca.rs diff --git a/sdk/identity/src/v3/os_simple_cert/ca/get.rs b/sdk/identity/src/v3/os_simple_cert/ca/get.rs new file mode 100644 index 000000000..baca67d7e --- /dev/null +++ b/sdk/identity/src/v3/os_simple_cert/ca/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 operation on /v3/OS-SIMPLE-CERT/ca +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Ca. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-SIMPLE-CERT/ca".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-SIMPLE-CERT/ca".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-SIMPLE-CERT/ca".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_simple_cert/ca/head.rs b/sdk/identity/src/v3/os_simple_cert/ca/head.rs new file mode 100644 index 000000000..3168eae23 --- /dev/null +++ b/sdk/identity/src/v3/os_simple_cert/ca/head.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`. + +//! HEAD operation on /v3/OS-SIMPLE-CERT/ca +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Ca. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-SIMPLE-CERT/ca".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-SIMPLE-CERT/ca".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-SIMPLE-CERT/ca".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_simple_cert/certificate.rs b/sdk/identity/src/v3/os_simple_cert/certificate.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_simple_cert/certificate.rs rename to sdk/identity/src/v3/os_simple_cert/certificate.rs diff --git a/sdk/identity/src/v3/os_simple_cert/certificate/get.rs b/sdk/identity/src/v3/os_simple_cert/certificate/get.rs new file mode 100644 index 000000000..ef483b519 --- /dev/null +++ b/sdk/identity/src/v3/os_simple_cert/certificate/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 operation on /v3/OS-SIMPLE-CERT/certificates +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Certificate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-SIMPLE-CERT/certificates".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-SIMPLE-CERT/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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-SIMPLE-CERT/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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_simple_cert/certificate/head.rs b/sdk/identity/src/v3/os_simple_cert/certificate/head.rs new file mode 100644 index 000000000..955c872ac --- /dev/null +++ b/sdk/identity/src/v3/os_simple_cert/certificate/head.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`. + +//! HEAD operation on /v3/OS-SIMPLE-CERT/certificates +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Certificate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-SIMPLE-CERT/certificates".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-SIMPLE-CERT/certificates".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-SIMPLE-CERT/certificates".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_trust.rs b/sdk/identity/src/v3/os_trust.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_trust.rs rename to sdk/identity/src/v3/os_trust.rs diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust.rs b/sdk/identity/src/v3/os_trust/trust.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_trust/trust.rs rename to sdk/identity/src/v3/os_trust/trust.rs diff --git a/sdk/identity/src/v3/os_trust/trust/create.rs b/sdk/identity/src/v3/os_trust/trust/create.rs new file mode 100644 index 000000000..fe29550db --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/create.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`. + +//! Create a new trust. +//! +//! The User creating the trust must be the trustor. +//! +//! POST /v3/OS-TRUST/trusts +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Roles<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The resource name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Trust<'a> { + /// If set to true then a trust between a trustor and any third-party user + /// may be issued by the trustee just like a regular trust. If set to + /// false, stops further redelegation. False by default. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allow_redelegation: Option>, + + /// Specifies the expiration time of the trust. A trust may be revoked + /// ahead of expiration. If the value represents a time in the past, the + /// trust is deactivated. In the redelegation case it must not exceed the + /// value of the corresponding expires_at field of the redelegated trust or + /// it may be omitted, then the expires_at value is copied from the + /// redelegated trust. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expires_at: Option>>, + + /// If set to true, then the user attribute of tokens generated based on + /// the trust will represent that of the trustor rather than the trustee, + /// thus allowing the trustee to impersonate the trustor. If impersonation + /// if set to false, then the token's user attribute will represent that of + /// the trustee. + #[serde()] + #[builder(setter(into))] + pub(crate) impersonation: bool, + + /// Identifies the project upon which the trustor is delegating + /// authorization. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>>, + + /// Returned with redelegated trust provides information about the + /// predecessor in the trust chain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redelegated_trust_id: Option>>, + + /// Specifies the maximum remaining depth of the redelegated trust chain. + /// Each subsequent trust has this field decremented by 1 automatically. + /// The initial trustor issuing new trust that can be redelegated, must set + /// allow_redelegation to true and may set redelegation_count to an integer + /// value less than or equal to max_redelegation_count configuration + /// parameter in order to limit the possible length of derived trust + /// chains. The trust issued by the trustor using a project-scoped token + /// (not redelegating), in which allow_redelegation is set to true (the new + /// trust is redelegatable), will be populated with the value specified in + /// the max_redelegation_count configuration parameter if + /// redelegation_count is not set or set to null. If allow_redelegation is + /// set to false then redelegation_count will be set to 0 in the trust. If + /// the trust is being issued by the trustee of a redelegatable + /// trust-scoped token (redelegation case) then redelegation_count should + /// not be set, as it will automatically be set to the value in the + /// redelegatable trust-scoped token decremented by 1. Note, if the + /// resulting value is 0, this means that the new trust will not be + /// redelegatable, regardless of the value of allow_redelegation. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redelegation_count: Option>, + + /// Specifies how many times the trust can be used to obtain a token. This + /// value is decreased each time a token is issued through the trust. Once + /// it reaches 0, no further tokens will be issued through the trust. The + /// default value is null, meaning there is no limit on the number of + /// tokens issued through the trust. If redelegation is enabled it must not + /// be set. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remaining_uses: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) roles: Option>>, + + /// Represents the user who is capable of consuming the trust. + #[serde()] + #[builder(setter(into))] + pub(crate) trustee_user_id: Cow<'a, str>, + + /// Represents the user who created the trust, and who's authorization is + /// being delegated. + #[serde()] + #[builder(setter(into))] + pub(crate) trustor_user_id: Cow<'a, str>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> TrustBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) trust: Trust<'a>, + + #[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 Trust. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-TRUST/trusts".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("trust", serde_json::to_value(&self.trust)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("trust".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .trust( + TrustBuilder::default() + .impersonation(false) + .trustee_user_id("foo") + .trustor_user_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .trust( + TrustBuilder::default() + .impersonation(false) + .trustee_user_id("foo") + .trustor_user_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "trust" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-TRUST/trusts".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "trust": {} })); + }); + + let endpoint = Request::builder() + .trust( + TrustBuilder::default() + .impersonation(false) + .trustee_user_id("foo") + .trustor_user_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/OS-TRUST/trusts".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "trust": {} })); + }); + + let endpoint = Request::builder() + .trust( + TrustBuilder::default() + .impersonation(false) + .trustee_user_id("foo") + .trustor_user_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_trust/trust/delete.rs b/sdk/identity/src/v3/os_trust/trust/delete.rs new file mode 100644 index 000000000..5939db797 --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/delete.rs @@ -0,0 +1,183 @@ +// 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 trust. +//! +//! DELETE /v3/OS-TRUST/trusts/{trust_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_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<'a> RequestBuilder<'a> { + /// Add a single header to the Trust. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-TRUST/trusts/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-TRUST/trusts/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/OS-TRUST/trusts/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_trust/trust/get.rs b/sdk/identity/src/v3/os_trust/trust/get.rs new file mode 100644 index 000000000..98f9bf8e6 --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/get.rs @@ -0,0 +1,186 @@ +// 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 trust. +//! +//! GET /v3/OS-TRUST/trusts/{trust_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_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<'a> RequestBuilder<'a> { + /// Add a single header to the Trust. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("OS-TRUST/trusts/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("trust".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "trust" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-TRUST/trusts/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "trust": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/OS-TRUST/trusts/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "trust": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_trust/trust/head.rs b/sdk/identity/src/v3/os_trust/trust/head.rs new file mode 100644 index 000000000..b5aca70c1 --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/head.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Dispatch for LIST trusts. +//! +//! GET /v3/OS-TRUST/trusts +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Represents the user who is capable of consuming the trust. + #[builder(default, setter(into))] + trustee_user_id: Option>, + + /// Represents the user who created the trust, and who's authorization is + /// being delegated. + #[builder(default, setter(into))] + trustor_user_id: 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> { + /// Add a single header to the Trust. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "OS-TRUST/trusts".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("trustee_user_id", self.trustee_user_id.as_ref()); + params.push_opt("trustor_user_id", self.trustor_user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-TRUST/trusts".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/OS-TRUST/trusts".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_trust/trust/list.rs b/sdk/identity/src/v3/os_trust/trust/list.rs new file mode 100644 index 000000000..a5927580e --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/list.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Dispatch for LIST trusts. +//! +//! GET /v3/OS-TRUST/trusts +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Represents the user who is capable of consuming the trust. + #[builder(default, setter(into))] + trustee_user_id: Option>, + + /// Represents the user who created the trust, and who's authorization is + /// being delegated. + #[builder(default, setter(into))] + trustor_user_id: 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> { + /// Add a single header to the Trust. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "OS-TRUST/trusts".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("trustee_user_id", self.trustee_user_id.as_ref()); + params.push_opt("trustor_user_id", self.trustor_user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("trusts".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "trusts" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-TRUST/trusts".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "trusts": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/OS-TRUST/trusts".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "trusts": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/os_trust/trust/role.rs b/sdk/identity/src/v3/os_trust/trust/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/os_trust/trust/role.rs rename to sdk/identity/src/v3/os_trust/trust/role.rs diff --git a/sdk/identity/src/v3/os_trust/trust/role/get.rs b/sdk/identity/src/v3/os_trust/trust/role/get.rs new file mode 100644 index 000000000..9b4a0c3b7 --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/role/get.rs @@ -0,0 +1,204 @@ +// 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 a role that has been assigned to a trust. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + trust_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-TRUST/trusts/{trust_id}/roles/{id}", + id = self.id.as_ref(), + trust_id = self.trust_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-TRUST/trusts/{trust_id}/roles/{id}", + id = "id", + trust_id = "trust_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .trust_id("trust_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-TRUST/trusts/{trust_id}/roles/{id}", + id = "id", + trust_id = "trust_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") + .trust_id("trust_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_trust/trust/role/head.rs b/sdk/identity/src/v3/os_trust/trust/role/head.rs new file mode 100644 index 000000000..43b3468f3 --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/role/head.rs @@ -0,0 +1,199 @@ +// 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 a role that has been assigned to a trust. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + trust_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "OS-TRUST/trusts/{trust_id}/roles/{id}", + id = self.id.as_ref(), + trust_id = self.trust_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/OS-TRUST/trusts/{trust_id}/roles/{id}", + id = "id", + trust_id = "trust_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .trust_id("trust_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/OS-TRUST/trusts/{trust_id}/roles/{id}", + id = "id", + trust_id = "trust_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .trust_id("trust_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/os_trust/trust/role/list.rs b/sdk/identity/src/v3/os_trust/trust/role/list.rs new file mode 100644 index 000000000..f896ceef0 --- /dev/null +++ b/sdk/identity/src/v3/os_trust/trust/role/list.rs @@ -0,0 +1,191 @@ +// 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 operation on /v3/OS-TRUST/trusts/{trust_id}/roles +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// trust_id parameter for /v3/OS-TRUST/trusts/{trust_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + trust_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "OS-TRUST/trusts/{trust_id}/roles", + trust_id = self.trust_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/OS-TRUST/trusts/{trust_id}/roles", + trust_id = "trust_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().trust_id("trust_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/OS-TRUST/trusts/{trust_id}/roles", + trust_id = "trust_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() + .trust_id("trust_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/policy.rs b/sdk/identity/src/v3/policy.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/policy.rs rename to sdk/identity/src/v3/policy.rs diff --git a/sdk/identity/src/v3/policy/create.rs b/sdk/identity/src/v3/policy/create.rs new file mode 100644 index 000000000..3be862fba --- /dev/null +++ b/sdk/identity/src/v3/policy/create.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Creates a policy. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/policies` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/policies".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/policies".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/delete.rs b/sdk/identity/src/v3/policy/delete.rs new file mode 100644 index 000000000..d44b801b8 --- /dev/null +++ b/sdk/identity/src/v3/policy/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes a policy. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/policy` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// policy_id parameter for /v3/policies/{policy_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<'a> RequestBuilder<'a> { + /// Add a single header to the Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/policies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/policies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/get.rs b/sdk/identity/src/v3/policy/get.rs new file mode 100644 index 000000000..4a6bdb1b6 --- /dev/null +++ b/sdk/identity/src/v3/policy/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Shows details for a policy. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/policy` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// policy_id parameter for /v3/policies/{policy_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<'a> RequestBuilder<'a> { + /// Add a single header to the Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/policies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/policies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/head.rs b/sdk/identity/src/v3/policy/head.rs new file mode 100644 index 000000000..4dab3cb9b --- /dev/null +++ b/sdk/identity/src/v3/policy/head.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`. + +//! HEAD operation on /v3/policies +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/policies".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/policies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/list.rs b/sdk/identity/src/v3/policy/list.rs new file mode 100644 index 000000000..d16158650 --- /dev/null +++ b/sdk/identity/src/v3/policy/list.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`. + +//! Lists policies. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/policies` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/policies".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/policies".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy.rs b/sdk/identity/src/v3/policy/os_endpoint_policy.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy.rs rename to sdk/identity/src/v3/policy/os_endpoint_policy.rs diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/endpoint.rs rename to sdk/identity/src/v3/policy/os_endpoint_policy/endpoint.rs diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/delete.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/delete.rs new file mode 100644 index 000000000..d428c3d42 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/delete.rs @@ -0,0 +1,205 @@ +// 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 operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + policy_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/get.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/get.rs new file mode 100644 index 000000000..4e0fdef55 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/get.rs @@ -0,0 +1,205 @@ +// 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 operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + policy_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/head.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/head.rs new file mode 100644 index 000000000..90e225031 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/head.rs @@ -0,0 +1,200 @@ +// 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`. + +//! HEAD operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + policy_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/list.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/list.rs new file mode 100644 index 000000000..f73c7e29e --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/list.rs @@ -0,0 +1,191 @@ +// 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 operation on /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + policy_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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints", + policy_id = "policy_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() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/set.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/set.rs new file mode 100644 index 000000000..68f2e78d9 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/endpoint/set.rs @@ -0,0 +1,232 @@ +// 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`. + +//! PUT operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// endpoint_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Endpoint. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service.rs rename to sdk/identity/src/v3/policy/os_endpoint_policy/service.rs diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/delete.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/delete.rs new file mode 100644 index 000000000..bffa3cb89 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/delete.rs @@ -0,0 +1,205 @@ +// 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 operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + policy_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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_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() + .policy_id("policy_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/get.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/get.rs new file mode 100644 index 000000000..93825f030 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/get.rs @@ -0,0 +1,205 @@ +// 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 operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + policy_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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_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() + .policy_id("policy_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/head.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/head.rs new file mode 100644 index 000000000..a136844e0 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/head.rs @@ -0,0 +1,200 @@ +// 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`. + +//! HEAD operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + policy_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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_id", + id = "id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/policy/os_endpoint_policy/service/region.rs rename to sdk/identity/src/v3/policy/os_endpoint_policy/service/region.rs diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/delete.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/delete.rs new file mode 100644 index 000000000..5cf485553 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/delete.rs @@ -0,0 +1,218 @@ +// 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 operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// region_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + service_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 Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + service_id = self.service_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_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() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/get.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/get.rs new file mode 100644 index 000000000..574295c1c --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/get.rs @@ -0,0 +1,218 @@ +// 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 operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// region_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + service_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 Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + service_id = self.service_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_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() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/head.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/head.rs new file mode 100644 index 000000000..232d5fd09 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/head.rs @@ -0,0 +1,213 @@ +// 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`. + +//! HEAD operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// region_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + service_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 Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + service_id = self.service_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/set.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/set.rs new file mode 100644 index 000000000..bfd89da25 --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/region/set.rs @@ -0,0 +1,245 @@ +// 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`. + +//! PUT operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// region_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{region_id} + /// API + #[builder(default, setter(into))] + service_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + service_id = self.service_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id}/regions/{id}", + policy_id = "policy_id", + id = "id", + service_id = "service_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() + .policy_id("policy_id") + .id("id") + .service_id("service_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/os_endpoint_policy/service/set.rs b/sdk/identity/src/v3/policy/os_endpoint_policy/service/set.rs new file mode 100644 index 000000000..913be6a1b --- /dev/null +++ b/sdk/identity/src/v3/policy/os_endpoint_policy/service/set.rs @@ -0,0 +1,232 @@ +// 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`. + +//! PUT operation on +//! /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v3/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{service_id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = self.policy_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/policies/{policy_id}/OS-ENDPOINT-POLICY/services/{id}", + policy_id = "policy_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() + .policy_id("policy_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/policy/set.rs b/sdk/identity/src/v3/policy/set.rs new file mode 100644 index 000000000..c253c3c75 --- /dev/null +++ b/sdk/identity/src/v3/policy/set.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`. + +//! Updates a policy. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/policy` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// policy_id parameter for /v3/policies/{policy_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PATCH + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/policies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/policies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/project.rs b/sdk/identity/src/v3/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/project.rs rename to sdk/identity/src/v3/project.rs diff --git a/sdk/identity/src/v3/project/create.rs b/sdk/identity/src/v3/project/create.rs new file mode 100644 index 000000000..d7d9ace6a --- /dev/null +++ b/sdk/identity/src/v3/project/create.rs @@ -0,0 +1,293 @@ +// 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`. + +//! Creates a project, where the project may act as a domain. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The resource options for the project. Available resource options are +/// `immutable`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) immutable: Option, +} + +/// A `project` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Project<'a> { + /// The description of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the domain for the project. + /// + /// For projects acting as a domain, the `domain_id` must not be specified, + /// it will be generated by the Identity service implementation. + /// + /// For regular projects (i.e. those not acing as a domain), if `domain_id` + /// is not specified, but `parent_id` is specified, then the domain ID of + /// the parent will be used. If neither `domain_id` or `parent_id` is + /// specified, the Identity service implementation will default to the + /// domain to which the client’s token is scoped. If both `domain_id` and + /// `parent_id` are specified, and they do not indicate the same domain, an + /// `Bad Request (400)` will be returned. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>>, + + /// If set to `true`, project is enabled. If set to `false`, project is + /// disabled. The default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// If set to `true`, project is enabled. If set to `false`, project is + /// disabled. The default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_domain: Option, + + /// The name of the project, which must be unique within the owning domain. + /// A project can have the same name as its domain. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The resource options for the project. Available resource options are + /// `immutable`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option, + + /// The ID of the parent of the project. + /// + /// If specified on project creation, this places the project within a + /// hierarchy and implicitly defines the owning domain, which will be the + /// same domain as the parent specified. If `parent_id` is not specified + /// and `is_domain` is `false`, then the project will use its owning domain + /// as its parent. If `is_domain` is `true` (i.e. the project is acting as + /// a domain), then `parent_id` must not specified (or if it is, it must be + /// `null`) since domains have no parents. + /// + /// `parent_id` is immutable, and can’t be updated after the project is + /// created - hence a project cannot be moved within the hierarchy. + /// + /// **New in version 3.4** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) parent_id: Option>>, + + /// A list of simple strings assigned to a project. Tags can be used to + /// classify projects into groups. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `project` object + #[builder(setter(into))] + pub(crate) project: Project<'a>, + + #[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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "projects".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("project", serde_json::to_value(&self.project)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("project".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .project(ProjectBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .project(ProjectBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "project" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/projects".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "project": {} })); + }); + + let endpoint = Request::builder() + .project(ProjectBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/projects".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "project": {} })); + }); + + let endpoint = Request::builder() + .project(ProjectBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/delete.rs b/sdk/identity/src/v3/project/delete.rs new file mode 100644 index 000000000..56b6d1e07 --- /dev/null +++ b/sdk/identity/src/v3/project/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("projects/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/projects/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/projects/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/find.rs b/sdk/identity/src/v3/project/find.rs new file mode 100644 index 000000000..3eafa8e48 --- /dev/null +++ b/sdk/identity/src/v3/project/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v3::project::{get as Get, list as List}; + +/// Find for project 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/identity/src/v3/project/get.rs b/sdk/identity/src/v3/project/get.rs new file mode 100644 index 000000000..3834b2845 --- /dev/null +++ b/sdk/identity/src/v3/project/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("projects/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("project".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "project" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/projects/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "project": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/projects/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "project": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/project/group.rs b/sdk/identity/src/v3/project/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/project/group.rs rename to sdk/identity/src/v3/project/group.rs diff --git a/openstack_sdk/src/api/identity/v3/project/group/role.rs b/sdk/identity/src/v3/project/group/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/project/group/role.rs rename to sdk/identity/src/v3/project/group/role.rs diff --git a/sdk/identity/src/v3/project/group/role/delete.rs b/sdk/identity/src/v3/project/group/role/delete.rs new file mode 100644 index 000000000..a77ac7b7d --- /dev/null +++ b/sdk/identity/src/v3/project/group/role/delete.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Unassigns a role from a group on a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + project_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = "group_id", + project_id = "project_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = "group_id", + project_id = "project_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() + .group_id("group_id") + .project_id("project_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/group/role/get.rs b/sdk/identity/src/v3/project/group/role/get.rs new file mode 100644 index 000000000..fe3adfe75 --- /dev/null +++ b/sdk/identity/src/v3/project/group/role/get.rs @@ -0,0 +1,216 @@ +// 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`. + +//! Check grant for project, group, role. +//! +//! GET/HEAD /v3/projects/{project_id/groups/{group_id}/roles/{role_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + project_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = "group_id", + project_id = "project_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = "group_id", + project_id = "project_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() + .group_id("group_id") + .project_id("project_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/group/role/head.rs b/sdk/identity/src/v3/project/group/role/head.rs new file mode 100644 index 000000000..7b8293b07 --- /dev/null +++ b/sdk/identity/src/v3/project/group/role/head.rs @@ -0,0 +1,201 @@ +// 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 grants for group on project. +//! +//! GET/HEAD /v3/projects/{project_id}/groups/{group_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + project_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "projects/{project_id}/groups/{group_id}/roles", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/projects/{project_id}/groups/{group_id}/roles", + group_id = "group_id", + project_id = "project_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/projects/{project_id}/groups/{group_id}/roles", + group_id = "group_id", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/group/role/list.rs b/sdk/identity/src/v3/project/group/role/list.rs new file mode 100644 index 000000000..bfff8364e --- /dev/null +++ b/sdk/identity/src/v3/project/group/role/list.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Lists role assignments for a group on a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + project_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/groups/{group_id}/roles", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("roles".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "roles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/projects/{project_id}/groups/{group_id}/roles", + group_id = "group_id", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/projects/{project_id}/groups/{group_id}/roles", + group_id = "group_id", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/group/role/set.rs b/sdk/identity/src/v3/project/group/role/set.rs new file mode 100644 index 000000000..e83d4ab51 --- /dev/null +++ b/sdk/identity/src/v3/project/group/role/set.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Assigns a role to a group on a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/groups/{group_id}/roles API + #[builder(default, setter(into))] + project_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = self.group_id.as_ref(), + project_id = self.project_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = "group_id", + project_id = "project_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .project_id("project_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/projects/{project_id}/groups/{group_id}/roles/{id}", + group_id = "group_id", + project_id = "project_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() + .group_id("group_id") + .project_id("project_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/head.rs b/sdk/identity/src/v3/project/head.rs new file mode 100644 index 000000000..d81ae9308 --- /dev/null +++ b/sdk/identity/src/v3/project/head.rs @@ -0,0 +1,178 @@ +// 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 project. +//! +//! GET/HEAD /v3/projects/{project_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("projects/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/projects/{id}", id = "id",)); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/projects/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/list.rs b/sdk/identity/src/v3/project/list.rs new file mode 100644 index 000000000..30a823b58 --- /dev/null +++ b/sdk/identity/src/v3/project/list.rs @@ -0,0 +1,233 @@ +// 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`. + +//! Lists projects. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + #[builder(default)] + enabled: Option, + + #[builder(default)] + is_domain: Option, + + #[builder(default)] + limit: Option, + + /// ID of the last fetched entry + #[builder(default, setter(into))] + marker: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: Option>, + + #[builder(default, setter(into))] + not_tags: Option>, + + #[builder(default, setter(into))] + not_tags_any: Option>, + + #[builder(default, setter(into))] + parent_id: Option>, + + #[builder(default, setter(into))] + tags: Option>, + + #[builder(default, setter(into))] + tags_any: 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> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "projects".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("enabled", self.enabled); + params.push_opt("is_domain", self.is_domain); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("parent_id", self.parent_id.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("projects".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "projects" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/projects".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/projects".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/set.rs b/sdk/identity/src/v3/project/set.rs new file mode 100644 index 000000000..ccb20cb82 --- /dev/null +++ b/sdk/identity/src/v3/project/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`. + +//! Updates a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// The resource options for the project. Available resource options are +/// `immutable`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) immutable: Option, +} + +/// A `project` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Project<'a> { + /// The description of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// If set to `true`, project is enabled. If set to `false`, project is + /// disabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The name of the project, which must be unique within the owning domain. + /// A project can have the same name as its domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The resource options for the project. Available resource options are + /// `immutable`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option, + + /// A list of simple strings assigned to a project. Tags can be used to + /// classify projects into groups. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `project` object + #[builder(setter(into))] + pub(crate) project: Project<'a>, + + /// project_id parameter for /v3/projects/{project_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<'a> RequestBuilder<'a> { + /// Add a single header to the Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("projects/{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("project", serde_json::to_value(&self.project)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("project".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .project(ProjectBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .project(ProjectBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "project" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/projects/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "project": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .project(ProjectBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/projects/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "project": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .project(ProjectBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/project/tag.rs b/sdk/identity/src/v3/project/tag.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/project/tag.rs rename to sdk/identity/src/v3/project/tag.rs diff --git a/sdk/identity/src/v3/project/tag/delete.rs b/sdk/identity/src/v3/project/tag/delete.rs new file mode 100644 index 000000000..564cc4e05 --- /dev/null +++ b/sdk/identity/src/v3/project/tag/delete.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Remove a single tag from a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// value parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + value: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/tags/{value}", + project_id = self.project_id.as_ref(), + value = self.value.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/tag/delete_all.rs b/sdk/identity/src/v3/project/tag/delete_all.rs new file mode 100644 index 000000000..2ce8a0d92 --- /dev/null +++ b/sdk/identity/src/v3/project/tag/delete_all.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Remove all tags from a given project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + project_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/tags", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/projects/{project_id}/tags", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/projects/{project_id}/tags", + project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/tag/get.rs b/sdk/identity/src/v3/project/tag/get.rs new file mode 100644 index 000000000..7e1013ad1 --- /dev/null +++ b/sdk/identity/src/v3/project/tag/get.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Checks if a project contains the specified tag. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// value parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + value: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/tags/{value}", + project_id = self.project_id.as_ref(), + value = self.value.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/tag/head.rs b/sdk/identity/src/v3/project/tag/head.rs new file mode 100644 index 000000000..96560350c --- /dev/null +++ b/sdk/identity/src/v3/project/tag/head.rs @@ -0,0 +1,199 @@ +// 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 information for a single tag associated with a given project. +//! +//! GET /v3/projects/{project_id}/tags/{value} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// value parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + value: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "projects/{project_id}/tags/{value}", + project_id = self.project_id.as_ref(), + value = self.value.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/tag/list.rs b/sdk/identity/src/v3/project/tag/list.rs new file mode 100644 index 000000000..eb4bcf502 --- /dev/null +++ b/sdk/identity/src/v3/project/tag/list.rs @@ -0,0 +1,196 @@ +// 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`. + +//! Lists all tags within a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + project_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/tags", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("tags".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/projects/{project_id}/tags", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/projects/{project_id}/tags", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/tag/replace.rs b/sdk/identity/src/v3/project/tag/replace.rs new file mode 100644 index 000000000..3ab3ad6db --- /dev/null +++ b/sdk/identity/src/v3/project/tag/replace.rs @@ -0,0 +1,223 @@ +// 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`. + +//! Modifies the tags for a project. Any existing tags not specified will be +//! deleted. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A list of simple strings assigned to a project. + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// project_id parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + project_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "projects/{project_id}/tags", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("tags".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/projects/{project_id}/tags", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/projects/{project_id}/tags", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/tag/set.rs b/sdk/identity/src/v3/project/tag/set.rs new file mode 100644 index 000000000..a0e20b020 --- /dev/null +++ b/sdk/identity/src/v3/project/tag/set.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Creates the specified tag and adds it to the list of tags in the project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// value parameter for /v3/projects/{project_id}/tags/{value} API + #[builder(default, setter(into))] + value: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "projects/{project_id}/tags/{value}", + project_id = self.project_id.as_ref(), + value = self.value.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/projects/{project_id}/tags/{value}", + project_id = "project_id", + value = "value", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .value("value") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/project/user.rs b/sdk/identity/src/v3/project/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/project/user.rs rename to sdk/identity/src/v3/project/user.rs diff --git a/openstack_sdk/src/api/identity/v3/project/user/role.rs b/sdk/identity/src/v3/project/user/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/project/user/role.rs rename to sdk/identity/src/v3/project/user/role.rs diff --git a/sdk/identity/src/v3/project/user/role/delete.rs b/sdk/identity/src/v3/project/user/role/delete.rs new file mode 100644 index 000000000..f8788a9eb --- /dev/null +++ b/sdk/identity/src/v3/project/user/role/delete.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Unassigns a role from a user on a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/users/{user_id}/roles/{id}", + project_id = self.project_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/projects/{project_id}/users/{user_id}/roles/{id}", + project_id = "project_id", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/projects/{project_id}/users/{user_id}/roles/{id}", + project_id = "project_id", + id = "id", + user_id = "user_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() + .project_id("project_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/user/role/get.rs b/sdk/identity/src/v3/project/user/role/get.rs new file mode 100644 index 000000000..03a5cca08 --- /dev/null +++ b/sdk/identity/src/v3/project/user/role/get.rs @@ -0,0 +1,216 @@ +// 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`. + +//! Check grant for project, user, role. +//! +//! GET/HEAD /v3/projects/{project_id/users/{user_id}/roles/{role_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/users/{user_id}/roles/{id}", + project_id = self.project_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/projects/{project_id}/users/{user_id}/roles/{id}", + project_id = "project_id", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/projects/{project_id}/users/{user_id}/roles/{id}", + project_id = "project_id", + id = "id", + user_id = "user_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() + .project_id("project_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/user/role/head.rs b/sdk/identity/src/v3/project/user/role/head.rs new file mode 100644 index 000000000..387502a5e --- /dev/null +++ b/sdk/identity/src/v3/project/user/role/head.rs @@ -0,0 +1,201 @@ +// 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 grants for user on project. +//! +//! GET/HEAD /v3/projects/{project_id}/users/{user_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "projects/{project_id}/users/{user_id}/roles", + project_id = self.project_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/projects/{project_id}/users/{user_id}/roles", + project_id = "project_id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/projects/{project_id}/users/{user_id}/roles", + project_id = "project_id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/user/role/list.rs b/sdk/identity/src/v3/project/user/role/list.rs new file mode 100644 index 000000000..7ea3f0384 --- /dev/null +++ b/sdk/identity/src/v3/project/user/role/list.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Lists role assignments for a user on a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "projects/{project_id}/users/{user_id}/roles", + project_id = self.project_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("roles".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "roles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/projects/{project_id}/users/{user_id}/roles", + project_id = "project_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/projects/{project_id}/users/{user_id}/roles", + project_id = "project_id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/project/user/role/set.rs b/sdk/identity/src/v3/project/user/role/set.rs new file mode 100644 index 000000000..03bb5193f --- /dev/null +++ b/sdk/identity/src/v3/project/user/role/set.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Assigns a role to a user on a project. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/project_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// project_id parameter for + /// /v3/projects/{project_id}/users/{user_id}/roles API + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// user_id parameter for /v3/projects/{project_id}/users/{user_id}/roles + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "projects/{project_id}/users/{user_id}/roles/{id}", + project_id = self.project_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/projects/{project_id}/users/{user_id}/roles/{id}", + project_id = "project_id", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/projects/{project_id}/users/{user_id}/roles/{id}", + project_id = "project_id", + id = "id", + user_id = "user_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() + .project_id("project_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/region.rs b/sdk/identity/src/v3/region.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/region.rs rename to sdk/identity/src/v3/region.rs diff --git a/sdk/identity/src/v3/region/create.rs b/sdk/identity/src/v3/region/create.rs new file mode 100644 index 000000000..e4a4e5665 --- /dev/null +++ b/sdk/identity/src/v3/region/create.rs @@ -0,0 +1,256 @@ +// 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`. + +//! Creates a region. +//! +//! When you create the region, you can optionally specify a region ID. If you +//! include characters in the region ID that are not allowed in a URI, you must +//! URL-encode the ID. If you omit an ID, the API assigns an ID to the region. +//! +//! The following errors might occur: +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/regions` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `region` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Region<'a> { + /// The region description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID for the region. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>>, + + /// To make this region a child of another region, set this parameter to + /// the ID of the parent region. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) parent_region_id: Option>>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> RegionBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `region` object + #[builder(setter(into))] + pub(crate) region: Region<'a>, + + #[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 Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "regions".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("region", serde_json::to_value(&self.region)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("region".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .region(RegionBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .region(RegionBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "region" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/regions".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "region": {} })); + }); + + let endpoint = Request::builder() + .region(RegionBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/regions".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "region": {} })); + }); + + let endpoint = Request::builder() + .region(RegionBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/region/delete.rs b/sdk/identity/src/v3/region/delete.rs new file mode 100644 index 000000000..71d5a7ba5 --- /dev/null +++ b/sdk/identity/src/v3/region/delete.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Deletes a region. +//! +//! The following error might occur: +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/region` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// region_id parameter for /v3/regions/{region_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<'a> RequestBuilder<'a> { + /// Add a single header to the Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("regions/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/regions/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/regions/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/region/get.rs b/sdk/identity/src/v3/region/get.rs new file mode 100644 index 000000000..e1d4cdb32 --- /dev/null +++ b/sdk/identity/src/v3/region/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a region, by ID. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/regions` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// region_id parameter for /v3/regions/{region_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<'a> RequestBuilder<'a> { + /// Add a single header to the Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("regions/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("region".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "region" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/regions/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "region": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/regions/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "region": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/region/head.rs b/sdk/identity/src/v3/region/head.rs new file mode 100644 index 000000000..d258da60d --- /dev/null +++ b/sdk/identity/src/v3/region/head.rs @@ -0,0 +1,178 @@ +// 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`. + +//! HEAD operation on /v3/regions +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the region. + #[builder(default, setter(into))] + parent_region_id: 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> { + /// Add a single header to the Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "regions".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("parent_region_id", self.parent_region_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/regions".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/regions".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/region/list.rs b/sdk/identity/src/v3/region/list.rs new file mode 100644 index 000000000..719ac70d5 --- /dev/null +++ b/sdk/identity/src/v3/region/list.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Lists regions. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/regions` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the region. + #[builder(default, setter(into))] + parent_region_id: 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> { + /// Add a single header to the Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "regions".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("parent_region_id", self.parent_region_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("regions".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "regions" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/regions".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "regions": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/regions".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "regions": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/region/set.rs b/sdk/identity/src/v3/region/set.rs new file mode 100644 index 000000000..435981aca --- /dev/null +++ b/sdk/identity/src/v3/region/set.rs @@ -0,0 +1,261 @@ +// 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`. + +//! Updates a region. +//! +//! You can update the description or parent region ID for a region. You cannot +//! update the region ID. +//! +//! The following error might occur: +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/region` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `region` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Region<'a> { + /// The region description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The region ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>>, + + /// To make this region a child of another region, set this parameter to + /// the ID of the parent region. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) parent_region_id: Option>>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> RegionBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `region` object + #[builder(setter(into))] + pub(crate) region: Region<'a>, + + /// region_id parameter for /v3/regions/{region_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<'a> RequestBuilder<'a> { + /// Add a single header to the Region. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("regions/{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("region", serde_json::to_value(&self.region)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("region".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .region(RegionBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .region(RegionBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "region" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/regions/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "region": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .region(RegionBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/regions/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "region": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .region(RegionBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/registered_limit.rs b/sdk/identity/src/v3/registered_limit.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/registered_limit.rs rename to sdk/identity/src/v3/registered_limit.rs diff --git a/sdk/identity/src/v3/registered_limit/create.rs b/sdk/identity/src/v3/registered_limit/create.rs new file mode 100644 index 000000000..145e5205a --- /dev/null +++ b/sdk/identity/src/v3/registered_limit/create.rs @@ -0,0 +1,262 @@ +// 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`. + +//! Creates registered limits. It supports to create more than one registered +//! limit in one request. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limits` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RegisteredLimits<'a> { + /// The default limit for the registered limit. + #[serde()] + #[builder(setter(into))] + pub(crate) default_limit: i32, + + /// The registered limit description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the region that contains the service endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region_id: Option>>, + + /// The resource name. + #[serde()] + #[builder(setter(into))] + pub(crate) resource_name: Cow<'a, str>, + + /// The UUID of the service to which the registered limit belongs. + #[serde()] + #[builder(setter(into))] + pub(crate) service_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A list of `registered_limits` objects + #[builder(setter(into))] + pub(crate) registered_limits: Vec>, + + #[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 Registered_Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "registered_limits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "registered_limits", + serde_json::to_value(&self.registered_limits)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("registered_limits".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .registered_limits(Vec::from([RegisteredLimitsBuilder::default() + .default_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .registered_limits(Vec::from([RegisteredLimitsBuilder::default() + .default_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "registered_limits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/registered_limits".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limits": {} })); + }); + + let endpoint = Request::builder() + .registered_limits(Vec::from([RegisteredLimitsBuilder::default() + .default_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/registered_limits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limits": {} })); + }); + + let endpoint = Request::builder() + .registered_limits(Vec::from([RegisteredLimitsBuilder::default() + .default_limit(123) + .resource_name("foo") + .service_id("foo") + .build() + .unwrap()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/registered_limit/delete.rs b/sdk/identity/src/v3/registered_limit/delete.rs new file mode 100644 index 000000000..441d9a1a2 --- /dev/null +++ b/sdk/identity/src/v3/registered_limit/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a registered limit. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limit` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// registered_limit_id parameter for + /// /v3/registered_limits/{registered_limit_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<'a> RequestBuilder<'a> { + /// Add a single header to the Registered_Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("registered_limits/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/registered_limits/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/registered_limits/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/registered_limit/get.rs b/sdk/identity/src/v3/registered_limit/get.rs new file mode 100644 index 000000000..0f1fe2e7b --- /dev/null +++ b/sdk/identity/src/v3/registered_limit/get.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Shows details for a registered limit. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limit` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// registered_limit_id parameter for + /// /v3/registered_limits/{registered_limit_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<'a> RequestBuilder<'a> { + /// Add a single header to the Registered_Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("registered_limits/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("registered_limit".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "registered_limit" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/registered_limits/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limit": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/registered_limits/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limit": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/registered_limit/head.rs b/sdk/identity/src/v3/registered_limit/head.rs new file mode 100644 index 000000000..0905e30e7 --- /dev/null +++ b/sdk/identity/src/v3/registered_limit/head.rs @@ -0,0 +1,190 @@ +// 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 registered limits. +//! +//! GET /v3/registered_limits +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the region. + #[builder(default, setter(into))] + region_id: Option>, + + /// The resource name. + #[builder(default, setter(into))] + resource_name: Option>, + + /// Filters the response by a service ID. + #[builder(default, setter(into))] + service_id: 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> { + /// Add a single header to the Registered_Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "registered_limits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("region_id", self.region_id.as_ref()); + params.push_opt("resource_name", self.resource_name.as_ref()); + params.push_opt("service_id", self.service_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/registered_limits".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/registered_limits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/registered_limit/list.rs b/sdk/identity/src/v3/registered_limit/list.rs new file mode 100644 index 000000000..4f4d6c08c --- /dev/null +++ b/sdk/identity/src/v3/registered_limit/list.rs @@ -0,0 +1,199 @@ +// 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`. + +//! Lists Registered Limits. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limits` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the region. + #[builder(default, setter(into))] + region_id: Option>, + + /// The resource name. + #[builder(default, setter(into))] + resource_name: Option>, + + /// Filters the response by a service ID. + #[builder(default, setter(into))] + service_id: 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> { + /// Add a single header to the Registered_Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "registered_limits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("region_id", self.region_id.as_ref()); + params.push_opt("resource_name", self.resource_name.as_ref()); + params.push_opt("service_id", self.service_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("registered_limits".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "registered_limits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/registered_limits".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limits": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/registered_limits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limits": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/registered_limit/set.rs b/sdk/identity/src/v3/registered_limit/set.rs new file mode 100644 index 000000000..fc4f1cb3d --- /dev/null +++ b/sdk/identity/src/v3/registered_limit/set.rs @@ -0,0 +1,254 @@ +// 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`. + +//! Updates the specified registered limit. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/registered_limit` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `registered_limit` objects +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RegisteredLimit<'a> { + /// The default limit for the registered limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_limit: Option, + + /// The registered limit description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the region that contains the service endpoint. Either + /// service_id, resource_name, or region_id must be different than existing + /// value otherwise it will raise 409. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) region_id: Option>>, + + /// The resource name. Either service_id, resource_name or region_id must + /// be different than existing value otherwise it will raise 409. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) resource_name: Option>, + + /// The UUID of the service to update to which the registered limit + /// belongs. Either service_id, resource_name, or region_id must be + /// different than existing value otherwise it will raise 409. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `registered_limit` objects + #[builder(setter(into))] + pub(crate) registered_limit: RegisteredLimit<'a>, + + /// registered_limit_id parameter for + /// /v3/registered_limits/{registered_limit_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<'a> RequestBuilder<'a> { + /// Add a single header to the Registered_Limit. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("registered_limits/{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( + "registered_limit", + serde_json::to_value(&self.registered_limit)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("registered_limit".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "registered_limit" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/registered_limits/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limit": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/registered_limits/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "registered_limit": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .registered_limit(RegisteredLimitBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/role.rs b/sdk/identity/src/v3/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/role.rs rename to sdk/identity/src/v3/role.rs diff --git a/sdk/identity/src/v3/role/create.rs b/sdk/identity/src/v3/role/create.rs new file mode 100644 index 000000000..a18e74c02 --- /dev/null +++ b/sdk/identity/src/v3/role/create.rs @@ -0,0 +1,265 @@ +// 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`. + +//! Creates a role. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/roles` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// The resource options for the role. Available resource options are +/// `immutable`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) immutable: Option, +} + +/// A `role` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Role<'a> { + /// Add description about the role. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the domain of the role. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>>, + + /// The role name. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The resource options for the role. Available resource options are + /// `immutable`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> RoleBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `role` object + #[builder(setter(into))] + pub(crate) role: Role<'a>, + + #[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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "roles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("role", serde_json::to_value(&self.role)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .role(RoleBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .role(RoleBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "role" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/roles".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role": {} })); + }); + + let endpoint = Request::builder() + .role(RoleBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/roles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role": {} })); + }); + + let endpoint = Request::builder() + .role(RoleBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/delete.rs b/sdk/identity/src/v3/role/delete.rs new file mode 100644 index 000000000..f138f5246 --- /dev/null +++ b/sdk/identity/src/v3/role/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes a role. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("roles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/roles/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/roles/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/find.rs b/sdk/identity/src/v3/role/find.rs new file mode 100644 index 000000000..e00018672 --- /dev/null +++ b/sdk/identity/src/v3/role/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::role::{get as Get, list as List}; + +/// Find for role 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate role in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // role 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/identity/src/v3/role/get.rs b/sdk/identity/src/v3/role/get.rs new file mode 100644 index 000000000..2a6d67319 --- /dev/null +++ b/sdk/identity/src/v3/role/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a role. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("roles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "role" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/roles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/roles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/head.rs b/sdk/identity/src/v3/role/head.rs new file mode 100644 index 000000000..85c460c3c --- /dev/null +++ b/sdk/identity/src/v3/role/head.rs @@ -0,0 +1,185 @@ +// 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 roles. +//! +//! GET/HEAD /v3/roles +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "roles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("name", self.name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/roles".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/roles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/role/imply.rs b/sdk/identity/src/v3/role/imply.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/role/imply.rs rename to sdk/identity/src/v3/role/imply.rs diff --git a/sdk/identity/src/v3/role/imply/delete.rs b/sdk/identity/src/v3/role/imply/delete.rs new file mode 100644 index 000000000..643e7bc72 --- /dev/null +++ b/sdk/identity/src/v3/role/imply/delete.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`. + +//! Deletes a role inference rule. +//! +//! Relationship: +//! `https://developer.openstack.org/api-ref/identity/v3/#delete-role-inference-rule` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// implied_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + implied_role_id: Cow<'a, str>, + + /// prior_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + prior_role_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 Imply. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = self.implied_role_id.as_ref(), + prior_role_id = self.prior_role_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_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() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/imply/get.rs b/sdk/identity/src/v3/role/imply/get.rs new file mode 100644 index 000000000..804ecdece --- /dev/null +++ b/sdk/identity/src/v3/role/imply/get.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Gets a role inference rule. +//! +//! Relationship: +//! `https://developer.openstack.org/api-ref/identity/v3/#get-role-inference-rule` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// implied_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + implied_role_id: Cow<'a, str>, + + /// prior_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + prior_role_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 Imply. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = self.implied_role_id.as_ref(), + prior_role_id = self.prior_role_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role_inference".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "role_inference" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inference": {} })); + }); + + let endpoint = Request::builder() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inference": {} })); + }); + + let endpoint = Request::builder() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/imply/head.rs b/sdk/identity/src/v3/role/imply/head.rs new file mode 100644 index 000000000..14b269834 --- /dev/null +++ b/sdk/identity/src/v3/role/imply/head.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Checks a role role inference rule. +//! +//! Relationship: +//! `https://developer.openstack.org/api-ref/identity/v3/#confirm-role-inference-rule` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// implied_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + implied_role_id: Cow<'a, str>, + + /// prior_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + prior_role_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 Imply. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = self.implied_role_id.as_ref(), + prior_role_id = self.prior_role_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/imply/list.rs b/sdk/identity/src/v3/role/imply/list.rs new file mode 100644 index 000000000..390fd1d04 --- /dev/null +++ b/sdk/identity/src/v3/role/imply/list.rs @@ -0,0 +1,200 @@ +// 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`. + +//! Lists implied (inference) roles for a role. +//! +//! Relationship: +//! `https://developer.openstack.org/api-ref/identity/v3/#list-implied-roles-for-role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// prior_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + prior_role_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 Imply. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "roles/{prior_role_id}/implies", + prior_role_id = self.prior_role_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role_inference".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "role_inference" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/roles/{prior_role_id}/implies", + prior_role_id = "prior_role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inference": {} })); + }); + + let endpoint = Request::builder() + .prior_role_id("prior_role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/roles/{prior_role_id}/implies", + prior_role_id = "prior_role_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inference": {} })); + }); + + let endpoint = Request::builder() + .prior_role_id("prior_role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/imply/set.rs b/sdk/identity/src/v3/role/imply/set.rs new file mode 100644 index 000000000..c7acec56d --- /dev/null +++ b/sdk/identity/src/v3/role/imply/set.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Creates a role inference rule. +//! +//! Relationship: +//! `https://developer.openstack.org/api-ref/identity/v3/#create-role-inference-rule` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// implied_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + implied_role_id: Cow<'a, str>, + + /// prior_role_id parameter for + /// /v3/roles/{prior_role_id}/implies/{implied_role_id} API + #[builder(default, setter(into))] + prior_role_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 Imply. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = self.implied_role_id.as_ref(), + prior_role_id = self.prior_role_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role_inference".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "role_inference" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inference": {} })); + }); + + let endpoint = Request::builder() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/roles/{prior_role_id}/implies/{implied_role_id}", + implied_role_id = "implied_role_id", + prior_role_id = "prior_role_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inference": {} })); + }); + + let endpoint = Request::builder() + .implied_role_id("implied_role_id") + .prior_role_id("prior_role_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/list.rs b/sdk/identity/src/v3/role/list.rs new file mode 100644 index 000000000..9fdf464ef --- /dev/null +++ b/sdk/identity/src/v3/role/list.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Lists roles. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/roles` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "roles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("name", self.name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("roles".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "roles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/roles".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/roles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role/set.rs b/sdk/identity/src/v3/role/set.rs new file mode 100644 index 000000000..55481b98b --- /dev/null +++ b/sdk/identity/src/v3/role/set.rs @@ -0,0 +1,271 @@ +// 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`. + +//! Updates a role. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// The resource options for the role. Available resource options are +/// `immutable`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) immutable: Option, +} + +/// A `role` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Role<'a> { + /// The new role description. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>>, + + /// The new role name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The resource options for the role. Available resource options are + /// `immutable`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> RoleBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `role` object + #[builder(setter(into))] + pub(crate) role: Role<'a>, + + /// role_id parameter for /v3/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("roles/{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("role", serde_json::to_value(&self.role)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .role(RoleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .role(RoleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "role" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/roles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .role(RoleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/roles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .role(RoleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/role_assignment.rs b/sdk/identity/src/v3/role_assignment.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/role_assignment.rs rename to sdk/identity/src/v3/role_assignment.rs diff --git a/sdk/identity/src/v3/role_assignment/head.rs b/sdk/identity/src/v3/role_assignment/head.rs new file mode 100644 index 000000000..80dfb3e39 --- /dev/null +++ b/sdk/identity/src/v3/role_assignment/head.rs @@ -0,0 +1,221 @@ +// 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 role assignments. +//! +//! GET/HEAD /v3/role_assignments +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + effective: Option>, + + #[builder(default, setter(into))] + group_id: Option>, + + #[builder(default, setter(into))] + include_names: Option>, + + #[builder(default, setter(into))] + include_subtree: Option>, + + #[builder(default, setter(into))] + role_id: Option>, + + /// The ID of the domain. + #[builder(default, setter(into))] + scope_domain_id: Option>, + + #[builder(default, setter(into))] + scope_os_inherit_inherited_to: Option>, + + /// The ID of the project. + #[builder(default, setter(into))] + scope_project_id: Option>, + + #[builder(default, setter(into))] + scope_system: Option>, + + /// The ID of the user. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Role_Assignment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "role_assignments".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("effective", self.effective.as_ref()); + params.push_opt("group.id", self.group_id.as_ref()); + params.push_opt("include_names", self.include_names.as_ref()); + params.push_opt("include_subtree", self.include_subtree.as_ref()); + params.push_opt("role.id", self.role_id.as_ref()); + params.push_opt( + "scope.OS-INHERIT:inherited_to", + self.scope_os_inherit_inherited_to.as_ref(), + ); + params.push_opt("scope.domain.id", self.scope_domain_id.as_ref()); + params.push_opt("scope.project.id", self.scope_project_id.as_ref()); + params.push_opt("scope.system", self.scope_system.as_ref()); + params.push_opt("user.id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/role_assignments".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/role_assignments".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role_assignment/list.rs b/sdk/identity/src/v3/role_assignment/list.rs new file mode 100644 index 000000000..9ee62b69a --- /dev/null +++ b/sdk/identity/src/v3/role_assignment/list.rs @@ -0,0 +1,297 @@ +// 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 a list of role assignments. +//! +//! If no query parameters are specified, then this API will return a list of +//! all role assignments. +//! +//! Since this list is likely to be very long, this API would typically always +//! be used with one of more of the filter queries. Some typical examples are: +//! +//! `GET /v3/role_assignments?user.id={user_id}` would list all role +//! assignments involving the specified user. +//! +//! `GET /v3/role_assignments?scope.project.id={project_id}` would list all +//! role assignments involving the specified project. +//! +//! It is also possible to list all role assignments within a tree of projects: +//! `GET /v3/role_assignments?scope.project.id={project_id}&include_subtree=true` +//! would list all role assignments involving the specified project and all +//! sub-projects. `include_subtree=true` can only be specified in conjunction +//! with `scope.project.id`, specifying it without this will result in an HTTP +//! 400 Bad Request being returned. +//! +//! Each role assignment entity in the collection contains a link to the +//! assignment that gave rise to this entity. +//! +//! The scope section in the list response is extended to allow the +//! representation of role assignments that are inherited to projects. +//! +//! The query filter `scope.OS-INHERIT:inherited_to` can be used to filter +//! based on role assignments that are inherited. The only value of +//! `scope.OS-INHERIT:inherited_to` that is currently supported is `projects`, +//! indicating that this role is inherited to all projects of the owning domain +//! or parent project. +//! +//! If the query parameter `effective` is specified, rather than simply +//! returning a list of role assignments that have been made, the API returns a +//! list of effective assignments at the user, project and domain level, having +//! allowed for the effects of group membership, role inference rules as well +//! as inheritance from the parent domain or project. Since the effects of +//! group membership have already been allowed for, the group role assignment +//! entities themselves will not be returned in the collection. Likewise, since +//! the effects of inheritance have already been allowed for, the role +//! assignment entities themselves that specify the inheritance will also not +//! be returned in the collection. This represents the effective role +//! assignments that would be included in a scoped token. The same set of query +//! parameters can also be used in combination with the `effective` parameter. +//! +//! For example: +//! +//! `GET /v3/role_assignments?user.id={user_id}&effective` would, in other +//! words, answer the question “what can this user actually do?”. +//! +//! `GET /v3/role_assignments?user.id={user_id}&scope.project.id={project_id}&effective` +//! would return the equivalent set of role assignments that would be included +//! in the token response of a project scoped token. +//! +//! An example response for an API call with the query parameter `effective` +//! specified is given below: +//! +//! The entity `links` section of a response using the `effective` query +//! parameter also contains, for entities that are included by virtue of group +//! membership, a url that can be used to access the membership of the group. +//! +//! If the query parameter `include_names` is specified, rather than simply +//! returning the entity IDs in the role assignments, the collection will +//! additionally include the names of the entities. For example: +//! +//! `GET /v3/role_assignments?user.id={user_id}&effective&include_names=true` +//! would return: +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/role_assignments` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + effective: Option>, + + #[builder(default, setter(into))] + group_id: Option>, + + #[builder(default, setter(into))] + include_names: Option>, + + #[builder(default, setter(into))] + include_subtree: Option>, + + #[builder(default, setter(into))] + role_id: Option>, + + /// The ID of the domain. + #[builder(default, setter(into))] + scope_domain_id: Option>, + + #[builder(default, setter(into))] + scope_os_inherit_inherited_to: Option>, + + /// The ID of the project. + #[builder(default, setter(into))] + scope_project_id: Option>, + + #[builder(default, setter(into))] + scope_system: Option>, + + /// The ID of the user. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Role_Assignment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "role_assignments".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("effective", self.effective.as_ref()); + params.push_opt("group.id", self.group_id.as_ref()); + params.push_opt("include_names", self.include_names.as_ref()); + params.push_opt("include_subtree", self.include_subtree.as_ref()); + params.push_opt("role.id", self.role_id.as_ref()); + params.push_opt( + "scope.OS-INHERIT:inherited_to", + self.scope_os_inherit_inherited_to.as_ref(), + ); + params.push_opt("scope.domain.id", self.scope_domain_id.as_ref()); + params.push_opt("scope.project.id", self.scope_project_id.as_ref()); + params.push_opt("scope.system", self.scope_system.as_ref()); + params.push_opt("user.id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role_assignments".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "role_assignments" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/role_assignments".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_assignments": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/role_assignments".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_assignments": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/role_inference.rs b/sdk/identity/src/v3/role_inference.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/role_inference.rs rename to sdk/identity/src/v3/role_inference.rs diff --git a/sdk/identity/src/v3/role_inference/head.rs b/sdk/identity/src/v3/role_inference/head.rs new file mode 100644 index 000000000..bd5c566af --- /dev/null +++ b/sdk/identity/src/v3/role_inference/head.rs @@ -0,0 +1,171 @@ +// 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 role inference rules. +//! +//! GET/HEAD /v3/role_inferences +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Role_Inference. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "role_inferences".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/role_inferences".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/role_inferences".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/role_inference/list.rs b/sdk/identity/src/v3/role_inference/list.rs new file mode 100644 index 000000000..5a2191072 --- /dev/null +++ b/sdk/identity/src/v3/role_inference/list.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`. + +//! Lists all role inference rules. +//! +//! Relationship: +//! `https://developer.openstack.org/api-ref/identity/v3/#list-all-role-inference-rules` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Role_Inference. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "role_inferences".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("role_inferences".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "role_inferences" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/role_inferences".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inferences": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/role_inferences".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "role_inferences": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/s3token.rs b/sdk/identity/src/v3/s3token.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/s3token.rs rename to sdk/identity/src/v3/s3token.rs diff --git a/sdk/identity/src/v3/s3token/create.rs b/sdk/identity/src/v3/s3token/create.rs new file mode 100644 index 000000000..f6b88a243 --- /dev/null +++ b/sdk/identity/src/v3/s3token/create.rs @@ -0,0 +1,204 @@ +// 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`. + +//! Authenticate s3token. +//! +//! POST /v3/s3tokens +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 S3Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "s3tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/s3tokens".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/s3tokens".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/s3token/get.rs b/sdk/identity/src/v3/s3token/get.rs new file mode 100644 index 000000000..19ebbcf7d --- /dev/null +++ b/sdk/identity/src/v3/s3token/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 operation on /v3/s3tokens +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 S3Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "s3tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/s3tokens".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/s3tokens".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/s3token/head.rs b/sdk/identity/src/v3/s3token/head.rs new file mode 100644 index 000000000..8e0cc7c4d --- /dev/null +++ b/sdk/identity/src/v3/s3token/head.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`. + +//! HEAD operation on /v3/s3tokens +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 S3Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "s3tokens".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/s3tokens".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/s3tokens".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/service.rs b/sdk/identity/src/v3/service.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/service.rs rename to sdk/identity/src/v3/service.rs diff --git a/sdk/identity/src/v3/service/create.rs b/sdk/identity/src/v3/service/create.rs new file mode 100644 index 000000000..7dfc0712c --- /dev/null +++ b/sdk/identity/src/v3/service/create.rs @@ -0,0 +1,253 @@ +// 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`. + +//! Creates a service. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/services` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `service` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Service<'a> { + /// Defines whether the service and its endpoints appear in the service + /// catalog: - `false`. The service and its endpoints do not appear in the + /// service catalog. - `true`. The service and its endpoints appear in the + /// service catalog. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The service name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The service type, which describes the API implemented by the service. + /// Value is `compute`, `ec2`, `identity`, `image`, `network`, or `volume`. + #[serde(rename = "type")] + #[builder(setter(into))] + pub(crate) _type: Cow<'a, str>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> ServiceBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `service` object. + #[builder(setter(into))] + pub(crate) service: Service<'a>, + + #[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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "services".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("service", serde_json::to_value(&self.service)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("service".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service(ServiceBuilder::default()._type("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service(ServiceBuilder::default()._type("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/services".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + let endpoint = Request::builder() + .service(ServiceBuilder::default()._type("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/services".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + let endpoint = Request::builder() + .service(ServiceBuilder::default()._type("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/service/delete.rs b/sdk/identity/src/v3/service/delete.rs new file mode 100644 index 000000000..49f6898bd --- /dev/null +++ b/sdk/identity/src/v3/service/delete.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Deletes a service. +//! +//! If you try to delete a service that still has associated endpoints, this +//! call either deletes all associated endpoints or fails until all endpoints +//! are deleted. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/service` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_id parameter for /v3/services/{service_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<'a> RequestBuilder<'a> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("services/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/services/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/services/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/service/find.rs b/sdk/identity/src/v3/service/find.rs new file mode 100644 index 000000000..19856bfcc --- /dev/null +++ b/sdk/identity/src/v3/service/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v3::service::{get as Get, list as List}; + +/// Find for service 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate service in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // service 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/identity/src/v3/service/get.rs b/sdk/identity/src/v3/service/get.rs new file mode 100644 index 000000000..be2d96f53 --- /dev/null +++ b/sdk/identity/src/v3/service/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a service. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/service` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// service_id parameter for /v3/services/{service_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<'a> RequestBuilder<'a> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("services/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("service".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/services/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/services/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/service/head.rs b/sdk/identity/src/v3/service/head.rs new file mode 100644 index 000000000..d117d32c3 --- /dev/null +++ b/sdk/identity/src/v3/service/head.rs @@ -0,0 +1,171 @@ +// 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 services. +//! +//! GET /v3/services +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "services".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/services".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/services".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/service/list.rs b/sdk/identity/src/v3/service/list.rs new file mode 100644 index 000000000..fe220f918 --- /dev/null +++ b/sdk/identity/src/v3/service/list.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Lists all services. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/services` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filters the response by a domain ID. + #[builder(default, setter(into))] + service: 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> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "services".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("service", self.service.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("services".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "services" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/services".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "services": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/services".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "services": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/service/set.rs b/sdk/identity/src/v3/service/set.rs new file mode 100644 index 000000000..a25af5521 --- /dev/null +++ b/sdk/identity/src/v3/service/set.rs @@ -0,0 +1,262 @@ +// 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`. + +//! Updates a service. +//! +//! The request body is the same as the create service request body, except +//! that you include only those attributes that you want to update. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/services` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `service` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Service<'a> { + /// Defines whether the service and its endpoints appear in the service + /// catalog: - `false`. The service and its endpoints do not appear in the + /// service catalog. - `true`. The service and its endpoints appear in the + /// service catalog. Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// The service name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The service type, which describes the API implemented by the service. + /// Value is `compute`, `ec2`, `identity`, `image`, `network`, or `volume`. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _type: Option>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> ServiceBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `service` object. + #[builder(setter(into))] + pub(crate) service: Service<'a>, + + /// service_id parameter for /v3/services/{service_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<'a> RequestBuilder<'a> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("services/{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("service", serde_json::to_value(&self.service)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("service".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service(ServiceBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service(ServiceBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/services/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service(ServiceBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/services/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service(ServiceBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/system.rs b/sdk/identity/src/v3/system.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/system.rs rename to sdk/identity/src/v3/system.rs diff --git a/openstack_sdk/src/api/identity/v3/system/group.rs b/sdk/identity/src/v3/system/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/system/group.rs rename to sdk/identity/src/v3/system/group.rs diff --git a/openstack_sdk/src/api/identity/v3/system/group/role.rs b/sdk/identity/src/v3/system/group/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/system/group/role.rs rename to sdk/identity/src/v3/system/group/role.rs diff --git a/sdk/identity/src/v3/system/group/role/delete.rs b/sdk/identity/src/v3/system/group/role/delete.rs new file mode 100644 index 000000000..6a97323db --- /dev/null +++ b/sdk/identity/src/v3/system/group/role/delete.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Remove a system role assignment from a group. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "system/groups/{group_id}/roles/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_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() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/group/role/get.rs b/sdk/identity/src/v3/system/group/role/get.rs new file mode 100644 index 000000000..a53ece6d1 --- /dev/null +++ b/sdk/identity/src/v3/system/group/role/get.rs @@ -0,0 +1,206 @@ +// 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 a specific system role assignment for a group. This is the same API as +//! `HEAD /v3/system/groups/{group_id}/roles/{role_id}`. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "system/groups/{group_id}/roles/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_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() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/group/role/head.rs b/sdk/identity/src/v3/system/group/role/head.rs new file mode 100644 index 000000000..193eaf937 --- /dev/null +++ b/sdk/identity/src/v3/system/group/role/head.rs @@ -0,0 +1,200 @@ +// 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`. + +//! Check if a specific group has a role assignment on the system. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "system/groups/{group_id}/roles/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/group/role/list.rs b/sdk/identity/src/v3/system/group/role/list.rs new file mode 100644 index 000000000..1581b48f9 --- /dev/null +++ b/sdk/identity/src/v3/system/group/role/list.rs @@ -0,0 +1,196 @@ +// 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`. + +//! Lists all system role assignment a group has. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_roles` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "system/groups/{group_id}/roles", + group_id = self.group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("roles".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "roles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/system/groups/{group_id}/roles", + group_id = "group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder().group_id("group_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/system/groups/{group_id}/roles", + group_id = "group_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/group/role/set.rs b/sdk/identity/src/v3/system/group/role/set.rs new file mode 100644 index 000000000..c69b6c265 --- /dev/null +++ b/sdk/identity/src/v3/system/group/role/set.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Grant a group a role on the system. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_group_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// group_id parameter for /v3/system/groups/{group_id}/roles/{role_id} API + #[builder(default, setter(into))] + group_id: Cow<'a, str>, + + /// role_id parameter for /v3/system/groups/{group_id}/roles/{role_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<'a> RequestBuilder<'a> { + /// Add a single header to the Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "system/groups/{group_id}/roles/{id}", + group_id = self.group_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .group_id("group_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/system/groups/{group_id}/roles/{id}", + group_id = "group_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() + .group_id("group_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/system/user.rs b/sdk/identity/src/v3/system/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/system/user.rs rename to sdk/identity/src/v3/system/user.rs diff --git a/openstack_sdk/src/api/identity/v3/system/user/role.rs b/sdk/identity/src/v3/system/user/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/system/user/role.rs rename to sdk/identity/src/v3/system/user/role.rs diff --git a/sdk/identity/src/v3/system/user/role/delete.rs b/sdk/identity/src/v3/system/user/role/delete.rs new file mode 100644 index 000000000..b0f91e671 --- /dev/null +++ b/sdk/identity/src/v3/system/user/role/delete.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Remove a system role assignment from a user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "system/users/{user_id}/roles/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_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") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/user/role/get.rs b/sdk/identity/src/v3/system/user/role/get.rs new file mode 100644 index 000000000..4ab88ff8e --- /dev/null +++ b/sdk/identity/src/v3/system/user/role/get.rs @@ -0,0 +1,206 @@ +// 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 a specific system role assignment for a user. This is the same API as +//! `HEAD /v3/system/users/{user_id}/roles/{role_id}`. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "system/users/{user_id}/roles/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_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") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/user/role/head.rs b/sdk/identity/src/v3/system/user/role/head.rs new file mode 100644 index 000000000..6e3aec6e6 --- /dev/null +++ b/sdk/identity/src/v3/system/user/role/head.rs @@ -0,0 +1,200 @@ +// 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`. + +//! Check if a specific user has a role assignment on the system. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "system/users/{user_id}/roles/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/user/role/list.rs b/sdk/identity/src/v3/system/user/role/list.rs new file mode 100644 index 000000000..7e2ed8d7c --- /dev/null +++ b/sdk/identity/src/v3/system/user/role/list.rs @@ -0,0 +1,196 @@ +// 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`. + +//! Lists all system role assignment a user has. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_roles` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "system/users/{user_id}/roles", + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("roles".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "roles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/system/users/{user_id}/roles", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/system/users/{user_id}/roles", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "roles": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/system/user/role/set.rs b/sdk/identity/src/v3/system/user/role/set.rs new file mode 100644 index 000000000..1e152a0c4 --- /dev/null +++ b/sdk/identity/src/v3/system/user/role/set.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Grant a user a role on the system. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/system_user_role` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// role_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for /v3/system/users/{user_id}/roles/{role_id} API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "system/users/{user_id}/roles/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/system/users/{user_id}/roles/{id}", + id = "id", + user_id = "user_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") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user.rs b/sdk/identity/src/v3/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user.rs rename to sdk/identity/src/v3/user.rs diff --git a/openstack_sdk/src/api/identity/v3/user/access_rule.rs b/sdk/identity/src/v3/user/access_rule.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/access_rule.rs rename to sdk/identity/src/v3/user/access_rule.rs diff --git a/sdk/identity/src/v3/user/access_rule/delete.rs b/sdk/identity/src/v3/user/access_rule/delete.rs new file mode 100644 index 000000000..8e5958592 --- /dev/null +++ b/sdk/identity/src/v3/user/access_rule/delete.rs @@ -0,0 +1,208 @@ +// 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 an access rule. An access rule that is still in use by an +//! application credential cannot be deleted. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/access_rules` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_rule_id parameter for + /// /v3/users/{user_id}/access_rules/{access_rule_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} + /// API + #[builder(default, setter(into))] + user_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 Access_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/access_rules/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/users/{user_id}/access_rules/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/users/{user_id}/access_rules/{id}", + id = "id", + user_id = "user_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") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/access_rule/find.rs b/sdk/identity/src/v3/user/access_rule/find.rs new file mode 100644 index 000000000..f06c83dba --- /dev/null +++ b/sdk/identity/src/v3/user/access_rule/find.rs @@ -0,0 +1,120 @@ +// 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 serde::de::DeserializeOwned; +use tracing::trace; + +use crate::api::common::CommaSeparatedList; +use crate::api::find::Findable; +use crate::api::rest_endpoint_prelude::*; +use crate::api::ParamValue; + +use crate::api::{ApiError, Client, Pageable, Query, RestClient}; + +use crate::v3::user::access_rule::{get as Get, list as List}; + +/// Find for user/access_rule by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[builder(default, setter(into))] + user_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 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<'a>; + fn get_ep(&self) -> Result, crate::api::ApiError> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.user_id(self.user_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().map_err(|err| ApiError::endpoint_builder(err)) + } + fn list_ep(&self) -> Result, crate::api::ApiError> { + let mut ep = List::Request::builder(); + ep.user_id(self.user_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().map_err(|err| ApiError::endpoint_builder(err)) + } + /// Locate user/access_rule in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // user/access_rule 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/sdk/identity/src/v3/user/access_rule/get.rs b/sdk/identity/src/v3/user/access_rule/get.rs new file mode 100644 index 000000000..0b83396ca --- /dev/null +++ b/sdk/identity/src/v3/user/access_rule/get.rs @@ -0,0 +1,210 @@ +// 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 details of an access rule. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/access_rules` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_rule_id parameter for + /// /v3/users/{user_id}/access_rules/{access_rule_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} + /// API + #[builder(default, setter(into))] + user_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 Access_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/access_rules/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("access_rule".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "access_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/access_rules/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "access_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/access_rules/{id}", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "access_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/access_rule/head.rs b/sdk/identity/src/v3/user/access_rule/head.rs new file mode 100644 index 000000000..a6d0370dc --- /dev/null +++ b/sdk/identity/src/v3/user/access_rule/head.rs @@ -0,0 +1,201 @@ +// 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 access rule resource. +//! +//! GET/HEAD /v3/users/{user_id}/access_rules/{access_rule_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_rule_id parameter for + /// /v3/users/{user_id}/access_rules/{access_rule_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} + /// API + #[builder(default, setter(into))] + user_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 Access_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "users/{user_id}/access_rules/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/users/{user_id}/access_rules/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/users/{user_id}/access_rules/{id}", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/access_rule/list.rs b/sdk/identity/src/v3/user/access_rule/list.rs new file mode 100644 index 000000000..1d8ed27ea --- /dev/null +++ b/sdk/identity/src/v3/user/access_rule/list.rs @@ -0,0 +1,216 @@ +// 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 access rules for a user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/access_rules` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The request method that the application credential is permitted to use + /// for a given API endpoint. + #[builder(default, setter(into))] + method: Option>, + + /// The API path that the application credential is permitted to access. + #[builder(default, setter(into))] + path: Option>, + + /// The service type identifier for the service that the application is + /// permitted to access. + #[builder(default, setter(into))] + service: Option>, + + /// user_id parameter for /v3/users/{user_id}/access_rules/{access_rule_id} + /// API + #[builder(default, setter(into))] + user_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 Access_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/access_rules", + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("method", self.method.as_ref()); + params.push_opt("path", self.path.as_ref()); + params.push_opt("service", self.service.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("access_rules".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "access_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/access_rules", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "access_rules": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/access_rules", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "access_rules": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user/application_credential.rs b/sdk/identity/src/v3/user/application_credential.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/application_credential.rs rename to sdk/identity/src/v3/user/application_credential.rs diff --git a/sdk/identity/src/v3/user/application_credential/create.rs b/sdk/identity/src/v3/user/application_credential/create.rs new file mode 100644 index 000000000..78c76b50a --- /dev/null +++ b/sdk/identity/src/v3/user/application_credential/create.rs @@ -0,0 +1,368 @@ +// 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`. + +//! Creates an application credential for a user on the project to which the +//! current token is scoped. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Method { + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "PATCH")] + Patch, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AccessRules<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The request method that the application credential is permitted to use + /// for a given API endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) method: Option, + + /// The API path that the application credential is permitted to access. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) path: Option>, + + /// The service type identifier for the service that the application + /// credential is permitted to access. Must be a service type that is + /// listed in the service catalog and not a code name for a service. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Roles<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The resource name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +/// An application credential object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ApplicationCredential<'a> { + /// A list of `access_rules` objects + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) access_rules: Option>>, + + /// A description of the application credential’s purpose. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// An optional expiry time for the application credential. If unset, the + /// application credential does not expire. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expires_at: Option>>, + + /// The UUID for the credential. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// The name of the application credential. Must be unique to a user. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The ID of the project the application credential was created for and + /// that authentication requests using this application credential will be + /// scoped to. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// An optional list of role objects, identified by ID or name. The list + /// may only contain roles that the user has assigned on the project. If + /// not provided, the roles assigned to the application credential will be + /// the same as the roles in the current token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) roles: Option>>, + + /// The secret that the application credential will be created with. If not + /// provided, one will be generated. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) secret: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) system: Option>>, + + /// An optional flag to restrict whether the application credential may be + /// used for the creation or destruction of other application credentials + /// or trusts. Defaults to false. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) unrestricted: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An application credential object. + #[builder(setter(into))] + pub(crate) application_credential: ApplicationCredential<'a>, + + /// user_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + user_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 Application_Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "users/{user_id}/application_credentials", + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "application_credential", + serde_json::to_value(&self.application_credential)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("application_credential".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .application_credential( + ApplicationCredentialBuilder::default() + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .application_credential( + ApplicationCredentialBuilder::default() + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "application_credential" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/users/{user_id}/application_credentials", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "application_credential": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .application_credential( + ApplicationCredentialBuilder::default() + .name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/users/{user_id}/application_credentials", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "application_credential": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .application_credential( + ApplicationCredentialBuilder::default() + .name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/application_credential/delete.rs b/sdk/identity/src/v3/user/application_credential/delete.rs new file mode 100644 index 000000000..2bf5d70d9 --- /dev/null +++ b/sdk/identity/src/v3/user/application_credential/delete.rs @@ -0,0 +1,209 @@ +// 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 an application credential. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// application_credential_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + user_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 Application_Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/application_credentials/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/users/{user_id}/application_credentials/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/users/{user_id}/application_credentials/{id}", + id = "id", + user_id = "user_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") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/application_credential/find.rs b/sdk/identity/src/v3/user/application_credential/find.rs new file mode 100644 index 000000000..49d549841 --- /dev/null +++ b/sdk/identity/src/v3/user/application_credential/find.rs @@ -0,0 +1,96 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v3::user::application_credential::{get as Get, list as List}; + +/// Find for user/application_credential by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[builder(default, setter(into))] + user_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 Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.user_id(self.user_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + let mut ep = List::Request::builder(); + ep.user_id(self.user_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/identity/src/v3/user/application_credential/get.rs b/sdk/identity/src/v3/user/application_credential/get.rs new file mode 100644 index 000000000..681fbbbe7 --- /dev/null +++ b/sdk/identity/src/v3/user/application_credential/get.rs @@ -0,0 +1,212 @@ +// 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 details of an application credential. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// application_credential_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + user_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 Application_Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/application_credentials/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("application_credential".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "application_credential" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/application_credentials/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "application_credential": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/application_credentials/{id}", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "application_credential": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/application_credential/head.rs b/sdk/identity/src/v3/user/application_credential/head.rs new file mode 100644 index 000000000..3d4021a68 --- /dev/null +++ b/sdk/identity/src/v3/user/application_credential/head.rs @@ -0,0 +1,204 @@ +// 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 application credential resource. +//! +//! GET/HEAD /v3/users/{user_id}/application_credentials/ +//! {application_credential_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// application_credential_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + user_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 Application_Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "users/{user_id}/application_credentials/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/users/{user_id}/application_credentials/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/users/{user_id}/application_credentials/{id}", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/application_credential/list.rs b/sdk/identity/src/v3/user/application_credential/list.rs new file mode 100644 index 000000000..e619ee94e --- /dev/null +++ b/sdk/identity/src/v3/user/application_credential/list.rs @@ -0,0 +1,205 @@ +// 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 application credentials for a user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/application_credentials` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The name of the application credential. Must be unique to a user. + #[builder(default, setter(into))] + name: Option>, + + /// user_id parameter for + /// /v3/users/{user_id}/application_credentials/{application_credential_id} + /// API + #[builder(default, setter(into))] + user_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 Application_Credential. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/application_credentials", + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("name", self.name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("application_credentials".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "application_credentials" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/application_credentials", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "application_credentials": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/application_credentials", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "application_credentials": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/create.rs b/sdk/identity/src/v3/user/create.rs new file mode 100644 index 000000000..078a37040 --- /dev/null +++ b/sdk/identity/src/v3/user/create.rs @@ -0,0 +1,379 @@ +// 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`. + +//! Creates a user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/users` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Protocols<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_id: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) unique_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Federated<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) idp_id: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) protocols: Vec>, +} + +/// The resource options for the user. Available resource options are +/// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, +/// `ignore_lockout_failure_attempts`, `lock_password`, +/// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` +/// `ignore_user_inactivity`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_change_password_upon_first_use: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_lockout_failure_attempts: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_password_expiry: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_user_inactivity: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) lock_password: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) multi_factor_auth_enabled: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_multi_factor_auth_rules"))] + pub(crate) multi_factor_auth_rules: Option>>>, +} + +impl<'a> OptionsBuilder<'a> { + pub fn multi_factor_auth_rules(&mut self, iter: I1) -> &mut Self + where + I1: Iterator, + I2: IntoIterator, + V: Into>, + { + self.multi_factor_auth_rules + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(|x| Vec::from_iter(x.into_iter().map(Into::into)))); + self + } +} + +/// A `user` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User<'a> { + /// The ID of the default project for the user. A user’s default project + /// must not be a domain. Setting this attribute does not grant any actual + /// authorization on the project, and is merely provided for convenience. + /// Therefore, the referenced project does not need to exist within the + /// user domain. (Since v3.1) If the user does not have authorization to + /// their default project, the default project is ignored at token + /// creation. (Since v3.1) Additionally, if your default project is not + /// valid, a token is issued without an explicit scope of authorization. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_project_id: Option>>, + + /// The description of the user resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the domain of the user. If the domain ID is not provided in + /// the request, the Identity service will attempt to pull the domain ID + /// from the token used in the request. Note that this requires the use of + /// a domain-scoped token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>, + + /// If the user is enabled, this value is `true`. If the user is disabled, + /// this value is `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// List of federated objects associated with a user. Each object in the + /// list contains the `idp_id` and `protocols`. `protocols` is a list of + /// objects, each of which contains `protocol_id` and `unique_id` of the + /// protocol and user respectively. For example: + /// + /// ```text + /// "federated": [ + /// { + /// "idp_id": "efbab5a6acad4d108fec6c63d9609d83", + /// "protocols": [ + /// {"protocol_id": mapped, "unique_id": "test@example.com"} + /// ] + /// } + /// ] + /// ``` + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) federated: Option>>, + + /// The user name. Must be unique within the owning domain. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The resource options for the user. Available resource options are + /// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, + /// `ignore_lockout_failure_attempts`, `lock_password`, + /// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` + /// `ignore_user_inactivity`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option>, + + /// The password for the user. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) password: Option>>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> UserBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `user` object + #[builder(setter(into))] + pub(crate) user: User<'a>, + + #[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 User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "users".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("user", serde_json::to_value(&self.user)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("user".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .user(UserBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .user(UserBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "user" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/users".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "user": {} })); + }); + + let endpoint = Request::builder() + .user(UserBuilder::default().name("foo").build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/users".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "user": {} })); + }); + + let endpoint = Request::builder() + .user(UserBuilder::default().name("foo").build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user/credential.rs b/sdk/identity/src/v3/user/credential.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/credential.rs rename to sdk/identity/src/v3/user/credential.rs diff --git a/openstack_sdk/src/api/identity/v3/user/credential/os_ec2.rs b/sdk/identity/src/v3/user/credential/os_ec2.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/credential/os_ec2.rs rename to sdk/identity/src/v3/user/credential/os_ec2.rs diff --git a/sdk/identity/src/v3/user/credential/os_ec2/create.rs b/sdk/identity/src/v3/user/credential/os_ec2/create.rs new file mode 100644 index 000000000..531cdbb10 --- /dev/null +++ b/sdk/identity/src/v3/user/credential/os_ec2/create.rs @@ -0,0 +1,220 @@ +// 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 EC2 Credential for user. +//! +//! POST /v3/users/{user_id}/credentials/OS-EC2 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + user_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Os_Ec2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "users/{user_id}/credentials/OS-EC2", + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/users/{user_id}/credentials/OS-EC2", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/users/{user_id}/credentials/OS-EC2", + user_id = "user_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() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/credential/os_ec2/delete.rs b/sdk/identity/src/v3/user/credential/os_ec2/delete.rs new file mode 100644 index 000000000..5952dce9c --- /dev/null +++ b/sdk/identity/src/v3/user/credential/os_ec2/delete.rs @@ -0,0 +1,206 @@ +// 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 specific EC2 credential. +//! +//! DELETE /users/{user_id}/credentials/OS-EC2/{credential_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// credential_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + credential_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + user_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 Os_Ec2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = self.credential_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = "credential_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .credential_id("credential_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = "credential_id", + user_id = "user_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() + .credential_id("credential_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/credential/os_ec2/get.rs b/sdk/identity/src/v3/user/credential/os_ec2/get.rs new file mode 100644 index 000000000..c8762f338 --- /dev/null +++ b/sdk/identity/src/v3/user/credential/os_ec2/get.rs @@ -0,0 +1,206 @@ +// 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 a specific EC2 credential. +//! +//! GET/HEAD /users/{user_id}/credentials/OS-EC2/{credential_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// credential_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + credential_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + user_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 Os_Ec2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = self.credential_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = "credential_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .credential_id("credential_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = "credential_id", + user_id = "user_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() + .credential_id("credential_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/credential/os_ec2/head.rs b/sdk/identity/src/v3/user/credential/os_ec2/head.rs new file mode 100644 index 000000000..216cfcd4d --- /dev/null +++ b/sdk/identity/src/v3/user/credential/os_ec2/head.rs @@ -0,0 +1,201 @@ +// 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 a specific EC2 credential. +//! +//! GET/HEAD /users/{user_id}/credentials/OS-EC2/{credential_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// credential_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + credential_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + user_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 Os_Ec2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = self.credential_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = "credential_id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .credential_id("credential_id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/users/{user_id}/credentials/OS-EC2/{credential_id}", + credential_id = "credential_id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .credential_id("credential_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/credential/os_ec2/list.rs b/sdk/identity/src/v3/user/credential/os_ec2/list.rs new file mode 100644 index 000000000..76e7f3e1a --- /dev/null +++ b/sdk/identity/src/v3/user/credential/os_ec2/list.rs @@ -0,0 +1,193 @@ +// 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 EC2 Credentials for user. +//! +//! GET/HEAD /v3/users/{user_id}/credentials/OS-EC2 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for + /// /v3/users/{user_id}/credentials/OS-EC2/{credential_id} API + #[builder(default, setter(into))] + user_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 Os_Ec2. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/credentials/OS-EC2", + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/credentials/OS-EC2", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/credentials/OS-EC2", + user_id = "user_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() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/delete.rs b/sdk/identity/src/v3/user/delete.rs new file mode 100644 index 000000000..f28d05611 --- /dev/null +++ b/sdk/identity/src/v3/user/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Deletes a user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/user` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for /v3/users/{user_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("users/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/users/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/users/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/find.rs b/sdk/identity/src/v3/user/find.rs new file mode 100644 index 000000000..ebfe49396 --- /dev/null +++ b/sdk/identity/src/v3/user/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v3::user::{get as Get, list as List}; + +/// Find for user 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/identity/src/v3/user/get.rs b/sdk/identity/src/v3/user/get.rs new file mode 100644 index 000000000..9b704c210 --- /dev/null +++ b/sdk/identity/src/v3/user/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Shows details for a user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/user` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for /v3/users/{user_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("users/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("user".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "user" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/users/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "user": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/users/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "user": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user/group.rs b/sdk/identity/src/v3/user/group.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/group.rs rename to sdk/identity/src/v3/user/group.rs diff --git a/sdk/identity/src/v3/user/group/head.rs b/sdk/identity/src/v3/user/group/head.rs new file mode 100644 index 000000000..1d850dfad --- /dev/null +++ b/sdk/identity/src/v3/user/group/head.rs @@ -0,0 +1,178 @@ +// 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 groups for a user. +//! +//! GET/HEAD /v3/users/{user_id}/groups +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for /v3/users/{user_id}/groups API + #[builder(default, setter(into))] + user_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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("users/{user_id}/groups", user_id = self.user_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/users/{user_id}/groups", user_id = "user_id",)); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/users/{user_id}/groups", user_id = "user_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/group/list.rs b/sdk/identity/src/v3/user/group/list.rs new file mode 100644 index 000000000..9d7df07b9 --- /dev/null +++ b/sdk/identity/src/v3/user/group/list.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Lists groups to which a user belongs. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/user_groups` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for /v3/users/{user_id}/groups API + #[builder(default, setter(into))] + user_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 Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("users/{user_id}/groups", user_id = self.user_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("groups".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/users/{user_id}/groups", user_id = "user_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/users/{user_id}/groups", user_id = "user_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "groups": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/head.rs b/sdk/identity/src/v3/user/head.rs new file mode 100644 index 000000000..dfa5538a2 --- /dev/null +++ b/sdk/identity/src/v3/user/head.rs @@ -0,0 +1,246 @@ +// 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 users. +//! +//! GET/HEAD /v3/users +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + /// Whether the identity provider is enabled or not + #[builder(default)] + enabled: Option, + + /// Filters the response by an identity provider ID. + #[builder(default, setter(into))] + idp_id: Option>, + + #[builder(default)] + limit: Option, + + /// ID of the last fetched entry + #[builder(default, setter(into))] + marker: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: Option>, + + /// Filter results based on which user passwords have expired. The query + /// should include an operator and a timestamp with a colon (:) separating + /// the two, for example: `password_expires_at={operator}:{timestamp}` + /// Valid operators are: lt, lte, gt, gte, eq, and neq + /// + /// - lt: expiration time lower than the timestamp + /// - lte: expiration time lower than or equal to the timestamp + /// - gt: expiration time higher than the timestamp + /// - gte: expiration time higher than or equal to the timestamp + /// - eq: expiration time equal to the timestamp + /// - neq: expiration time not equal to the timestamp + /// + /// Valid timestamps are of the form: `YYYY-MM-DDTHH:mm:ssZ`.For + /// example:`/v3/users?password_expires_at=lt:2016-12-08T22:02:00Z` The + /// example would return a list of users whose password expired before the + /// timestamp `(2016-12-08T22:02:00Z).` + #[builder(default, setter(into))] + password_expires_at: Option>, + + /// Filters the response by a protocol ID. + #[builder(default, setter(into))] + protocol_id: Option>, + + /// Sort direction. A valid value is asc (ascending) or desc (descending). + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts resources by attribute. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filters the response by a unique ID. + #[builder(default, setter(into))] + unique_id: 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> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "users".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("enabled", self.enabled); + params.push_opt("idp_id", self.idp_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("password_expires_at", self.password_expires_at.as_ref()); + params.push_opt("protocol_id", self.protocol_id.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("unique_id", self.unique_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/users".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/users".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/list.rs b/sdk/identity/src/v3/user/list.rs new file mode 100644 index 000000000..77e304808 --- /dev/null +++ b/sdk/identity/src/v3/user/list.rs @@ -0,0 +1,255 @@ +// 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`. + +//! Lists users. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/users` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the domain. + #[builder(default, setter(into))] + domain_id: Option>, + + /// Whether the identity provider is enabled or not + #[builder(default)] + enabled: Option, + + /// Filters the response by an identity provider ID. + #[builder(default, setter(into))] + idp_id: Option>, + + #[builder(default)] + limit: Option, + + /// ID of the last fetched entry + #[builder(default, setter(into))] + marker: Option>, + + /// The resource name. + #[builder(default, setter(into))] + name: Option>, + + /// Filter results based on which user passwords have expired. The query + /// should include an operator and a timestamp with a colon (:) separating + /// the two, for example: `password_expires_at={operator}:{timestamp}` + /// Valid operators are: lt, lte, gt, gte, eq, and neq + /// + /// - lt: expiration time lower than the timestamp + /// - lte: expiration time lower than or equal to the timestamp + /// - gt: expiration time higher than the timestamp + /// - gte: expiration time higher than or equal to the timestamp + /// - eq: expiration time equal to the timestamp + /// - neq: expiration time not equal to the timestamp + /// + /// Valid timestamps are of the form: `YYYY-MM-DDTHH:mm:ssZ`.For + /// example:`/v3/users?password_expires_at=lt:2016-12-08T22:02:00Z` The + /// example would return a list of users whose password expired before the + /// timestamp `(2016-12-08T22:02:00Z).` + #[builder(default, setter(into))] + password_expires_at: Option>, + + /// Filters the response by a protocol ID. + #[builder(default, setter(into))] + protocol_id: Option>, + + /// Sort direction. A valid value is asc (ascending) or desc (descending). + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts resources by attribute. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filters the response by a unique ID. + #[builder(default, setter(into))] + unique_id: 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> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "users".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("enabled", self.enabled); + params.push_opt("idp_id", self.idp_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("password_expires_at", self.password_expires_at.as_ref()); + params.push_opt("protocol_id", self.protocol_id.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("unique_id", self.unique_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("users".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(3, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "users" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/users".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "users": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/users".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "users": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1.rs b/sdk/identity/src/v3/user/os_oauth1.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/os_oauth1.rs rename to sdk/identity/src/v3/user/os_oauth1.rs diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token.rs b/sdk/identity/src/v3/user/os_oauth1/access_token.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token.rs rename to sdk/identity/src/v3/user/os_oauth1/access_token.rs diff --git a/sdk/identity/src/v3/user/os_oauth1/access_token/delete.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/delete.rs new file mode 100644 index 000000000..e0e6ee822 --- /dev/null +++ b/sdk/identity/src/v3/user/os_oauth1/access_token/delete.rs @@ -0,0 +1,206 @@ +// 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 specific access token. +//! +//! DELETE /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_token_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API + #[builder(default, setter(into))] + user_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 Access_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = "id", + user_id = "user_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") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/os_oauth1/access_token/get.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/get.rs new file mode 100644 index 000000000..da833b5a4 --- /dev/null +++ b/sdk/identity/src/v3/user/os_oauth1/access_token/get.rs @@ -0,0 +1,206 @@ +// 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 specific access token. +//! +//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_token_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API + #[builder(default, setter(into))] + user_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 Access_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = "id", + user_id = "user_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") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/os_oauth1/access_token/head.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/head.rs new file mode 100644 index 000000000..d71be8192 --- /dev/null +++ b/sdk/identity/src/v3/user/os_oauth1/access_token/head.rs @@ -0,0 +1,201 @@ +// 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 specific access token. +//! +//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_token_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API + #[builder(default, setter(into))] + user_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 Access_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = "id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{id}", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/os_oauth1/access_token/list.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/list.rs new file mode 100644 index 000000000..3994af424 --- /dev/null +++ b/sdk/identity/src/v3/user/os_oauth1/access_token/list.rs @@ -0,0 +1,193 @@ +// 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 OAuth1 Access Tokens for user. +//! +//! GET /v3/users/{user_id}/OS-OAUTH1/access_tokens +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id} API + #[builder(default, setter(into))] + user_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 Access_Token. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/OS-OAUTH1/access_tokens", + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens", + user_id = "user_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() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/role.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/os_oauth1/access_token/role.rs rename to sdk/identity/src/v3/user/os_oauth1/access_token/role.rs diff --git a/sdk/identity/src/v3/user/os_oauth1/access_token/role/get.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/role/get.rs new file mode 100644 index 000000000..3006df6c7 --- /dev/null +++ b/sdk/identity/src/v3/user/os_oauth1/access_token/role/get.rs @@ -0,0 +1,220 @@ +// 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 role for access token. +//! +//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/ +//! {access_token_id}/roles/{role_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_token_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + access_token_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", + access_token_id = self.access_token_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", + access_token_id = "access_token_id", + id = "id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .access_token_id("access_token_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", + access_token_id = "access_token_id", + id = "id", + user_id = "user_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() + .access_token_id("access_token_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/os_oauth1/access_token/role/head.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/role/head.rs new file mode 100644 index 000000000..95ec5b809 --- /dev/null +++ b/sdk/identity/src/v3/user/os_oauth1/access_token/role/head.rs @@ -0,0 +1,215 @@ +// 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 role for access token. +//! +//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/ +//! {access_token_id}/roles/{role_id} +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_token_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + access_token_id: Cow<'a, str>, + + /// role_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", + access_token_id = self.access_token_id.as_ref(), + id = self.id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", + access_token_id = "access_token_id", + id = "id", + user_id = "user_id", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .access_token_id("access_token_id") + .id("id") + .user_id("user_id") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{id}", + access_token_id = "access_token_id", + id = "id", + user_id = "user_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .access_token_id("access_token_id") + .id("id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/os_oauth1/access_token/role/list.rs b/sdk/identity/src/v3/user/os_oauth1/access_token/role/list.rs new file mode 100644 index 000000000..f99a85c9a --- /dev/null +++ b/sdk/identity/src/v3/user/os_oauth1/access_token/role/list.rs @@ -0,0 +1,209 @@ +// 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 roles for a user access token. +//! +//! GET/HEAD /v3/users/{user_id}/OS-OAUTH1/access_tokens/ +//! {access_token_id}/roles +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// access_token_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + access_token_id: Cow<'a, str>, + + /// user_id parameter for + /// /v3/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles/{role_id} + /// API + #[builder(default, setter(into))] + user_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 Role. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles", + access_token_id = self.access_token_id.as_ref(), + user_id = self.user_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles", + access_token_id = "access_token_id", + user_id = "user_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .access_token_id("access_token_id") + .user_id("user_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}/roles", + access_token_id = "access_token_id", + user_id = "user_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() + .access_token_id("access_token_id") + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user/password.rs b/sdk/identity/src/v3/user/password.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/password.rs rename to sdk/identity/src/v3/user/password.rs diff --git a/sdk/identity/src/v3/user/password/set.rs b/sdk/identity/src/v3/user/password/set.rs new file mode 100644 index 000000000..77713665b --- /dev/null +++ b/sdk/identity/src/v3/user/password/set.rs @@ -0,0 +1,255 @@ +// 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`. + +//! Changes the password for a user. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/user_change_password` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::serialize_sensitive_string; +use secrecy::SecretString; +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `user` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User { + /// The original password for the user. + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) original_password: SecretString, + + /// The new password for the user. + #[serde(serialize_with = "serialize_sensitive_string")] + #[builder(setter(into))] + pub(crate) password: SecretString, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `user` object + #[builder(setter(into))] + pub(crate) user: User, + + /// user_id parameter for /v3/users/{user_id}/password API + #[builder(default, setter(into))] + user_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 Password. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("users/{user_id}/password", user_id = self.user_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("user", serde_json::to_value(&self.user)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .user( + UserBuilder::default() + .original_password("foo") + .password("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .user( + UserBuilder::default() + .original_password("foo") + .password("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/users/{user_id}/password", user_id = "user_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .user( + UserBuilder::default() + .original_password("foo") + .password("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/users/{user_id}/password", user_id = "user_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() + .user_id("user_id") + .user( + UserBuilder::default() + .original_password("foo") + .password("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/user/project.rs b/sdk/identity/src/v3/user/project.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/user/project.rs rename to sdk/identity/src/v3/user/project.rs diff --git a/sdk/identity/src/v3/user/project/head.rs b/sdk/identity/src/v3/user/project/head.rs new file mode 100644 index 000000000..645fda7ab --- /dev/null +++ b/sdk/identity/src/v3/user/project/head.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`. + +//! HEAD operation on /v3/users/{user_id}/projects +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for /v3/users/{user_id}/projects API + #[builder(default, setter(into))] + user_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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("users/{user_id}/projects", user_id = self.user_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/users/{user_id}/projects", user_id = "user_id",)); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/users/{user_id}/projects", user_id = "user_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/project/list.rs b/sdk/identity/src/v3/user/project/list.rs new file mode 100644 index 000000000..6f71842b6 --- /dev/null +++ b/sdk/identity/src/v3/user/project/list.rs @@ -0,0 +1,187 @@ +// 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 projects to which the user has authorization to access. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/user_projects` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// user_id parameter for /v3/users/{user_id}/projects API + #[builder(default, setter(into))] + user_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 Project. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("users/{user_id}/projects", user_id = self.user_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("projects".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "projects" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/users/{user_id}/projects", user_id = "user_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder().user_id("user_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/users/{user_id}/projects", user_id = "user_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "projects": {} })); + }); + + let endpoint = Request::builder() + .user_id("user_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/user/set.rs b/sdk/identity/src/v3/user/set.rs new file mode 100644 index 000000000..bda12bc21 --- /dev/null +++ b/sdk/identity/src/v3/user/set.rs @@ -0,0 +1,385 @@ +// 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`. + +//! Updates a user. +//! +//! If the back-end driver does not support this functionality, this call might +//! return the HTTP `Not Implemented (501)` response code. +//! +//! Relationship: +//! `https://docs.openstack.org/api/openstack-identity/3/rel/user` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Protocols<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_id: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) unique_id: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Federated<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) idp_id: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) protocols: Vec>, +} + +/// The resource options for the user. Available resource options are +/// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, +/// `ignore_lockout_failure_attempts`, `lock_password`, +/// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` +/// `ignore_user_inactivity`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Options<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_change_password_upon_first_use: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_lockout_failure_attempts: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_password_expiry: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ignore_user_inactivity: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) lock_password: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) multi_factor_auth_enabled: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_multi_factor_auth_rules"))] + pub(crate) multi_factor_auth_rules: Option>>>, +} + +impl<'a> OptionsBuilder<'a> { + pub fn multi_factor_auth_rules(&mut self, iter: I1) -> &mut Self + where + I1: Iterator, + I2: IntoIterator, + V: Into>, + { + self.multi_factor_auth_rules + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(|x| Vec::from_iter(x.into_iter().map(Into::into)))); + self + } +} + +/// A `user` object +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct User<'a> { + /// The new ID of the default project for the user. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_project_id: Option>>, + + /// The description of the user resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The ID of the new domain for the user. The ability to change the domain + /// of a user is now deprecated, and will be removed in subsequent release. + /// It is already disabled by default in most Identity service + /// implementations. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>, + + /// Enables or disables the user. An enabled user can authenticate and + /// receive authorization. A disabled user cannot authenticate or receive + /// authorization. Additionally, all tokens that the user holds become no + /// longer valid. If you reenable this user, pre-existing tokens do not + /// become valid. To enable the user, set to `true`. To disable the user, + /// set to `false`. Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// List of federated objects associated with a user. Each object in the + /// list contains the `idp_id` and `protocols`. `protocols` is a list of + /// objects, each of which contains `protocol_id` and `unique_id` of the + /// protocol and user respectively. For example: + /// + /// ```text + /// "federated": [ + /// { + /// "idp_id": "efbab5a6acad4d108fec6c63d9609d83", + /// "protocols": [ + /// {"protocol_id": mapped, "unique_id": "test@example.com"} + /// ] + /// } + /// ] + /// ``` + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) federated: Option>>, + + /// The new name for the user. Must be unique within the owning domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The resource options for the user. Available resource options are + /// `ignore_change_password_upon_first_use`, `ignore_password_expiry`, + /// `ignore_lockout_failure_attempts`, `lock_password`, + /// `multi_factor_auth_enabled`, and `multi_factor_auth_rules` + /// `ignore_user_inactivity`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) options: Option>, + + /// The new password for the user. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) password: Option>>, + + #[builder(setter(name = "_properties"), default, private)] + #[serde(flatten)] + _properties: BTreeMap, Value>, +} + +impl<'a> UserBuilder<'a> { + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `user` object + #[builder(setter(into))] + pub(crate) user: User<'a>, + + /// user_id parameter for /v3/users/{user_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<'a> RequestBuilder<'a> { + /// Add a single header to the User. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("users/{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("user", serde_json::to_value(&self.user)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("user".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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .user(UserBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .user(UserBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "user" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/users/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "user": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user(UserBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PATCH) + .path(format!("/users/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "user": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .user(UserBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v3/version.rs b/sdk/identity/src/v3/version.rs similarity index 100% rename from openstack_sdk/src/api/identity/v3/version.rs rename to sdk/identity/src/v3/version.rs diff --git a/sdk/identity/src/v3/version/get.rs b/sdk/identity/src/v3/version/get.rs new file mode 100644 index 000000000..1af98fe62 --- /dev/null +++ b/sdk/identity/src/v3/version/get.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`. + +//! GET operation on /v3 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v3/version/head.rs b/sdk/identity/src/v3/version/head.rs new file mode 100644 index 000000000..5456339fd --- /dev/null +++ b/sdk/identity/src/v3/version/head.rs @@ -0,0 +1,168 @@ +// 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`. + +//! HEAD operation on /v3 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + "".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(3, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path("/".to_string()); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path("/".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v4.rs b/sdk/identity/src/v4.rs similarity index 100% rename from openstack_sdk/src/api/identity/v4.rs rename to sdk/identity/src/v4.rs diff --git a/openstack_sdk/src/api/identity/v4/federation.rs b/sdk/identity/src/v4/federation.rs similarity index 100% rename from openstack_sdk/src/api/identity/v4/federation.rs rename to sdk/identity/src/v4/federation.rs diff --git a/openstack_sdk/src/api/identity/v4/federation/identity_provider.rs b/sdk/identity/src/v4/federation/identity_provider.rs similarity index 100% rename from openstack_sdk/src/api/identity/v4/federation/identity_provider.rs rename to sdk/identity/src/v4/federation/identity_provider.rs diff --git a/sdk/identity/src/v4/federation/identity_provider/create.rs b/sdk/identity/src/v4/federation/identity_provider/create.rs new file mode 100644 index 000000000..8bc2578b2 --- /dev/null +++ b/sdk/identity/src/v4/federation/identity_provider/create.rs @@ -0,0 +1,328 @@ +// 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 the identity provider with the specified properties. +//! +//! It is expected that only admin user is able to create global identity +//! providers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// Identity provider data. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct IdentityProvider<'a> { + /// The bound issuer that is verified when using the identity provider. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bound_issuer: Option>, + + /// Default attribute mapping name which is automatically used when no + /// mapping is explicitly requested. The referred attribute mapping must + /// exist. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_mapping_name: Option>, + + /// The ID of the domain this identity provider belongs to. Empty value + /// identifies that the identity provider can be used by other domains as + /// well. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>, + + /// Identity provider `enabled` property. Inactive Identity Providers can + /// not be used for login. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// Optional URL to fetch JsonWebKeySet. Must be specified for JWT + /// authentication when discovery for the provider is not available or not + /// standard compliant. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) jwks_url: Option>, + + /// List of the jwt validation public keys. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) jwt_validation_pubkeys: Option>>, + + /// Identity provider name. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// The oidc `client_id` to use for the private client. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_client_id: Option>, + + /// The oidc `client_secret` to use for the private client. It is never + /// returned back. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_client_secret: Option>, + + /// OIDC discovery endpoint for the identity provider. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_discovery_url: Option>, + + /// The oidc response mode. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_response_mode: Option>, + + /// List of supported response types. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_response_types: Option>>, + + /// Additional special provider specific configuration. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_provider_config"))] + pub(crate) provider_config: Option, Value>>, +} + +impl<'a> IdentityProviderBuilder<'a> { + /// Additional special provider specific configuration. + pub fn provider_config(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.provider_config + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Identity provider data. + #[builder(setter(into))] + pub(crate) identity_provider: IdentityProvider<'a>, + + #[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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "federation/identity_providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "identity_provider", + serde_json::to_value(&self.identity_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_provider".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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .identity_provider( + IdentityProviderBuilder::default() + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .identity_provider( + IdentityProviderBuilder::default() + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "identity_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/federation/identity_providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .identity_provider( + IdentityProviderBuilder::default() + .name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/federation/identity_providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .identity_provider( + IdentityProviderBuilder::default() + .name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/identity_provider/delete.rs b/sdk/identity/src/v4/federation/identity_provider/delete.rs new file mode 100644 index 000000000..ca9b9d854 --- /dev/null +++ b/sdk/identity/src/v4/federation/identity_provider/delete.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Deletes the existing identity provider. +//! +//! It is expected that only admin user is allowed to delete the global +//! identity provider +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the identity provider + #[builder(default, setter(into))] + idp_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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "federation/identity_providers/{idp_id}", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/federation/identity_providers/{idp_id}", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/federation/identity_providers/{idp_id}", + idp_id = "idp_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() + .idp_id("idp_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/identity_provider/get.rs b/sdk/identity/src/v4/federation/identity_provider/get.rs new file mode 100644 index 000000000..a6087b6b5 --- /dev/null +++ b/sdk/identity/src/v4/federation/identity_provider/get.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows details of the existing identity provider. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the identity provider + #[builder(default, setter(into))] + idp_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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "federation/identity_providers/{idp_id}", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_provider".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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "identity_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/federation/identity_providers/{idp_id}", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder().idp_id("idp_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/federation/identity_providers/{idp_id}", + idp_id = "idp_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/identity_provider/list.rs b/sdk/identity/src/v4/federation/identity_provider/list.rs new file mode 100644 index 000000000..94f25eea5 --- /dev/null +++ b/sdk/identity/src/v4/federation/identity_provider/list.rs @@ -0,0 +1,208 @@ +// 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 identity providers. Without any filters only global identity providers +//! are returned. With the `domain_id` identity providers owned by the +//! specified identity provider are returned. +//! +//! It is expected that only global or owned identity providers can be +//! returned, while an admin user is able to list all providers. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filters the response by a domain ID. + #[builder(default, setter(into))] + domain_id: Option>, + + /// Limit number of entries on the single response page. + #[builder(default)] + limit: Option, + + /// Page marker (id of the last entry on the previous page. + #[builder(default, setter(into))] + marker: Option>, + + /// Filters the response by IDP name. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "federation/identity_providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("name", self.name.as_ref()); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_providers".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(4, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "identity_providers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/federation/identity_providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_providers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/federation/identity_providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_providers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/identity_provider/set.rs b/sdk/identity/src/v4/federation/identity_provider/set.rs new file mode 100644 index 000000000..0e793d0d1 --- /dev/null +++ b/sdk/identity/src/v4/federation/identity_provider/set.rs @@ -0,0 +1,331 @@ +// 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`. + +//! Updates the existing identity provider. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// New identity provider data. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct IdentityProvider<'a> { + /// The new bound issuer that is verified when using the identity provider. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bound_issuer: Option>>, + + /// New default attribute mapping name which is automatically used when no + /// mapping is explicitly requested. The referred attribute mapping must + /// exist. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_mapping_name: Option>>, + + /// Identity provider `enabled` property. Inactive Identity Providers can + /// not be used for login. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option>, + + /// New URL to fetch JsonWebKeySet. This must be set for "jwt" mapping when + /// the provider does not provide discovery endpoint or when it is not + /// standard compliant. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) jwks_url: Option>>, + + /// The list of the jwt validation public keys. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) jwt_validation_pubkeys: Option>>, + + /// The new name of the federated identity provider. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The new oidc `client_id` to use for the private client. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_client_id: Option>>, + + /// The new oidc `client_secret` to use for the private client. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_client_secret: Option>>, + + /// The new OIDC discovery endpoint for the identity provider. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_discovery_url: Option>>, + + /// The new oidc response mode. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_response_mode: Option>>, + + /// The new oidc response mode. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_response_types: Option>>, + + /// New additional provider configuration. + #[serde()] + #[builder(private, setter(into, name = "_provider_config"))] + pub(crate) provider_config: BTreeMap, Value>, +} + +impl<'a> IdentityProviderBuilder<'a> { + /// New additional provider configuration. + pub fn provider_config(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.provider_config + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// New identity provider data. + #[builder(setter(into))] + pub(crate) identity_provider: IdentityProvider<'a>, + + /// The ID of the identity provider + #[builder(default, setter(into))] + idp_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 Identity_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "federation/identity_providers/{idp_id}", + idp_id = self.idp_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "identity_provider", + serde_json::to_value(&self.identity_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("identity_provider".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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .identity_provider( + IdentityProviderBuilder::default() + .provider_config(BTreeMap::::new().into_iter()) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .identity_provider( + IdentityProviderBuilder::default() + .provider_config(BTreeMap::::new().into_iter()) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "identity_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/federation/identity_providers/{idp_id}", + idp_id = "idp_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .identity_provider( + IdentityProviderBuilder::default() + .provider_config(BTreeMap::::new().into_iter()) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/federation/identity_providers/{idp_id}", + idp_id = "idp_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "identity_provider": {} })); + }); + + let endpoint = Request::builder() + .idp_id("idp_id") + .identity_provider( + IdentityProviderBuilder::default() + .provider_config(BTreeMap::::new().into_iter()) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v4/federation/mapping.rs b/sdk/identity/src/v4/federation/mapping.rs similarity index 100% rename from openstack_sdk/src/api/identity/v4/federation/mapping.rs rename to sdk/identity/src/v4/federation/mapping.rs diff --git a/sdk/identity/src/v4/federation/mapping/create.rs b/sdk/identity/src/v4/federation/mapping/create.rs new file mode 100644 index 000000000..044064755 --- /dev/null +++ b/sdk/identity/src/v4/federation/mapping/create.rs @@ -0,0 +1,358 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "jwt")] + Jwt, + #[serde(rename = "oidc")] + Oidc, +} + +/// OIDC/JWT attribute mapping create data. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Mapping<'a> { + /// List of allowed redirect urls (only for `oidc` type). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allowed_redirect_uris: Option>>, + + /// List of audiences that must be present in the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bound_audiences: Option>>, + + /// Additional claims that must be present in the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_bound_claims"))] + pub(crate) bound_claims: Option, Value>>, + + /// Token subject value that must be set in the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bound_subject: Option>, + + /// `domain_id` owning the attribute mapping. + /// + /// Unset `domain_id` means the attribute mapping is shared and can be used + /// by different domains. This requires `domain_id_claim` to be present. + /// Attribute mapping can be only shared when the referred identity + /// provider is also shared (does not set the `domain_id` attribute). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>, + + /// `domain_id` claim name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id_claim: Option>, + + /// Mapping enabled property. Inactive mappings can not be used for login. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// `groups` claim name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) groups_claim: Option>, + + /// Attribute mapping ID for federated logins. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>>, + + /// ID of the federated identity provider for which this attribute mapping + /// can be used. + #[serde()] + #[builder(setter(into))] + pub(crate) idp_id: Cow<'a, str>, + + /// Attribute mapping name for federated logins. + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// List of OIDC scopes. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_scopes: Option>>, + + /// Fixed project_id for the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) token_project_id: Option>, + + /// Token restrictions to be applied to the granted token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) token_restriction_id: Option>>, + + /// Attribute mapping type. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, + + /// `user_id` claim name. + #[serde()] + #[builder(setter(into))] + pub(crate) user_id_claim: Cow<'a, str>, + + /// `user_name` claim name. + #[serde()] + #[builder(setter(into))] + pub(crate) user_name_claim: Cow<'a, str>, +} + +impl<'a> MappingBuilder<'a> { + /// Additional claims that must be present in the token. + pub fn bound_claims(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.bound_claims + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// OIDC/JWT attribute mapping create data. + #[builder(setter(into))] + pub(crate) mapping: Mapping<'a>, + + #[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 Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "federation/mappings".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("mapping", serde_json::to_value(&self.mapping)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mapping".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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .mapping( + MappingBuilder::default() + .idp_id("foo") + .name("foo") + .user_id_claim("foo") + .user_name_claim("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .mapping( + MappingBuilder::default() + .idp_id("foo") + .name("foo") + .user_id_claim("foo") + .user_name_claim("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "mapping" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/federation/mappings".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .mapping( + MappingBuilder::default() + .idp_id("foo") + .name("foo") + .user_id_claim("foo") + .user_name_claim("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/federation/mappings".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .mapping( + MappingBuilder::default() + .idp_id("foo") + .name("foo") + .user_id_claim("foo") + .user_name_claim("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/mapping/delete.rs b/sdk/identity/src/v4/federation/mapping/delete.rs new file mode 100644 index 000000000..89fbc8663 --- /dev/null +++ b/sdk/identity/src/v4/federation/mapping/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the attribute mapping + #[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<'a> RequestBuilder<'a> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("federation/mappings/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + 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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/federation/mappings/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/federation/mappings/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/mapping/get.rs b/sdk/identity/src/v4/federation/mapping/get.rs new file mode 100644 index 000000000..c1f631121 --- /dev/null +++ b/sdk/identity/src/v4/federation/mapping/get.rs @@ -0,0 +1,184 @@ +// 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 attribute mapping attribute by the ID. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the attribute mapping. + #[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<'a> RequestBuilder<'a> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("federation/mappings/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mapping".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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "mapping" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/federation/mappings/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/federation/mappings/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/mapping/list.rs b/sdk/identity/src/v4/federation/mapping/list.rs new file mode 100644 index 000000000..9b6b5188d --- /dev/null +++ b/sdk/identity/src/v4/federation/mapping/list.rs @@ -0,0 +1,218 @@ +// 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 available federation mappings. +//! +//! Without `domain_id` specified global mappings are returned. +//! +//! It is expected that listing mappings belonging to the other domain is only +//! allowed to the admin user. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Filters the response by a mapping type. + #[builder(default, setter(into))] + _type: Option>, + + /// Filters the response by a domain ID. + #[builder(default, setter(into))] + domain_id: Option>, + + /// Filters the response by a idp ID. + #[builder(default, setter(into))] + idp_id: Option>, + + /// Limit number of entries on the single response page (Maximal 100). + #[builder(default)] + limit: Option, + + /// Page marker (id of the last entry on the previous page. + #[builder(default, setter(into))] + marker: Option>, + + /// Filters the response by IDP name. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "federation/mappings".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("idp_id", self.idp_id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("type", self._type.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mappings".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(4, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "mappings" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/federation/mappings".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mappings": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/federation/mappings".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mappings": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/identity/src/v4/federation/mapping/set.rs b/sdk/identity/src/v4/federation/mapping/set.rs new file mode 100644 index 000000000..5dd4e7997 --- /dev/null +++ b/sdk/identity/src/v4/federation/mapping/set.rs @@ -0,0 +1,328 @@ +// 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`. + +//! TODO: describe domain_id update rules +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "jwt")] + Jwt, + #[serde(rename = "oidc")] + Oidc, +} + +/// OIDC/JWT attribute mapping update data. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Mapping<'a> { + /// List of allowed redirect urls (only for `oidc` type). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allowed_redirect_uris: Option>>, + + /// List of audiences that must be present in the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bound_audiences: Option>>, + + /// Additional claims that must be present in the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_bound_claims"))] + pub(crate) bound_claims: Option, Value>>, + + /// Token subject value that must be set in the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) bound_subject: Option>>, + + /// `domain_id` owning the attribute mapping. + /// + /// Unset `domain_id` means the attribute mapping is shared and can be used + /// by different domains. This requires `domain_id_claim` to be present. + /// Attribute mapping can be only shared when the referred identity + /// provider is also shared (does not set the `domain_id` attribute). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_id_claim: Option>>, + + /// Mapping enabled property. Inactive mappings can not be used for login. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// `groups` claim name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) groups_claim: Option>>, + + /// ID of the federated identity provider for which this attribute mapping + /// can be used. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) idp_id: Option>>, + + /// Attribute mapping name for federated logins. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// List of OIDC scopes. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) oidc_scopes: Option>>, + + /// Fixed project_id for the token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) token_project_id: Option>>, + + /// Token restrictions to be applied to the granted token. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) token_restriction_id: Option>>, + + /// Attribute mapping type. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, + + /// `user_id` claim name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user_id_claim: Option>>, + + /// `user_name` claim name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) user_name_claim: Option>>, +} + +impl<'a> MappingBuilder<'a> { + /// Additional claims that must be present in the token. + pub fn bound_claims(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.bound_claims + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// OIDC/JWT attribute mapping update data. + #[builder(setter(into))] + pub(crate) mapping: Mapping<'a>, + + /// The ID of the attribute mapping. + #[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<'a> RequestBuilder<'a> { + /// Add a single header to the Mapping. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("federation/mappings/{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("mapping", serde_json::to_value(&self.mapping)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Identity + } + + fn response_key(&self) -> Option> { + Some("mapping".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(4, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .mapping(MappingBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Identity + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .mapping(MappingBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "mapping" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/federation/mappings/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .mapping(MappingBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/federation/mappings/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "mapping": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .mapping(MappingBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/identity/v4/user.rs b/sdk/identity/src/v4/user.rs similarity index 100% rename from openstack_sdk/src/api/identity/v4/user.rs rename to sdk/identity/src/v4/user.rs diff --git a/openstack_sdk/src/api/identity/v4/user/passkey.rs b/sdk/identity/src/v4/user/passkey.rs similarity index 100% rename from openstack_sdk/src/api/identity/v4/user/passkey.rs rename to sdk/identity/src/v4/user/passkey.rs diff --git a/openstack_sdk/src/api/identity/v4/user/passkey/register_finish.rs b/sdk/identity/src/v4/user/passkey/register_finish.rs similarity index 99% rename from openstack_sdk/src/api/identity/v4/user/passkey/register_finish.rs rename to sdk/identity/src/v4/user/passkey/register_finish.rs index 6390be6ea..848470af3 100644 --- a/openstack_sdk/src/api/identity/v4/user/passkey/register_finish.rs +++ b/sdk/identity/src/v4/user/passkey/register_finish.rs @@ -255,7 +255,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/identity/v4/user/passkey/register_start.rs b/sdk/identity/src/v4/user/passkey/register_start.rs similarity index 99% rename from openstack_sdk/src/api/identity/v4/user/passkey/register_start.rs rename to sdk/identity/src/v4/user/passkey/register_start.rs index 78bd93fb6..f613076d0 100644 --- a/openstack_sdk/src/api/identity/v4/user/passkey/register_start.rs +++ b/sdk/identity/src/v4/user/passkey/register_start.rs @@ -141,7 +141,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/image/Cargo.toml b/sdk/image/Cargo.toml new file mode 100644 index 000000000..66015965a --- /dev/null +++ b/sdk/image/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "openstack-sdk-image" +description = "OpenStack SDK Image service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +json-patch.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/image/src/lib.rs b/sdk/image/src/lib.rs new file mode 100644 index 000000000..c4c997274 --- /dev/null +++ b/sdk/image/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Image` Service bindings +pub mod v2; diff --git a/openstack_sdk/src/api/image/v2.rs b/sdk/image/src/v2.rs similarity index 100% rename from openstack_sdk/src/api/image/v2.rs rename to sdk/image/src/v2.rs diff --git a/openstack_sdk/src/api/image/v2/cache.rs b/sdk/image/src/v2/cache.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/cache.rs rename to sdk/image/src/v2/cache.rs diff --git a/sdk/image/src/v2/cache/delete.rs b/sdk/image/src/v2/cache/delete.rs new file mode 100644 index 000000000..4d81aa387 --- /dev/null +++ b/sdk/image/src/v2/cache/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a image from cache. *(Since Image API v2.14)* +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/cache/{image_id} API + #[builder(default, setter(into))] + image_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 Cache. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("cache/{image_id}", image_id = self.image_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/cache/{image_id}", image_id = "image_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().image_id("image_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/cache/{image_id}", image_id = "image_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() + .image_id("image_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/cache/delete_all.rs b/sdk/image/src/v2/cache/delete_all.rs new file mode 100644 index 000000000..a0c8717ab --- /dev/null +++ b/sdk/image/src/v2/cache/delete_all.rs @@ -0,0 +1,178 @@ +// 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`. + +//! Clears the cache and its queue. *(Since Image API v2.14)* +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Cache. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "cache".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/cache".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path("/cache".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/cache/list.rs b/sdk/image/src/v2/cache/list.rs new file mode 100644 index 000000000..6407f4ede --- /dev/null +++ b/sdk/image/src/v2/cache/list.rs @@ -0,0 +1,178 @@ +// 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`. + +//! Lists all images in cache or queue. *(Since Image API v2.14)* +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Cache. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "cache".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cache".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cache".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/cache/set.rs b/sdk/image/src/v2/cache/set.rs new file mode 100644 index 000000000..73b250cc3 --- /dev/null +++ b/sdk/image/src/v2/cache/set.rs @@ -0,0 +1,212 @@ +// 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`. + +//! Queues image for caching. *(Since Image API v2.14)* +//! +//! Normal response codes: 202 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/cache/{image_id} API + #[builder(default, setter(into))] + image_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Cache. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("cache/{image_id}", image_id = self.image_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/cache/{image_id}", image_id = "image_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().image_id("image_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/cache/{image_id}", image_id = "image_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() + .image_id("image_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image.rs b/sdk/image/src/v2/image.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image.rs rename to sdk/image/src/v2/image.rs diff --git a/sdk/image/src/v2/image/create.rs b/sdk/image/src/v2/image/create.rs new file mode 100644 index 000000000..0b018c9cc --- /dev/null +++ b/sdk/image/src/v2/image/create.rs @@ -0,0 +1,467 @@ +// 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`. + +//! Creates a catalog record for an operating system disk image. *(Since Image +//! API v2.0)* +//! +//! The `Location` response header contains the URI for the image. +//! +//! A multiple store backend support is introduced in the Rocky release as a +//! part of the EXPERIMENTAL Image API v2.8. Since Image API v2.8 a new header +//! `OpenStack-image-store-ids` which contains the list of available stores +//! will be included in response. This header is only included if multiple +//! backend stores are supported. +//! +//! The response body contains the new image entity. +//! +//! Synchronous Postconditions +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 409, 413, 415 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum ContainerFormat { + #[serde(rename = "aki")] + Aki, + #[serde(rename = "ami")] + Ami, + #[serde(rename = "ari")] + Ari, + #[serde(rename = "bare")] + Bare, + #[serde(rename = "compressed")] + Compressed, + #[serde(rename = "docker")] + Docker, + #[serde(rename = "ova")] + Ova, + #[serde(rename = "ovf")] + Ovf, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum DiskFormat { + #[serde(rename = "aki")] + Aki, + #[serde(rename = "ami")] + Ami, + #[serde(rename = "ari")] + Ari, + #[serde(rename = "iso")] + Iso, + #[serde(rename = "ploop")] + Ploop, + #[serde(rename = "qcow2")] + Qcow2, + #[serde(rename = "raw")] + Raw, + #[serde(rename = "vdi")] + Vdi, + #[serde(rename = "vhd")] + Vhd, + #[serde(rename = "vhdx")] + Vhdx, + #[serde(rename = "vmdk")] + Vmdk, +} + +/// Values to be used to populate the corresponding image properties. If the +/// image status is not 'queued', values must exactly match those already +/// contained in the image properties. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ValidationData<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) checksum: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) os_hash_algo: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) os_hash_value: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Locations<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Value>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) url: Cow<'a, str>, + + /// Values to be used to populate the corresponding image properties. If + /// the image status is not 'queued', values must exactly match those + /// already contained in the image properties. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) validation_data: Option>, +} + +impl<'a> LocationsBuilder<'a> { + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.metadata + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Visibility { + #[serde(rename = "community")] + Community, + #[serde(rename = "private")] + Private, + #[serde(rename = "public")] + Public, + #[serde(rename = "shared")] + Shared, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Format of the image container. + /// + /// Values may vary based on the configuration available in a particular + /// OpenStack cloud. See the [Image Schema](#image-schema) response from + /// the cloud itself for the valid values available. See + /// [Container Format](https://docs.openstack.org/glance/latest/user/formats.html#container-format) + /// in the Glance documentation for more information. + /// + /// Example formats are: `ami`, `ari`, `aki`, `bare`, `ovf`, `ova`, + /// `docker`, or `compressed`. + /// + /// The value might be `null` (JSON null data type). + /// + /// **Train changes**: The `compressed` container format is a supported + /// value. + #[builder(default)] + pub(crate) container_format: Option, + + /// The format of the disk. + /// + /// Values may vary based on the configuration available in a particular + /// OpenStack cloud. See the [Image Schema](#image-schema) response from + /// the cloud itself for the valid values available. See + /// [Disk Format](https://docs.openstack.org/glance/latest/user/formats.html#disk-format) + /// in the Glance documentation for more information. + /// + /// Example formats are: `ami`, `ari`, `aki`, `vhd`, `vhdx`, `vmdk`, `raw`, + /// `qcow2`, `vdi`, `ploop` or `iso`. + /// + /// The value might be `null` (JSON null data type). + /// + /// **Newton changes**: The `vhdx` disk format is a supported value.\ + /// **Ocata changes**: The `ploop` disk format is a supported value. + #[builder(default)] + pub(crate) disk_format: Option, + + /// A unique, user-defined image UUID, in the format: + /// + /// ```text + /// nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn + /// ``` + /// + /// Where **n** is a hexadecimal digit from 0 to f, or F. + /// + /// For example: + /// + /// ```text + /// b2173dd3-7ad6-4362-baa6-a68bce3565cb + /// ``` + /// + /// If you omit this value, the API generates a UUID for the image. If you + /// specify a value that has already been assigned, the request fails with + /// a `409` response code. + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// A set of URLs to access the image file kept in external store + #[builder(default, setter(into))] + pub(crate) locations: Option>>, + + /// Amount of disk space in GB that is required to boot the image. + #[builder(default, setter(into))] + pub(crate) min_disk: Option, + + /// Amount of RAM in MB that is required to boot the image. + #[builder(default, setter(into))] + pub(crate) min_ram: Option, + + /// The name of the image. + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// If true, image will not appear in default image list response. + #[builder(default, setter(into))] + pub(crate) os_hidden: Option, + + /// Owner of the image + #[builder(default, setter(into))] + pub(crate) owner: Option>>, + + /// Image protection for deletion. Valid value is `true` or `false`. + /// Default is `false`. + #[builder(default, setter(into))] + pub(crate) protected: Option, + + /// List of tags for this image. Each tag is a string of at most 255 chars. + /// The maximum number of tags allowed on an image is set by the operator. + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// Visibility for this image. Valid value is one of: `public`, `private`, + /// `shared`, or `community`. At most sites, only an administrator can make + /// an image `public`. Some sites may restrict what users can make an image + /// `community`. Some sites may restrict what users can perform member + /// operations on a `shared` image. *Since the Image API v2.5, the default + /// value is `shared`.* + #[builder(default)] + pub(crate) visibility: Option, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Cow<'a, str>>, +} +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 Image. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "images".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.container_format { + params.push("container_format", serde_json::to_value(val)?); + } + if let Some(val) = &self.disk_format { + params.push("disk_format", serde_json::to_value(val)?); + } + if let Some(val) = &self.id { + params.push("id", serde_json::to_value(val)?); + } + if let Some(val) = &self.locations { + params.push("locations", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_disk { + params.push("min_disk", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_ram { + params.push("min_ram", serde_json::to_value(val)?); + } + if let Some(val) = &self.name { + params.push("name", serde_json::to_value(val)?); + } + if let Some(val) = &self.os_hidden { + params.push("os_hidden", serde_json::to_value(val)?); + } + if let Some(val) = &self.owner { + params.push("owner", serde_json::to_value(val)?); + } + if let Some(val) = &self.protected { + params.push("protected", serde_json::to_value(val)?); + } + if let Some(val) = &self.tags { + params.push("tags", serde_json::to_value(val)?); + } + if let Some(val) = &self.visibility { + params.push("visibility", serde_json::to_value(val)?); + } + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/images".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/images".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image/deactivate.rs b/sdk/image/src/v2/image/deactivate.rs similarity index 99% rename from openstack_sdk/src/api/image/v2/image/deactivate.rs rename to sdk/image/src/v2/image/deactivate.rs index 0d0fd0d1c..e1d1bc417 100644 --- a/openstack_sdk/src/api/image/v2/image/deactivate.rs +++ b/sdk/image/src/v2/image/deactivate.rs @@ -153,7 +153,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/image/src/v2/image/delete.rs b/sdk/image/src/v2/image/delete.rs new file mode 100644 index 000000000..694564d02 --- /dev/null +++ b/sdk/image/src/v2/image/delete.rs @@ -0,0 +1,192 @@ +// 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`. + +//! (Since Image API v2.0) Deletes an image. +//! +//! You cannot delete images with the `protected` attribute set to `true` +//! (boolean). +//! +//! Preconditions +//! +//! Synchronous Postconditions +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_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<'a> RequestBuilder<'a> { + /// Add a single header to the Image. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("images/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/images/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/images/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image/file.rs b/sdk/image/src/v2/image/file.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image/file.rs rename to sdk/image/src/v2/image/file.rs diff --git a/openstack_sdk/src/api/image/v2/image/file/download.rs b/sdk/image/src/v2/image/file/download.rs similarity index 98% rename from openstack_sdk/src/api/image/v2/image/file/download.rs rename to sdk/image/src/v2/image/file/download.rs index 36d4a67a0..44b7d4830 100644 --- a/openstack_sdk/src/api/image/v2/image/file/download.rs +++ b/sdk/image/src/v2/image/file/download.rs @@ -128,7 +128,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/image/v2/image/file/upload.rs b/sdk/image/src/v2/image/file/upload.rs similarity index 99% rename from openstack_sdk/src/api/image/v2/image/file/upload.rs rename to sdk/image/src/v2/image/file/upload.rs index ba599a345..cdf562d24 100644 --- a/openstack_sdk/src/api/image/v2/image/file/upload.rs +++ b/sdk/image/src/v2/image/file/upload.rs @@ -144,7 +144,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/image/src/v2/image/find.rs b/sdk/image/src/v2/image/find.rs new file mode 100644 index 000000000..a6e84d135 --- /dev/null +++ b/sdk/image/src/v2/image/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::image::{get as Get, list as List}; + +/// Find for image 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/image/src/v2/image/get.rs b/sdk/image/src/v2/image/get.rs new file mode 100644 index 000000000..66b8acb3a --- /dev/null +++ b/sdk/image/src/v2/image/get.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Shows details for an image. *(Since Image API v2.0)* +//! +//! The response body contains a single image entity. +//! +//! Preconditions +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_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<'a> RequestBuilder<'a> { + /// Add a single header to the Image. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("images/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/images/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/images/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image/import.rs b/sdk/image/src/v2/image/import.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image/import.rs rename to sdk/image/src/v2/image/import.rs diff --git a/sdk/image/src/v2/image/import/create.rs b/sdk/image/src/v2/image/import/create.rs new file mode 100644 index 000000000..d6964071b --- /dev/null +++ b/sdk/image/src/v2/image/import/create.rs @@ -0,0 +1,322 @@ +// 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`. + +//! Signals the Image Service to complete the image import workflow by +//! processing data that has been made available to the OpenStack image +//! service. *(Since Image API v2.6)* +//! +//! In the `glance-direct` workflow, the data has been made available to the +//! Image service via the [Stage binary image data](#image-stage-call) API +//! call. +//! +//! In the `web-download` workflow, the data is made available to the Image +//! service by being posted to an accessible location with a URL that you know. +//! +//! In the `copy-image` workflow, the data is made available to the Image +//! service by copying existing image data to the staging area. +//! +//! In the `glance-download` workflow, the data is made available to the Image +//! service by fetching an image accessible from another glance service +//! specified by a region name and an image id that you know. +//! +//! Beginning with API version 2.8, an optional `stores` parameter may be added +//! to the body request. When present, it contains the list of backing store +//! identifiers to import the image binary data to. If at least one store +//! identifier specified is not recognized, a 409 (Conflict) response is +//! returned. When the parameter is not present, the image data is placed into +//! the default backing store. +//! +//! For backwards compatibility, if the `stores` parameter is not specified, +//! the header ‘X-Image-Meta-Store’ is evaluated. +//! +//! To import the data into the entire set of stores you may consume from this +//! particular deployment of Glance without specifying each one of them, you +//! can use the optional boolean body parameter `all_stores`. Note that this +//! can’t be used simultaneously with the `stores` parameter. +//! +//! To set the behavior of the import workflow in case of error, you can use +//! the optional boolean body parameter `all_stores_must_succeed`. When set to +//! True (default), if an error occurs during the upload in at least one store, +//! the workflow fails, the data is deleted from stores where copying is done +//! and the state of the image remains unchanged. When set to False, the +//! workflow will fail only if the upload fails on all stores specified. In +//! case of a partial success, the locations added to the image will be the +//! stores where the data has been correctly uploaded. +//! +//! The JSON request body specifies what import method you wish to use for this +//! image request. +//! +//! **Preconditions** +//! +//! Before you can complete the interoperable image import workflow, you must +//! meet the following preconditions: +//! +//! **Additional Preconditions** +//! +//! If you are using the `glance-direct` import method: +//! +//! If you are using the `web-download` import method: +//! +//! If you are using the `copy-image` import method: +//! +//! If you are using the `glance-download` import method: +//! +//! **Synchronous Postconditions** +//! +//! Normal response codes: 202 +//! +//! Error response codes: 400, 401, 403, 404, 405, 409, 410, 413, 415, 503 +//! +//! If the image import process is not enabled in your cloud, this request will +//! result in a 404 response code with an appropriate message. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A JSON object indicating what import method you wish to use to import your +/// image. The content of this JSON object is another JSON object with a `name` +/// field whose value is the identifier for the import method. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Method<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) glance_image_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) glance_region: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) glance_service_interface: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) uri: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// When set to True the data will be imported to the set of stores you may + /// consume from this particular deployment of Glance (ie: the same set of + /// stores returned to a call to /v2/info/stores on the glance-api the + /// request hits). This can’t be used simultaneously with the `stores` + /// parameter. + #[builder(default, setter(into))] + pub(crate) all_stores: Option, + + #[builder(default, setter(into))] + pub(crate) all_stores_must_success: Option, + + /// A JSON object indicating what import method you wish to use to import + /// your image. The content of this JSON object is another JSON object with + /// a `name` field whose value is the identifier for the import method. + #[builder(default, setter(into))] + pub(crate) method: Option>, + + /// If present contains the list of store id to import the image binary + /// data to. + #[builder(default, setter(into))] + pub(crate) stores: Option>>, + + /// image_id parameter for /v2/images/{image_id}/import API + #[builder(default, setter(into))] + image_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 Import. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "images/{image_id}/import", + image_id = self.image_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.all_stores { + params.push("all_stores", serde_json::to_value(val)?); + } + if let Some(val) = &self.all_stores_must_success { + params.push("all_stores_must_success", serde_json::to_value(val)?); + } + if let Some(val) = &self.method { + params.push("method", serde_json::to_value(val)?); + } + if let Some(val) = &self.stores { + params.push("stores", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/images/{image_id}/import", image_id = "image_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().image_id("image_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/images/{image_id}/import", image_id = "image_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() + .image_id("image_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/image/list.rs b/sdk/image/src/v2/image/list.rs new file mode 100644 index 000000000..db9b5d095 --- /dev/null +++ b/sdk/image/src/v2/image/list.rs @@ -0,0 +1,415 @@ +// 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`. + +//! Lists public virtual machine (VM) images. *(Since Image API v2.0)* +//! +//! **Pagination** +//! +//! Returns a subset of the larger collection of images and a link that you can +//! use to get the next set of images. You should always check for the presence +//! of a `next` link and use it as the URI in a subsequent HTTP GET request. +//! You should follow this pattern until a `next` link is no longer provided. +//! +//! The `next` link preserves any query parameters that you send in your +//! initial request. You can use the `first` link to jump back to the first +//! page of the collection. If you prefer to paginate through images manually, +//! use the `limit` and `marker` parameters. +//! +//! **Query Filters** +//! +//! The list operation accepts query parameters to filter the response. +//! +//! A client can provide direct comparison filters by using most image +//! attributes, such as `name=Ubuntu`, `visibility=public`, and so on. +//! +//! To filter using image tags, use the filter `tag` (note the singular). To +//! filter on multiple tags, include each tag separately in the query. For +//! example, to find images with the tag **ready**, include `tag=ready` in your +//! query string. To find images tagged with **ready** and **approved**, +//! include `tag=ready&tag=approved` in your query string. (Note that only +//! images containing *both* tags will be included in the response.) +//! +//! A client cannot use any `link` in the json-schema, such as self, file, or +//! schema, to filter the response. +//! +//! You can list VM images that have a status of `active`, `queued`, or +//! `saving`. +//! +//! **The** `in` **Operator** +//! +//! As a convenience, you may specify several values for any of the following +//! fields by using the `in` operator: +//! +//! For most of these, usage is straight forward. For example, to list images +//! in queued or saving status, use: +//! +//! `GET /v2/images?status=in:saving,queued` +//! +//! To find images in a particular list of image IDs, use: +//! +//! `GET /v2/images?id=in:3afb79c1-131a-4c38-a87c-bc4b801d14e6,2e011209-660f-44b5-baf2-2eb4babae53d` +//! +//! Using the `in` operator with the `name` property of images can be a bit +//! trickier, depending upon how creatively you have named your images. The +//! general rule is that if an image name contains a comma (`,`), you must +//! enclose the entire name in quotation marks (`"`). As usual, you must URL +//! encode any characters that require it. +//! +//! For example, to find images named `glass, darkly` or `share me`, you would +//! use the following filter specification: +//! +//! `GET v2/images?name=in:"glass,%20darkly",share%20me` +//! +//! As with regular filtering by name, you must specify the complete name you +//! are looking for. Thus, for example, the query string `name=in:glass,share` +//! will only match images with the exact name `glass` or the exact name +//! `share`. It will not find an image named `glass, darkly` or an image named +//! `share me`. +//! +//! **Size Comparison Filters** +//! +//! You can use the `size_min` and `size_max` query parameters to filter images +//! that are greater than or less than the image size. The size, in bytes, is +//! the size of an image on disk. +//! +//! For example, to filter the container to include only images that are from 1 +//! to 4 MB, set the `size_min` query parameter to `1048576` and the `size_max` +//! query parameter to `4194304`. +//! +//! **Time Comparison Filters** +//! +//! You can use a *comparison operator* along with the `created_at` or +//! `updated_at` fields to filter your results. Specify the operator first, a +//! colon (`:`) as a separator, and then the time in +//! [ISO 8601 Format](https://en.wikipedia.org/wiki/ISO_8601). Available +//! comparison operators are: +//! +//! For example: +//! +//! **Sorting** +//! +//! You can use query parameters to sort the results of this operation. +//! +//! To sort the response, use the `sort_key` and `sort_dir` query parameters: +//! +//! Alternatively, specify the `sort` query parameter: +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Specify a comparison filter based on the date and time when the + /// resource was created. + #[builder(default, setter(into))] + created_at: Option>, + + /// id filter parameter + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Filters the response by a member status. A valid value is accepted, + /// pending, rejected, or all. Default is accepted. + #[builder(default, setter(into))] + member_status: Option>, + + /// Filters the response by a name, as a string. A valid value is the name + /// of an image. + #[builder(default, setter(into))] + name: Option>, + + /// When true, filters the response to display only "hidden" images. By + /// default, "hidden" images are not included in the image-list response. + /// (Since Image API v2.7) + #[builder(default)] + os_hidden: Option, + + /// Filters the response by a project (also called a “tenant”) ID. Shows + /// only images that are shared with you by the specified owner. + #[builder(default, setter(into))] + owner: Option>, + + /// Filters the response by the ‘protected’ image property. A valid value + /// is one of ‘true’, ‘false’ (must be all lowercase). Any other value will + /// result in a 400 response. + #[builder(default)] + protected: Option, + + /// Filters the response by a maximum image size, in bytes. + #[builder(default, setter(into))] + size_max: Option>, + + /// Filters the response by a minimum image size, in bytes. + #[builder(default, setter(into))] + size_min: Option>, + + /// Sorts the response by one or more attribute and sort direction + /// combinations. You can also set multiple sort keys and directions. + /// Default direction is desc. Use the comma (,) character to separate + /// multiple values. For example: `sort=name:asc,status:desc` + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts the response by a set of one or more sort direction and attribute + /// (sort_key) combinations. A valid value for the sort direction is asc + /// (ascending) or desc (descending). If you omit the sort direction in a + /// set, the default is desc. + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts the response by an attribute, such as name, id, or updated_at. + /// Default is created_at. The API uses the natural sorting direction of + /// the sort_key image attribute. + #[builder(default, setter(into))] + sort_key: Option>, + + /// Filters the response by an image status. + #[builder(default, setter(into))] + status: Option>, + + /// Filters the response by the specified tag value. May be repeated, but + /// keep in mind that you're making a conjunctive query, so only images + /// containing all the tags specified will appear in the response. + #[builder(default, private, setter(name = "_tag"))] + tag: Option>>, + + /// Specify a comparison filter based on the date and time when the + /// resource was most recently modified. + #[builder(default, setter(into))] + updated_at: Option>, + + /// Filters the response by an image visibility value. A valid value is + /// public, private, community, shared, or all. (Note that if you filter on + /// shared, the images included in the response will only be those where + /// your member status is accepted unless you explicitly include a + /// member_status filter in the request.) If you omit this parameter, the + /// response shows public, private, and those shared images with a member + /// status of accepted. + #[builder(default, setter(into))] + visibility: 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> { + /// Filters the response by the specified tag value. May be repeated, but + /// keep in mind that you're making a conjunctive query, so only images + /// containing all the tags specified will appear in the response. + pub fn tag(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tag + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Image. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "images".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("member_status", self.member_status.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("os_hidden", self.os_hidden); + params.push_opt("owner", self.owner.as_ref()); + params.push_opt("protected", self.protected); + params.push_opt("size_max", self.size_max.as_ref()); + params.push_opt("size_min", self.size_min.as_ref()); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("status", self.status.as_ref()); + if let Some(val) = &self.tag { + params.extend(val.iter().map(|value| ("tag", value))); + } + params.push_opt("updated_at", self.updated_at.as_ref()); + params.push_opt("visibility", self.visibility.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("images".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "images" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/images".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "images": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/images".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "images": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image/location.rs b/sdk/image/src/v2/image/location.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image/location.rs rename to sdk/image/src/v2/image/location.rs diff --git a/sdk/image/src/v2/image/location/create.rs b/sdk/image/src/v2/image/location/create.rs new file mode 100644 index 000000000..bc87d1bb1 --- /dev/null +++ b/sdk/image/src/v2/image/location/create.rs @@ -0,0 +1,288 @@ +// 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`. + +//! Add location to an image which is in `queued` state. Accepts location url, +//! validation_data in JSON body. +//! +//! Adding a location to an image is only allowed for the owner or a user with +//! the service role. If these conditions are not met, a 403 (Forbidden) will +//! be returned. +//! +//! Attempting to add a location path to an image that is not in `queued` state +//! will result in a 409 (Conflict) response code +//! +//! Attempting to provide incorrect hash value in validation data(in the case +//! of http store) to the image will result in a 400 (Bad Request) response +//! code. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// An image metadata in key:value pairs containing values of `os_hash_value` +/// and `os_hash_algo` to be added to the image. If `do_secure_hash` is not +/// passed then it is the responsibility of the consumer of location add API to +/// provide the correct values in `validation_data`’ +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ValidationData<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) checksum: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) os_hash_algo: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) os_hash_value: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, private, setter(into, name = "_metadata"))] + pub(crate) metadata: Option, Value>>, + + /// The URL of the new location to be added in the image. + #[builder(setter(into))] + pub(crate) url: Cow<'a, str>, + + /// An image metadata in key:value pairs containing values of + /// `os_hash_value` and `os_hash_algo` to be added to the image. If + /// `do_secure_hash` is not passed then it is the responsibility of the + /// consumer of location add API to provide the correct values in + /// `validation_data`’ + #[builder(default, setter(into))] + pub(crate) validation_data: Option>, + + /// image_id parameter for /v2/images/{image_id}/locations API + #[builder(default, setter(into))] + image_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> { + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.metadata + .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 Location. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "images/{image_id}/locations", + image_id = self.image_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.metadata { + params.push("metadata", serde_json::to_value(val)?); + } + params.push("url", serde_json::to_value(&self.url)?); + if let Some(val) = &self.validation_data { + params.push("validation_data", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .url("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .url("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/images/{image_id}/locations", + image_id = "image_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .url("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/images/{image_id}/locations", + image_id = "image_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() + .image_id("image_id") + .url("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/image/location/list.rs b/sdk/image/src/v2/image/location/list.rs new file mode 100644 index 000000000..9afda0ee5 --- /dev/null +++ b/sdk/image/src/v2/image/location/list.rs @@ -0,0 +1,196 @@ +// 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`. + +//! Lists all locations associated to an image with location url and store-id, +//! accessible to only service user, for non service users API will return +//! forbidden. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_id}/locations API + #[builder(default, setter(into))] + image_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 Location. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "images/{image_id}/locations", + image_id = self.image_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/images/{image_id}/locations", + image_id = "image_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().image_id("image_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/images/{image_id}/locations", + image_id = "image_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() + .image_id("image_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image/member.rs b/sdk/image/src/v2/image/member.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image/member.rs rename to sdk/image/src/v2/image/member.rs diff --git a/sdk/image/src/v2/image/member/create.rs b/sdk/image/src/v2/image/member/create.rs new file mode 100644 index 000000000..6d18a577b --- /dev/null +++ b/sdk/image/src/v2/image/member/create.rs @@ -0,0 +1,222 @@ +// 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`. + +//! Adds a tenant ID as an image member. *(Since Image API v2.1)* +//! +//! Preconditions +//! +//! Synchronous Postconditions +//! +//! Troubleshooting +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 409, 413 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + image_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "images/{image_id}/members", + image_id = self.image_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/images/{image_id}/members", image_id = "image_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().image_id("image_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/images/{image_id}/members", image_id = "image_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() + .image_id("image_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/image/member/delete.rs b/sdk/image/src/v2/image/member/delete.rs new file mode 100644 index 000000000..5a2b55745 --- /dev/null +++ b/sdk/image/src/v2/image/member/delete.rs @@ -0,0 +1,213 @@ +// 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`. + +//! Deletes a tenant ID from the member list of an image. *(Since Image API +//! v2.1)* +//! +//! Preconditions +//! +//! Synchronous Postconditions +//! +//! Troubleshooting +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// member_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// image_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + image_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "images/{image_id}/members/{id}", + image_id = self.image_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/images/{image_id}/members/{id}", + image_id = "image_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/images/{image_id}/members/{id}", + image_id = "image_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() + .image_id("image_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/image/member/get.rs b/sdk/image/src/v2/image/member/get.rs new file mode 100644 index 000000000..496dc4b70 --- /dev/null +++ b/sdk/image/src/v2/image/member/get.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Shows image member details. *(Since Image API v2.1)* +//! +//! Response body is a single image member entity. +//! +//! Preconditions +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// member_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// image_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + image_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "images/{image_id}/members/{id}", + image_id = self.image_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/images/{image_id}/members/{id}", + image_id = "image_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/images/{image_id}/members/{id}", + image_id = "image_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() + .image_id("image_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/image/member/list.rs b/sdk/image/src/v2/image/member/list.rs new file mode 100644 index 000000000..e05ca26bd --- /dev/null +++ b/sdk/image/src/v2/image/member/list.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Lists the tenants that share this image. *(Since Image API v2.1)* +//! +//! If the image owner makes this call, the complete member list is returned. +//! +//! If a user who is an image member makes this call, the member list contains +//! only information for that user. +//! +//! If a user who is not an image member makes this call, the call returns the +//! HTTP `404` response code. +//! +//! Preconditions +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + image_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "images/{image_id}/members", + image_id = self.image_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("members".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "members" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/images/{image_id}/members", image_id = "image_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "members": {} })); + }); + + let endpoint = Request::builder().image_id("image_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/images/{image_id}/members", image_id = "image_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "members": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/image/member/set.rs b/sdk/image/src/v2/image/member/set.rs new file mode 100644 index 000000000..963bd89e3 --- /dev/null +++ b/sdk/image/src/v2/image/member/set.rs @@ -0,0 +1,246 @@ +// 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`. + +//! Sets the status for an image member. *(Since Image API v2.1)* +//! +//! This call allows an image member to change his or her *member status*. +//! +//! When an image is shared with you, you have immediate access to the image. +//! What updating your member status on the image does for you is that it +//! affects whether the image will appear in your image list response. +//! +//! For a more detailed discussion of image sharing, please consult +//! [Image API v2 Sharing](http://specs.openstack.org/openstack/glance-specs/specs/api/v2/sharing-image-api-v2.html). +//! +//! Preconditions +//! +//! Synchronous Postconditions +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// member_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// image_id parameter for /v2/images/{image_id}/members/{member_id} API + #[builder(default, setter(into))] + image_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "images/{image_id}/members/{id}", + image_id = self.image_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/images/{image_id}/members/{id}", + image_id = "image_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/images/{image_id}/members/{id}", + image_id = "image_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() + .image_id("image_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image/patch.rs b/sdk/image/src/v2/image/patch.rs similarity index 99% rename from openstack_sdk/src/api/image/v2/image/patch.rs rename to sdk/image/src/v2/image/patch.rs index be630e398..91ed78231 100644 --- a/openstack_sdk/src/api/image/v2/image/patch.rs +++ b/sdk/image/src/v2/image/patch.rs @@ -149,8 +149,8 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; use json_patch::Patch; + use openstack_sdk_core::test::client::FakeOpenStackClient; use serde_json::from_value; #[test] diff --git a/openstack_sdk/src/api/image/v2/image/reactivate.rs b/sdk/image/src/v2/image/reactivate.rs similarity index 99% rename from openstack_sdk/src/api/image/v2/image/reactivate.rs rename to sdk/image/src/v2/image/reactivate.rs index 6f9923aba..cf24b25c8 100644 --- a/openstack_sdk/src/api/image/v2/image/reactivate.rs +++ b/sdk/image/src/v2/image/reactivate.rs @@ -149,7 +149,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/image/v2/image/stage.rs b/sdk/image/src/v2/image/stage.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image/stage.rs rename to sdk/image/src/v2/image/stage.rs diff --git a/openstack_sdk/src/api/image/v2/image/stage/stage.rs b/sdk/image/src/v2/image/stage/stage.rs similarity index 99% rename from openstack_sdk/src/api/image/v2/image/stage/stage.rs rename to sdk/image/src/v2/image/stage/stage.rs index 400c7c748..b45876793 100644 --- a/openstack_sdk/src/api/image/v2/image/stage/stage.rs +++ b/sdk/image/src/v2/image/stage/stage.rs @@ -166,7 +166,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/image/v2/image/tag.rs b/sdk/image/src/v2/image/tag.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image/tag.rs rename to sdk/image/src/v2/image/tag.rs diff --git a/sdk/image/src/v2/image/tag/delete.rs b/sdk/image/src/v2/image/tag/delete.rs new file mode 100644 index 000000000..6a7309653 --- /dev/null +++ b/sdk/image/src/v2/image/tag/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_id}/tags/{tag_value} API + #[builder(default, setter(into))] + image_id: Cow<'a, str>, + + /// tag_value parameter for /v2/images/{image_id}/tags/{tag_value} API + #[builder(default, setter(into))] + tag_value: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "images/{image_id}/tags/{tag_value}", + image_id = self.image_id.as_ref(), + tag_value = self.tag_value.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/images/{image_id}/tags/{tag_value}", + image_id = "image_id", + tag_value = "tag_value", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .tag_value("tag_value") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/images/{image_id}/tags/{tag_value}", + image_id = "image_id", + tag_value = "tag_value", + )) + .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("image_id") + .tag_value("tag_value") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/image/tag/set.rs b/sdk/image/src/v2/image/tag/set.rs new file mode 100644 index 000000000..951ee3f18 --- /dev/null +++ b/sdk/image/src/v2/image/tag/set.rs @@ -0,0 +1,227 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_id}/tags/{tag_value} API + #[builder(default, setter(into))] + image_id: Cow<'a, str>, + + /// tag_value parameter for /v2/images/{image_id}/tags/{tag_value} API + #[builder(default, setter(into))] + tag_value: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "images/{image_id}/tags/{tag_value}", + image_id = self.image_id.as_ref(), + tag_value = self.tag_value.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/images/{image_id}/tags/{tag_value}", + image_id = "image_id", + tag_value = "tag_value", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .tag_value("tag_value") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/images/{image_id}/tags/{tag_value}", + image_id = "image_id", + tag_value = "tag_value", + )) + .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("image_id") + .tag_value("tag_value") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/image/task.rs b/sdk/image/src/v2/image/task.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/image/task.rs rename to sdk/image/src/v2/image/task.rs diff --git a/sdk/image/src/v2/image/task/list.rs b/sdk/image/src/v2/image/task/list.rs new file mode 100644 index 000000000..0935a0e6c --- /dev/null +++ b/sdk/image/src/v2/image/task/list.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows tasks associated with an image. *(Since Image API v2.12)* +//! +//! The response body contains list of tasks, possibly empty, associated with +//! the specified image. +//! +//! Preconditions +//! +//! Normal response codes: 200 +//! +//! Error response codes: 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// image_id parameter for /v2/images/{image_id}/tasks API + #[builder(default, setter(into))] + image_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 Task. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("images/{image_id}/tasks", image_id = self.image_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("tasks".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tasks" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/images/{image_id}/tasks", image_id = "image_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tasks": {} })); + }); + + let endpoint = Request::builder().image_id("image_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/images/{image_id}/tasks", image_id = "image_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tasks": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/info.rs b/sdk/image/src/v2/info.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/info.rs rename to sdk/image/src/v2/info.rs diff --git a/openstack_sdk/src/api/image/v2/info/import.rs b/sdk/image/src/v2/info/import.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/info/import.rs rename to sdk/image/src/v2/info/import.rs diff --git a/sdk/image/src/v2/info/import/get.rs b/sdk/image/src/v2/info/import/get.rs new file mode 100644 index 000000000..73cfeb160 --- /dev/null +++ b/sdk/image/src/v2/info/import/get.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Returns information concerning the constraints around image import in the +//! cloud in which the call is made, for example, supported container formats, +//! supported disk formats, maximum image size, etc. This call contains a +//! `import-methods` field consisting of an array of string identifiers +//! indicating what import methods are supported in the cloud in which the call +//! is made. *(Since Image API v2.6)* +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Import. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "info/import".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("import-methods".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "import-methods" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/import".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "import-methods": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/import".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "import-methods": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/info/store.rs b/sdk/image/src/v2/info/store.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/info/store.rs rename to sdk/image/src/v2/info/store.rs diff --git a/sdk/image/src/v2/info/store/list.rs b/sdk/image/src/v2/info/store/list.rs new file mode 100644 index 000000000..556268988 --- /dev/null +++ b/sdk/image/src/v2/info/store/list.rs @@ -0,0 +1,186 @@ +// 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`. + +//! A multiple store backend support is introduced in the Rocky release as a +//! part of the EXPERIMENTAL Image API v2.8. +//! +//! In version 2.7 of the API, this call will return a 404 (Not Found). Use the +//! [API versions call](../versions/index.html#versions-call) to determine what +//! API versions are available in your cloud. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Store. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "info/stores".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("stores".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "stores" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/stores".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stores": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/stores".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stores": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/info/store/list_detailed.rs b/sdk/image/src/v2/info/store/list_detailed.rs new file mode 100644 index 000000000..94d394ea9 --- /dev/null +++ b/sdk/image/src/v2/info/store/list_detailed.rs @@ -0,0 +1,182 @@ +// 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`. + +//! Lists all the backend stores, with detail, accessible to admins, for +//! non-admin user API will return bad request. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Store. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "info/stores/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("stores".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "stores" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/stores/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stores": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/stores/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stores": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/info/usage.rs b/sdk/image/src/v2/info/usage.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/info/usage.rs rename to sdk/image/src/v2/info/usage.rs diff --git a/sdk/image/src/v2/info/usage/list.rs b/sdk/image/src/v2/info/usage/list.rs new file mode 100644 index 000000000..a2f733f54 --- /dev/null +++ b/sdk/image/src/v2/info/usage/list.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`. + +//! The user’s quota and current usage are displayed, if enabled by server-side +//! configuration. +//! +//! Normal response codes: 200 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Usage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "info/usage".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("usage".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "usage" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/usage".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "usage": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/info/usage".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "usage": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/metadef.rs b/sdk/image/src/v2/metadef.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/metadef.rs rename to sdk/image/src/v2/metadef.rs diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace.rs b/sdk/image/src/v2/metadef/namespace.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/metadef/namespace.rs rename to sdk/image/src/v2/metadef/namespace.rs diff --git a/sdk/image/src/v2/metadef/namespace/create.rs b/sdk/image/src/v2/metadef/namespace/create.rs new file mode 100644 index 000000000..2ffd9ef23 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/create.rs @@ -0,0 +1,450 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "array")] + Array, + #[serde(rename = "boolean")] + Boolean, + #[serde(rename = "integer")] + Integer, + #[serde(rename = "number")] + Number, + #[serde(rename = "object")] + Object, + #[serde(rename = "string")] + String, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Items<'a> { + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Properties<'a> { + #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) additional_items: Option, + + /// OpenAPI specifies the field as '{}'. + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _default: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) items: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_items: Option, + + #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_items: Option, + + #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) operators: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) pattern: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) readonly: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) title: Cow<'a, str>, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, + + #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) unique_items: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Objects<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_properties"))] + pub(crate) properties: Option, Properties<'a>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) required: Option>>, +} + +impl<'a> ObjectsBuilder<'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 + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ResourceTypeAssociations<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) properties_target: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Tags<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Visibility { + #[serde(rename = "private")] + Private, + #[serde(rename = "public")] + Public, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Provides a user friendly description of the namespace. + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The user friendly name for the namespace. Used by UI if available. + #[builder(default, setter(into))] + pub(crate) display_name: Option>, + + /// The unique namespace text. + #[builder(setter(into))] + pub(crate) namespace: Cow<'a, str>, + + #[builder(default, setter(into))] + pub(crate) objects: Option>>, + + /// Owner of the namespace. + #[builder(default, setter(into))] + pub(crate) owner: Option>, + + #[builder(default, private, setter(into, name = "_properties"))] + pub(crate) properties: Option, Properties<'a>>>, + + /// If true, namespace will not be deletable. + #[builder(default, setter(into))] + pub(crate) protected: Option, + + #[builder(default, setter(into))] + pub(crate) resource_type_associations: Option>>, + + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// Scope of namespace accessibility. + #[builder(default)] + pub(crate) visibility: 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 Namespace. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "metadefs/namespaces".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self.display_name { + params.push("display_name", serde_json::to_value(val)?); + } + params.push("namespace", serde_json::to_value(&self.namespace)?); + if let Some(val) = &self.objects { + params.push("objects", serde_json::to_value(val)?); + } + if let Some(val) = &self.owner { + params.push("owner", serde_json::to_value(val)?); + } + if let Some(val) = &self.properties { + params.push("properties", serde_json::to_value(val)?); + } + if let Some(val) = &self.protected { + params.push("protected", serde_json::to_value(val)?); + } + if let Some(val) = &self.resource_type_associations { + params.push("resource_type_associations", serde_json::to_value(val)?); + } + if let Some(val) = &self.tags { + params.push("tags", serde_json::to_value(val)?); + } + if let Some(val) = &self.visibility { + params.push("visibility", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .namespace("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .namespace("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/metadefs/namespaces".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().namespace("foo").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/metadefs/namespaces".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() + .namespace("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/delete.rs b/sdk/image/src/v2/metadef/namespace/delete.rs new file mode 100644 index 000000000..8aa8a097c --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/delete.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for /v2/metadefs/namespaces/{namespace_name} + /// API + #[builder(default, setter(into))] + namespace_name: 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 Namespace. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/get.rs b/sdk/image/src/v2/metadef/namespace/get.rs new file mode 100644 index 000000000..968352d2e --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/get.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for /v2/metadefs/namespaces/{namespace_name} + /// API + #[builder(default, setter(into))] + namespace_name: 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 Namespace. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/list.rs b/sdk/image/src/v2/metadef/namespace/list.rs new file mode 100644 index 000000000..960e43bc0 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/list.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Namespace. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "metadefs/namespaces".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("namespaces".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "namespaces" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metadefs/namespaces".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "namespaces": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metadefs/namespaces".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "namespaces": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/object.rs b/sdk/image/src/v2/metadef/namespace/object.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/metadef/namespace/object.rs rename to sdk/image/src/v2/metadef/namespace/object.rs diff --git a/sdk/image/src/v2/metadef/namespace/object/create.rs b/sdk/image/src/v2/metadef/namespace/object/create.rs new file mode 100644 index 000000000..34d0521bc --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/object/create.rs @@ -0,0 +1,360 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "array")] + Array, + #[serde(rename = "boolean")] + Boolean, + #[serde(rename = "integer")] + Integer, + #[serde(rename = "number")] + Number, + #[serde(rename = "object")] + Object, + #[serde(rename = "string")] + String, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Items<'a> { + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Properties<'a> { + #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) additional_items: Option, + + /// OpenAPI specifies the field as '{}'. + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _default: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) items: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_items: Option, + + #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_items: Option, + + #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) operators: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) pattern: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) readonly: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) title: Cow<'a, str>, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, + + #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) unique_items: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[builder(default, private, setter(into, name = "_properties"))] + pub(crate) properties: Option, Properties<'a>>>, + + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + namespace_name: 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> { + 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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "metadefs/namespaces/{namespace_name}/objects", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + params.push("name", serde_json::to_value(&self.name)?); + if let Some(val) = &self.properties { + params.push("properties", serde_json::to_value(val)?); + } + if let Some(val) = &self.required { + params.push("required", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/metadefs/namespaces/{namespace_name}/objects", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .name("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/metadefs/namespaces/{namespace_name}/objects", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .name("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/object/delete.rs b/sdk/image/src/v2/metadef/namespace/object/delete.rs new file mode 100644 index 000000000..eb5aae2d0 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/object/delete.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// object_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + object_name: 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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = self.namespace_name.as_ref(), + object_name = self.object_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = "namespace_name", + object_name = "object_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .object_name("object_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = "namespace_name", + object_name = "object_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .object_name("object_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/object/delete_all.rs b/sdk/image/src/v2/metadef/namespace/object/delete_all.rs new file mode 100644 index 000000000..058192f1a --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/object/delete_all.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + namespace_name: 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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/objects", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}/objects", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}/objects", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/object/get.rs b/sdk/image/src/v2/metadef/namespace/object/get.rs new file mode 100644 index 000000000..46df0fe9b --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/object/get.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// object_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + object_name: 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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = self.namespace_name.as_ref(), + object_name = self.object_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = "namespace_name", + object_name = "object_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .object_name("object_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = "namespace_name", + object_name = "object_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .object_name("object_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/object/list.rs b/sdk/image/src/v2/metadef/namespace/object/list.rs new file mode 100644 index 000000000..96abcb6ec --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/object/list.rs @@ -0,0 +1,195 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + namespace_name: 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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/objects", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("objects".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "objects" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}/objects", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "objects": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}/objects", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "objects": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/object/set.rs b/sdk/image/src/v2/metadef/namespace/object/set.rs new file mode 100644 index 000000000..98efe052a --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/object/set.rs @@ -0,0 +1,370 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "array")] + Array, + #[serde(rename = "boolean")] + Boolean, + #[serde(rename = "integer")] + Integer, + #[serde(rename = "number")] + Number, + #[serde(rename = "object")] + Object, + #[serde(rename = "string")] + String, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Items<'a> { + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Properties<'a> { + #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) additional_items: Option, + + /// OpenAPI specifies the field as '{}'. + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _default: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) items: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_items: Option, + + #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_items: Option, + + #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) operators: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) pattern: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) readonly: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) title: Cow<'a, str>, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, + + #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) unique_items: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[builder(default, private, setter(into, name = "_properties"))] + pub(crate) properties: Option, Properties<'a>>>, + + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// object_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/objects/{object_name} API + #[builder(default, setter(into))] + object_name: 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> { + 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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = self.namespace_name.as_ref(), + object_name = self.object_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + params.push("name", serde_json::to_value(&self.name)?); + if let Some(val) = &self.properties { + params.push("properties", serde_json::to_value(val)?); + } + if let Some(val) = &self.required { + params.push("required", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = "namespace_name", + object_name = "object_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .object_name("object_name") + .name("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/metadefs/namespaces/{namespace_name}/objects/{object_name}", + namespace_name = "namespace_name", + object_name = "object_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .object_name("object_name") + .name("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/property.rs b/sdk/image/src/v2/metadef/namespace/property.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/metadef/namespace/property.rs rename to sdk/image/src/v2/metadef/namespace/property.rs diff --git a/sdk/image/src/v2/metadef/namespace/property/create.rs b/sdk/image/src/v2/metadef/namespace/property/create.rs new file mode 100644 index 000000000..4b9babc4e --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/property/create.rs @@ -0,0 +1,360 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "array")] + Array, + #[serde(rename = "boolean")] + Boolean, + #[serde(rename = "integer")] + Integer, + #[serde(rename = "number")] + Number, + #[serde(rename = "object")] + Object, + #[serde(rename = "string")] + String, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Items<'a> { + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) additional_items: Option, + + /// OpenAPI specifies the field as '{}'. + #[builder(default, setter(into))] + pub(crate) _default: Option, + + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[builder(default, setter(into))] + pub(crate) items: Option>, + + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[builder(default, setter(into))] + pub(crate) max_items: Option, + + #[builder(default, setter(into))] + pub(crate) max_length: Option, + + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[builder(default, setter(into))] + pub(crate) min_items: Option, + + #[builder(default, setter(into))] + pub(crate) min_length: Option, + + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[builder(default, setter(into))] + pub(crate) operators: Option>>, + + #[builder(default, setter(into))] + pub(crate) pattern: Option>, + + #[builder(default, setter(into))] + pub(crate) readonly: Option, + + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + #[builder(setter(into))] + pub(crate) title: Cow<'a, str>, + + #[builder()] + pub(crate) _type: Type, + + #[builder(default, setter(into))] + pub(crate) unique_items: Option, + + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + namespace_name: 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 Property. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "metadefs/namespaces/{namespace_name}/properties", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.additional_items { + params.push("additionalItems", serde_json::to_value(val)?); + } + if let Some(val) = &self._default { + params.push("default", serde_json::to_value(val)?); + } + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self._enum { + params.push("enum", serde_json::to_value(val)?); + } + if let Some(val) = &self.items { + params.push("items", serde_json::to_value(val)?); + } + if let Some(val) = &self.max_items { + params.push("maxItems", serde_json::to_value(val)?); + } + if let Some(val) = &self.max_length { + params.push("maxLength", serde_json::to_value(val)?); + } + if let Some(val) = &self.maximum { + params.push("maximum", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_items { + params.push("minItems", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_length { + params.push("minLength", serde_json::to_value(val)?); + } + if let Some(val) = &self.minimum { + params.push("minimum", serde_json::to_value(val)?); + } + params.push("name", serde_json::to_value(&self.name)?); + if let Some(val) = &self.operators { + params.push("operators", serde_json::to_value(val)?); + } + if let Some(val) = &self.pattern { + params.push("pattern", serde_json::to_value(val)?); + } + if let Some(val) = &self.readonly { + params.push("readonly", serde_json::to_value(val)?); + } + if let Some(val) = &self.required { + params.push("required", serde_json::to_value(val)?); + } + params.push("title", serde_json::to_value(&self.title)?); + params.push("type", serde_json::to_value(&self._type)?); + if let Some(val) = &self.unique_items { + params.push("uniqueItems", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .title("foo") + ._type(Type::Array) + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .title("foo") + ._type(Type::Array) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/metadefs/namespaces/{namespace_name}/properties", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .name("foo") + .title("foo") + ._type(Type::Array) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/metadefs/namespaces/{namespace_name}/properties", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .name("foo") + .title("foo") + ._type(Type::Array) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/property/delete.rs b/sdk/image/src/v2/metadef/namespace/property/delete.rs new file mode 100644 index 000000000..988c4e02d --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/property/delete.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// property_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + property_name: 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 Property. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = self.namespace_name.as_ref(), + property_name = self.property_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = "namespace_name", + property_name = "property_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .property_name("property_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = "namespace_name", + property_name = "property_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .property_name("property_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/property/delete_all.rs b/sdk/image/src/v2/metadef/namespace/property/delete_all.rs new file mode 100644 index 000000000..e59fc46e0 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/property/delete_all.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + namespace_name: 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 Property. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/properties", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}/properties", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}/properties", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/property/get.rs b/sdk/image/src/v2/metadef/namespace/property/get.rs new file mode 100644 index 000000000..499b9ac00 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/property/get.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// property_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + property_name: 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 Property. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = self.namespace_name.as_ref(), + property_name = self.property_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = "namespace_name", + property_name = "property_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .property_name("property_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = "namespace_name", + property_name = "property_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .property_name("property_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/property/list.rs b/sdk/image/src/v2/metadef/namespace/property/list.rs new file mode 100644 index 000000000..299ea3508 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/property/list.rs @@ -0,0 +1,195 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + namespace_name: 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 Property. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/properties", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("properties".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "properties" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}/properties", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "properties": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}/properties", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "properties": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/property/set.rs b/sdk/image/src/v2/metadef/namespace/property/set.rs new file mode 100644 index 000000000..b0db4a878 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/property/set.rs @@ -0,0 +1,370 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "array")] + Array, + #[serde(rename = "boolean")] + Boolean, + #[serde(rename = "integer")] + Integer, + #[serde(rename = "number")] + Number, + #[serde(rename = "object")] + Object, + #[serde(rename = "string")] + String, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Items<'a> { + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + pub(crate) additional_items: Option, + + /// OpenAPI specifies the field as '{}'. + #[builder(default, setter(into))] + pub(crate) _default: Option, + + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[builder(default, setter(into))] + pub(crate) items: Option>, + + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[builder(default, setter(into))] + pub(crate) max_items: Option, + + #[builder(default, setter(into))] + pub(crate) max_length: Option, + + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[builder(default, setter(into))] + pub(crate) min_items: Option, + + #[builder(default, setter(into))] + pub(crate) min_length: Option, + + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[builder(default, setter(into))] + pub(crate) operators: Option>>, + + #[builder(default, setter(into))] + pub(crate) pattern: Option>, + + #[builder(default, setter(into))] + pub(crate) readonly: Option, + + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + #[builder(setter(into))] + pub(crate) title: Cow<'a, str>, + + #[builder()] + pub(crate) _type: Type, + + #[builder(default, setter(into))] + pub(crate) unique_items: Option, + + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// property_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/properties/{property_name} API + #[builder(default, setter(into))] + property_name: 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 Property. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = self.namespace_name.as_ref(), + property_name = self.property_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.additional_items { + params.push("additionalItems", serde_json::to_value(val)?); + } + if let Some(val) = &self._default { + params.push("default", serde_json::to_value(val)?); + } + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self._enum { + params.push("enum", serde_json::to_value(val)?); + } + if let Some(val) = &self.items { + params.push("items", serde_json::to_value(val)?); + } + if let Some(val) = &self.max_items { + params.push("maxItems", serde_json::to_value(val)?); + } + if let Some(val) = &self.max_length { + params.push("maxLength", serde_json::to_value(val)?); + } + if let Some(val) = &self.maximum { + params.push("maximum", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_items { + params.push("minItems", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_length { + params.push("minLength", serde_json::to_value(val)?); + } + if let Some(val) = &self.minimum { + params.push("minimum", serde_json::to_value(val)?); + } + params.push("name", serde_json::to_value(&self.name)?); + if let Some(val) = &self.operators { + params.push("operators", serde_json::to_value(val)?); + } + if let Some(val) = &self.pattern { + params.push("pattern", serde_json::to_value(val)?); + } + if let Some(val) = &self.readonly { + params.push("readonly", serde_json::to_value(val)?); + } + if let Some(val) = &self.required { + params.push("required", serde_json::to_value(val)?); + } + params.push("title", serde_json::to_value(&self.title)?); + params.push("type", serde_json::to_value(&self._type)?); + if let Some(val) = &self.unique_items { + params.push("uniqueItems", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .title("foo") + ._type(Type::Array) + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .title("foo") + ._type(Type::Array) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = "namespace_name", + property_name = "property_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .property_name("property_name") + .name("foo") + .title("foo") + ._type(Type::Array) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/metadefs/namespaces/{namespace_name}/properties/{property_name}", + namespace_name = "namespace_name", + property_name = "property_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .property_name("property_name") + .name("foo") + .title("foo") + ._type(Type::Array) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/resource_type.rs b/sdk/image/src/v2/metadef/namespace/resource_type.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/metadef/namespace/resource_type.rs rename to sdk/image/src/v2/metadef/namespace/resource_type.rs diff --git a/sdk/image/src/v2/metadef/namespace/resource_type/create.rs b/sdk/image/src/v2/metadef/namespace/resource_type/create.rs new file mode 100644 index 000000000..c9c8bb0aa --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/resource_type/create.rs @@ -0,0 +1,241 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Resource type names should be aligned with Heat resource types whenever + /// possible: + /// https://docs.openstack.org/heat/latest/template_guide/openstack.html + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// Specifies the prefix to use for the given resource type. Any properties + /// in the namespace should be prefixed with this prefix when being applied + /// to the specified resource type. Must include prefix separator (e.g. a + /// colon :). + #[builder(default, setter(into))] + pub(crate) prefix: Option>, + + /// Some resource types allow more than one key / value pair per instance. + /// For example, Cinder allows user and image metadata on volumes. Only the + /// image properties metadata is evaluated by Nova (scheduling or drivers). + /// This property allows a namespace target to remove the ambiguity. + #[builder(default, setter(into))] + pub(crate) properties_target: Option>, + + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} + /// API + #[builder(default, setter(into))] + namespace_name: 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 Resource_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "metadefs/namespaces/{namespace_name}/resource_types", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("name", serde_json::to_value(&self.name)?); + if let Some(val) = &self.prefix { + params.push("prefix", serde_json::to_value(val)?); + } + if let Some(val) = &self.properties_target { + params.push("properties_target", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("resource_type_associations".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .response_key() + .unwrap(), + "resource_type_associations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/metadefs/namespaces/{namespace_name}/resource_types", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_type_associations": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .name("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/metadefs/namespaces/{namespace_name}/resource_types", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_type_associations": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .name("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/resource_type/delete.rs b/sdk/image/src/v2/metadef/namespace/resource_type/delete.rs new file mode 100644 index 000000000..0ef8eacd4 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/resource_type/delete.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} + /// API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// resource_type parameter for + /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} + /// API + #[builder(default, setter(into))] + resource_type: 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 Resource_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/resource_types/{resource_type}", + namespace_name = self.namespace_name.as_ref(), + resource_type = self.resource_type.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("resource_type_associations".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "resource_type_associations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}/resource_types/{resource_type}", + namespace_name = "namespace_name", + resource_type = "resource_type", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_type_associations": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .resource_type("resource_type") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}/resource_types/{resource_type}", + namespace_name = "namespace_name", + resource_type = "resource_type", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_type_associations": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .resource_type("resource_type") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/resource_type/list.rs b/sdk/image/src/v2/metadef/namespace/resource_type/list.rs new file mode 100644 index 000000000..89049324d --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/resource_type/list.rs @@ -0,0 +1,196 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/resource_types/{resource_type} + /// API + #[builder(default, setter(into))] + namespace_name: 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 Resource_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/resource_types", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("resource_type_associations".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "resource_type_associations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}/resource_types", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_type_associations": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}/resource_types", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_type_associations": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/set.rs b/sdk/image/src/v2/metadef/namespace/set.rs new file mode 100644 index 000000000..b87ba2bb0 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/set.rs @@ -0,0 +1,469 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "array")] + Array, + #[serde(rename = "boolean")] + Boolean, + #[serde(rename = "integer")] + Integer, + #[serde(rename = "number")] + Number, + #[serde(rename = "object")] + Object, + #[serde(rename = "string")] + String, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Items<'a> { + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Properties<'a> { + #[serde(rename = "additionalItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) additional_items: Option, + + /// OpenAPI specifies the field as '{}'. + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _default: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) _enum: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) items: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[serde(rename = "maxItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_items: Option, + + #[serde(rename = "maxLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[serde(rename = "minItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_items: Option, + + #[serde(rename = "minLength", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_length: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) operators: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) pattern: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) readonly: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) required: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) title: Cow<'a, str>, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, + + #[serde(rename = "uniqueItems", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) unique_items: Option, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Objects<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_properties"))] + pub(crate) properties: Option, Properties<'a>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) required: Option>>, +} + +impl<'a> ObjectsBuilder<'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 + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ResourceTypeAssociations<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) properties_target: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Tags<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Visibility { + #[serde(rename = "private")] + Private, + #[serde(rename = "public")] + Public, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Provides a user friendly description of the namespace. + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The user friendly name for the namespace. Used by UI if available. + #[builder(default, setter(into))] + pub(crate) display_name: Option>, + + /// The unique namespace text. + #[builder(setter(into))] + pub(crate) namespace: Cow<'a, str>, + + #[builder(default, setter(into))] + pub(crate) objects: Option>>, + + /// Owner of the namespace. + #[builder(default, setter(into))] + pub(crate) owner: Option>, + + #[builder(default, private, setter(into, name = "_properties"))] + pub(crate) properties: Option, Properties<'a>>>, + + /// If true, namespace will not be deletable. + #[builder(default, setter(into))] + pub(crate) protected: Option, + + #[builder(default, setter(into))] + pub(crate) resource_type_associations: Option>>, + + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// Scope of namespace accessibility. + #[builder(default)] + pub(crate) visibility: Option, + + /// namespace_name parameter for /v2/metadefs/namespaces/{namespace_name} + /// API + #[builder(default, setter(into))] + namespace_name: 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> { + 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 Namespace. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "metadefs/namespaces/{namespace_name}", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.description { + params.push("description", serde_json::to_value(val)?); + } + if let Some(val) = &self.display_name { + params.push("display_name", serde_json::to_value(val)?); + } + params.push("namespace", serde_json::to_value(&self.namespace)?); + if let Some(val) = &self.objects { + params.push("objects", serde_json::to_value(val)?); + } + if let Some(val) = &self.owner { + params.push("owner", serde_json::to_value(val)?); + } + if let Some(val) = &self.properties { + params.push("properties", serde_json::to_value(val)?); + } + if let Some(val) = &self.protected { + params.push("protected", serde_json::to_value(val)?); + } + if let Some(val) = &self.resource_type_associations { + params.push("resource_type_associations", serde_json::to_value(val)?); + } + if let Some(val) = &self.tags { + params.push("tags", serde_json::to_value(val)?); + } + if let Some(val) = &self.visibility { + params.push("visibility", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .namespace("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .namespace("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/metadefs/namespaces/{namespace_name}", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .namespace("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/metadefs/namespaces/{namespace_name}", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .namespace("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/metadef/namespace/tag.rs b/sdk/image/src/v2/metadef/namespace/tag.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/metadef/namespace/tag.rs rename to sdk/image/src/v2/metadef/namespace/tag.rs diff --git a/sdk/image/src/v2/metadef/namespace/tag/create.rs b/sdk/image/src/v2/metadef/namespace/tag/create.rs new file mode 100644 index 000000000..e10ff302c --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/tag/create.rs @@ -0,0 +1,226 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// tag_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + tag_name: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = self.namespace_name.as_ref(), + tag_name = self.tag_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("name", serde_json::to_value(&self.name)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .name("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .name("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/tag/delete.rs b/sdk/image/src/v2/metadef/namespace/tag/delete.rs new file mode 100644 index 000000000..413d4b098 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/tag/delete.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// tag_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + tag_name: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = self.namespace_name.as_ref(), + tag_name = self.tag_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/tag/delete_all.rs b/sdk/image/src/v2/metadef/namespace/tag/delete_all.rs new file mode 100644 index 000000000..8b20f1299 --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/tag/delete_all.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + namespace_name: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/tags", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/metadefs/namespaces/{namespace_name}/tags", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/metadefs/namespaces/{namespace_name}/tags", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/tag/get.rs b/sdk/image/src/v2/metadef/namespace/tag/get.rs new file mode 100644 index 000000000..f02c3895d --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/tag/get.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// tag_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + tag_name: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = self.namespace_name.as_ref(), + tag_name = self.tag_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/tag/list.rs b/sdk/image/src/v2/metadef/namespace/tag/list.rs new file mode 100644 index 000000000..3a768e09b --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/tag/list.rs @@ -0,0 +1,195 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + namespace_name: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "metadefs/namespaces/{namespace_name}/tags", + namespace_name = self.namespace_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/metadefs/namespaces/{namespace_name}/tags", + namespace_name = "namespace_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/metadefs/namespaces/{namespace_name}/tags", + namespace_name = "namespace_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/metadef/namespace/tag/set.rs b/sdk/image/src/v2/metadef/namespace/tag/set.rs new file mode 100644 index 000000000..c1a15f56f --- /dev/null +++ b/sdk/image/src/v2/metadef/namespace/tag/set.rs @@ -0,0 +1,226 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// namespace_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + namespace_name: Cow<'a, str>, + + /// tag_name parameter for + /// /v2/metadefs/namespaces/{namespace_name}/tags/{tag_name} API + #[builder(default, setter(into))] + tag_name: 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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = self.namespace_name.as_ref(), + tag_name = self.tag_name.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("name", serde_json::to_value(&self.name)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .name("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/metadefs/namespaces/{namespace_name}/tags/{tag_name}", + namespace_name = "namespace_name", + tag_name = "tag_name", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .namespace_name("namespace_name") + .tag_name("tag_name") + .name("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/metadef/resource_type.rs b/sdk/image/src/v2/metadef/resource_type.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/metadef/resource_type.rs rename to sdk/image/src/v2/metadef/resource_type.rs diff --git a/sdk/image/src/v2/metadef/resource_type/get.rs b/sdk/image/src/v2/metadef/resource_type/get.rs new file mode 100644 index 000000000..9f95671f1 --- /dev/null +++ b/sdk/image/src/v2/metadef/resource_type/get.rs @@ -0,0 +1,165 @@ +// 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`. + +//! Lists all available resource types. +//! +//! Using the other API calls in this section, you can create and maintain +//! *resource type associations* between metadata definition namespaces and the +//! resource types that are returned by this call. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +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 Resource_Type. + 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> { + "v2/metadefs/resource_types".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + use crate::api::Query; + use openstack_sdk_core::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::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/v2/metadefs/resource_types".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(); + } + + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/v2/metadefs/resource_types".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/sdk/image/src/v2/metadef/resource_type/list.rs b/sdk/image/src/v2/metadef/resource_type/list.rs new file mode 100644 index 000000000..503910af0 --- /dev/null +++ b/sdk/image/src/v2/metadef/resource_type/list.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Resource_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "metadefs/resource_types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("resource_types".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "resource_types" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metadefs/resource_types".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_types": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metadefs/resource_types".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_types": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema.rs b/sdk/image/src/v2/schema.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema.rs rename to sdk/image/src/v2/schema.rs diff --git a/openstack_sdk/src/api/image/v2/schema/image.rs b/sdk/image/src/v2/schema/image.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/image.rs rename to sdk/image/src/v2/schema/image.rs diff --git a/sdk/image/src/v2/schema/image/get.rs b/sdk/image/src/v2/schema/image/get.rs new file mode 100644 index 000000000..69026ed56 --- /dev/null +++ b/sdk/image/src/v2/schema/image/get.rs @@ -0,0 +1,183 @@ +// 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`. + +//! *(Since Images v2.0)* +//! +//! Shows a JSON schema document that represents an *image* entity. +//! +//! The following schema is solely an example. Consider only the response to +//! the API call as authoritative. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Image. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/image".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/image".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/image".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/images.rs b/sdk/image/src/v2/schema/images.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/images.rs rename to sdk/image/src/v2/schema/images.rs diff --git a/sdk/image/src/v2/schema/images/get.rs b/sdk/image/src/v2/schema/images/get.rs new file mode 100644 index 000000000..1f4a3a415 --- /dev/null +++ b/sdk/image/src/v2/schema/images/get.rs @@ -0,0 +1,185 @@ +// 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`. + +//! *(Since Images v2.0)* +//! +//! Shows a JSON schema document that represents an *images* entity. +//! +//! An images entity is a container of image entities. +//! +//! The following schema is solely an example. Consider only the response to +//! the API call as authoritative. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Images. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/images".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/images".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/images".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/member.rs b/sdk/image/src/v2/schema/member.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/member.rs rename to sdk/image/src/v2/schema/member.rs diff --git a/sdk/image/src/v2/schema/member/get.rs b/sdk/image/src/v2/schema/member/get.rs new file mode 100644 index 000000000..6c45daa28 --- /dev/null +++ b/sdk/image/src/v2/schema/member/get.rs @@ -0,0 +1,183 @@ +// 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`. + +//! *(Since Images v2.1)* +//! +//! Shows a JSON schema document that represents an *image member* entity. +//! +//! The following schema is solely an example. Consider only the response to +//! the API call as authoritative. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/member".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/member".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/member".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/members.rs b/sdk/image/src/v2/schema/members.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/members.rs rename to sdk/image/src/v2/schema/members.rs diff --git a/sdk/image/src/v2/schema/members/get.rs b/sdk/image/src/v2/schema/members/get.rs new file mode 100644 index 000000000..36c6956be --- /dev/null +++ b/sdk/image/src/v2/schema/members/get.rs @@ -0,0 +1,185 @@ +// 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`. + +//! *(Since Images v2.1)* +//! +//! Shows a JSON schema document that represents an *image members* entity. +//! +//! An image members entity is a container of image member entities. +//! +//! The following schema is solely an example. Consider only the response to +//! the API call as authoritative. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Members. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/members".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/members".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/members".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef.rs b/sdk/image/src/v2/schema/metadef.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef.rs rename to sdk/image/src/v2/schema/metadef.rs diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/namespace.rs b/sdk/image/src/v2/schema/metadef/namespace.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/namespace.rs rename to sdk/image/src/v2/schema/metadef/namespace.rs diff --git a/sdk/image/src/v2/schema/metadef/namespace/get.rs b/sdk/image/src/v2/schema/metadef/namespace/get.rs new file mode 100644 index 000000000..06a16151f --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/namespace/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Namespace. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/namespace".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/namespace".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/namespace".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/namespaces.rs b/sdk/image/src/v2/schema/metadef/namespaces.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/namespaces.rs rename to sdk/image/src/v2/schema/metadef/namespaces.rs diff --git a/sdk/image/src/v2/schema/metadef/namespaces/get.rs b/sdk/image/src/v2/schema/metadef/namespaces/get.rs new file mode 100644 index 000000000..2dfa3fe82 --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/namespaces/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Namespaces. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/namespaces".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/namespaces".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/namespaces".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/object.rs b/sdk/image/src/v2/schema/metadef/object.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/object.rs rename to sdk/image/src/v2/schema/metadef/object.rs diff --git a/sdk/image/src/v2/schema/metadef/object/get.rs b/sdk/image/src/v2/schema/metadef/object/get.rs new file mode 100644 index 000000000..64fa6f025 --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/object/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/object".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/object".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/object".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/objects.rs b/sdk/image/src/v2/schema/metadef/objects.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/objects.rs rename to sdk/image/src/v2/schema/metadef/objects.rs diff --git a/sdk/image/src/v2/schema/metadef/objects/get.rs b/sdk/image/src/v2/schema/metadef/objects/get.rs new file mode 100644 index 000000000..f51ea9b43 --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/objects/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Objects. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/objects".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/objects".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/objects".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/properties.rs b/sdk/image/src/v2/schema/metadef/properties.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/properties.rs rename to sdk/image/src/v2/schema/metadef/properties.rs diff --git a/sdk/image/src/v2/schema/metadef/properties/get.rs b/sdk/image/src/v2/schema/metadef/properties/get.rs new file mode 100644 index 000000000..fba3347fb --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/properties/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Properties. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/properties".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/properties".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/properties".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/property.rs b/sdk/image/src/v2/schema/metadef/property.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/property.rs rename to sdk/image/src/v2/schema/metadef/property.rs diff --git a/sdk/image/src/v2/schema/metadef/property/get.rs b/sdk/image/src/v2/schema/metadef/property/get.rs new file mode 100644 index 000000000..80ef8dd85 --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/property/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Property. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/property".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/property".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/property".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/resource_type.rs b/sdk/image/src/v2/schema/metadef/resource_type.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/resource_type.rs rename to sdk/image/src/v2/schema/metadef/resource_type.rs diff --git a/sdk/image/src/v2/schema/metadef/resource_type/get.rs b/sdk/image/src/v2/schema/metadef/resource_type/get.rs new file mode 100644 index 000000000..7a57e8057 --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/resource_type/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Resource_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/resource_type".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/resource_type".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/resource_type".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/resource_types.rs b/sdk/image/src/v2/schema/metadef/resource_types.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/resource_types.rs rename to sdk/image/src/v2/schema/metadef/resource_types.rs diff --git a/sdk/image/src/v2/schema/metadef/resource_types/get.rs b/sdk/image/src/v2/schema/metadef/resource_types/get.rs new file mode 100644 index 000000000..0bb7a44a2 --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/resource_types/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Resource_Types. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/resource_types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/resource_types".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/resource_types".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/tag.rs b/sdk/image/src/v2/schema/metadef/tag.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/tag.rs rename to sdk/image/src/v2/schema/metadef/tag.rs diff --git a/sdk/image/src/v2/schema/metadef/tag/get.rs b/sdk/image/src/v2/schema/metadef/tag/get.rs new file mode 100644 index 000000000..942b25590 --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/tag/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/tag".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/tag".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/tag".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/metadef/tags.rs b/sdk/image/src/v2/schema/metadef/tags.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/metadef/tags.rs rename to sdk/image/src/v2/schema/metadef/tags.rs diff --git a/sdk/image/src/v2/schema/metadef/tags/get.rs b/sdk/image/src/v2/schema/metadef/tags/get.rs new file mode 100644 index 000000000..b4a7889da --- /dev/null +++ b/sdk/image/src/v2/schema/metadef/tags/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Tags. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/metadefs/tags".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/tags".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/metadefs/tags".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/task.rs b/sdk/image/src/v2/schema/task.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/task.rs rename to sdk/image/src/v2/schema/task.rs diff --git a/sdk/image/src/v2/schema/task/get.rs b/sdk/image/src/v2/schema/task/get.rs new file mode 100644 index 000000000..c298d751a --- /dev/null +++ b/sdk/image/src/v2/schema/task/get.rs @@ -0,0 +1,183 @@ +// 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`. + +//! *(Since Images v2.2)* +//! +//! Shows a JSON schema document that represents an *task* entity. +//! +//! The following schema is solely an example. Consider only the response to +//! the API call as authoritative. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Task. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/task".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/task".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/task".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/schema/tasks.rs b/sdk/image/src/v2/schema/tasks.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/schema/tasks.rs rename to sdk/image/src/v2/schema/tasks.rs diff --git a/sdk/image/src/v2/schema/tasks/get.rs b/sdk/image/src/v2/schema/tasks/get.rs new file mode 100644 index 000000000..82c8ca431 --- /dev/null +++ b/sdk/image/src/v2/schema/tasks/get.rs @@ -0,0 +1,186 @@ +// 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`. + +//! *(Since Images v2.2)* +//! +//! Shows a JSON schema document that represents a list of *tasks*. +//! +//! An tasks list entity is a container of entities containing abbreviated +//! information about individual tasks. +//! +//! The following schema is solely an example. Consider only the response to +//! the API call as authoritative. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Tasks. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "schemas/tasks".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/tasks".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/schemas/tasks".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/store.rs b/sdk/image/src/v2/store.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/store.rs rename to sdk/image/src/v2/store.rs diff --git a/sdk/image/src/v2/store/delete.rs b/sdk/image/src/v2/store/delete.rs new file mode 100644 index 000000000..444727838 --- /dev/null +++ b/sdk/image/src/v2/store/delete.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`. + +//! This API allows you to delete a copy of the image from a specific store. +//! *(Since Image API v2.10)* +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// store_id parameter for /v2/stores/{store_id}/{image_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// image_id parameter for /v2/stores/{store_id}/{image_id} API + #[builder(default, setter(into))] + image_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 Store. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "stores/{id}/{image_id}", + image_id = self.image_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/stores/{id}/{image_id}", + image_id = "image_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .image_id("image_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/stores/{id}/{image_id}", + image_id = "image_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() + .image_id("image_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/image/v2/task.rs b/sdk/image/src/v2/task.rs similarity index 100% rename from openstack_sdk/src/api/image/v2/task.rs rename to sdk/image/src/v2/task.rs diff --git a/sdk/image/src/v2/task/create.rs b/sdk/image/src/v2/task/create.rs new file mode 100644 index 000000000..b88e59636 --- /dev/null +++ b/sdk/image/src/v2/task/create.rs @@ -0,0 +1,337 @@ +// 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`. + +//! Creates a task. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 401, 413, 415 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Status { + #[serde(rename = "failure")] + Failure, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "processing")] + Processing, + #[serde(rename = "success")] + Success, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "api_image_import")] + ApiImageImport, + #[serde(rename = "import")] + Import, + #[serde(rename = "location_import")] + LocationImport, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Datetime when this resource was created + #[builder(default, setter(into))] + pub(crate) created_at: Option>, + + /// Datetime when this resource would be subject to removal + #[builder(default, setter(into))] + pub(crate) expires_at: Option>>, + + /// An identifier for the task + #[builder(default, setter(into))] + pub(crate) id: Option>, + + /// Image associated with the task + #[builder(default, setter(into))] + pub(crate) image_id: Option>, + + /// A JSON object specifying the input parameters to the task. Consult your + /// cloud provider’s documentation for details. + #[builder(default, private, setter(into, name = "_input"))] + pub(crate) input: Option, Value>>>, + + /// Human-readable informative message only included when appropriate + /// (usually on failure) + #[builder(default, setter(into))] + pub(crate) message: Option>, + + /// An identifier for the owner of this task + #[builder(default, setter(into))] + pub(crate) owner: Option>, + + /// Human-readable informative request-id + #[builder(default, setter(into))] + pub(crate) request_id: Option>, + + /// The result of current task, JSON blob + #[builder(default, private, setter(into, name = "_result"))] + pub(crate) result: Option, Value>>>, + + /// The current status of this task + #[builder(default)] + pub(crate) status: Option, + + /// The type of task represented by this content. + #[builder(default)] + pub(crate) _type: Option, + + /// Datetime when this resource was updated + #[builder(default, setter(into))] + pub(crate) updated_at: Option>, + + /// User associated with the task + #[builder(default, setter(into))] + pub(crate) user_id: 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> { + /// A JSON object specifying the input parameters to the task. Consult your + /// cloud provider’s documentation for details. + pub fn input(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.input + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// The result of current task, JSON blob + pub fn result(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.result + .get_or_insert(None) + .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 Task. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "tasks".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.created_at { + params.push("created_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.expires_at { + params.push("expires_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.id { + params.push("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.input { + params.push("input", serde_json::to_value(val)?); + } + if let Some(val) = &self.message { + params.push("message", serde_json::to_value(val)?); + } + if let Some(val) = &self.owner { + params.push("owner", serde_json::to_value(val)?); + } + if let Some(val) = &self.request_id { + params.push("request_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.result { + params.push("result", serde_json::to_value(val)?); + } + if let Some(val) = &self.status { + params.push("status", serde_json::to_value(val)?); + } + if let Some(val) = &self._type { + params.push("type", serde_json::to_value(val)?); + } + if let Some(val) = &self.updated_at { + params.push("updated_at", serde_json::to_value(val)?); + } + if let Some(val) = &self.user_id { + params.push("user_id", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/tasks".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/tasks".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/task/delete.rs b/sdk/image/src/v2/task/delete.rs new file mode 100644 index 000000000..13e61eee3 --- /dev/null +++ b/sdk/image/src/v2/task/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// task_id parameter for /v2/tasks/{task_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<'a> RequestBuilder<'a> { + /// Add a single header to the Task. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("tasks/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/tasks/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/tasks/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/task/get.rs b/sdk/image/src/v2/task/get.rs new file mode 100644 index 000000000..42a94450f --- /dev/null +++ b/sdk/image/src/v2/task/get.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Shows details for a task. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// task_id parameter for /v2/tasks/{task_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<'a> RequestBuilder<'a> { + /// Add a single header to the Task. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("tasks/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/tasks/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/tasks/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/image/src/v2/task/list.rs b/sdk/image/src/v2/task/list.rs new file mode 100644 index 000000000..ed3997bc5 --- /dev/null +++ b/sdk/image/src/v2/task/list.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Lists tasks. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 403, 404, 413 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Task. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "tasks".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Image + } + + fn response_key(&self) -> Option> { + Some("tasks".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Image + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tasks" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/tasks".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tasks": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/tasks".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tasks": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/Cargo.toml b/sdk/load-balancer/Cargo.toml new file mode 100644 index 000000000..7f7565b45 --- /dev/null +++ b/sdk/load-balancer/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "openstack-sdk-load-balancer" +description = "OpenStack SDK Load Balancer service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/load-balancer/src/lib.rs b/sdk/load-balancer/src/lib.rs new file mode 100644 index 000000000..c79d34161 --- /dev/null +++ b/sdk/load-balancer/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Load_balancer` Service bindings +pub mod v2; diff --git a/openstack_sdk/src/api/load_balancer/v2.rs b/sdk/load-balancer/src/v2.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2.rs rename to sdk/load-balancer/src/v2.rs diff --git a/openstack_sdk/src/api/load_balancer/v2/amphorae.rs b/sdk/load-balancer/src/v2/amphorae.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/amphorae.rs rename to sdk/load-balancer/src/v2/amphorae.rs diff --git a/openstack_sdk/src/api/load_balancer/v2/amphorae/config.rs b/sdk/load-balancer/src/v2/amphorae/config.rs similarity index 98% rename from openstack_sdk/src/api/load_balancer/v2/amphorae/config.rs rename to sdk/load-balancer/src/v2/amphorae/config.rs index 989b46d6b..6d0c2d441 100644 --- a/openstack_sdk/src/api/load_balancer/v2/amphorae/config.rs +++ b/sdk/load-balancer/src/v2/amphorae/config.rs @@ -124,7 +124,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/load-balancer/src/v2/amphorae/delete.rs b/sdk/load-balancer/src/v2/amphorae/delete.rs new file mode 100644 index 000000000..079e426ed --- /dev/null +++ b/sdk/load-balancer/src/v2/amphorae/delete.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Removes an amphora and its associated configuration. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +//! **New in version 2.20** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id} API + #[builder(default, setter(into))] + amphora_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 Amphorae. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "octavia/amphorae/{amphora_id}", + amphora_id = self.amphora_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/octavia/amphorae/{amphora_id}", + amphora_id = "amphora_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/octavia/amphorae/{amphora_id}", + amphora_id = "amphora_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() + .amphora_id("amphora_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/amphorae/failover.rs b/sdk/load-balancer/src/v2/amphorae/failover.rs new file mode 100644 index 000000000..a5e821346 --- /dev/null +++ b/sdk/load-balancer/src/v2/amphorae/failover.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Force an amphora to failover. +//! +//! If you are not an administrative user, the service returns the HTTP +//! `Forbidden (403)` response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id}/failover API + #[builder(default, setter(into))] + amphora_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 Amphorae. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "octavia/amphorae/{amphora_id}/failover", + amphora_id = self.amphora_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/octavia/amphorae/{amphora_id}/failover", + amphora_id = "amphora_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/octavia/amphorae/{amphora_id}/failover", + amphora_id = "amphora_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() + .amphora_id("amphora_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/amphorae/get.rs b/sdk/load-balancer/src/v2/amphorae/get.rs new file mode 100644 index 000000000..dc6ac8bea --- /dev/null +++ b/sdk/load-balancer/src/v2/amphorae/get.rs @@ -0,0 +1,198 @@ +// 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`. + +//! Shows the details of an amphora. +//! +//! If you are not an administrative user, the service returns the HTTP +//! `Forbidden (403)` response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id} API + #[builder(default, setter(into))] + amphora_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 Amphorae. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "octavia/amphorae/{amphora_id}", + amphora_id = self.amphora_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("amphora".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "amphora" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/octavia/amphorae/{amphora_id}", + amphora_id = "amphora_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "amphora": {} })); + }); + + let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/octavia/amphorae/{amphora_id}", + amphora_id = "amphora_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "amphora": {} })); + }); + + let endpoint = Request::builder() + .amphora_id("amphora_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/amphorae/list.rs b/sdk/load-balancer/src/v2/amphorae/list.rs new file mode 100644 index 000000000..ceec2d353 --- /dev/null +++ b/sdk/load-balancer/src/v2/amphorae/list.rs @@ -0,0 +1,288 @@ +// 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`. + +//! Lists all amphora for the project. +//! +//! If you are not an administrative user, the service returns the HTTP +//! `Forbidden (403)` response code. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + cached_zone: Option>, + + #[builder(default, setter(into))] + cert_busy: Option>, + + #[builder(default, setter(into))] + cert_expiration: Option>, + + #[builder(default, setter(into))] + compute_flavor: Option>, + + #[builder(default, setter(into))] + compute_id: Option>, + + #[builder(default, setter(into))] + created_at: Option>, + + #[builder(default, setter(into))] + ha_ip: Option>, + + #[builder(default, setter(into))] + ha_port_id: Option>, + + #[builder(default, setter(into))] + id: Option>, + + #[builder(default, setter(into))] + image_id: Option>, + + #[builder(default, setter(into))] + lb_network_ip: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + loadbalancer_id: Option>, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + #[builder(default, setter(into))] + role: Option>, + + #[builder(default, setter(into))] + status: Option>, + + #[builder(default, setter(into))] + updated_at: Option>, + + #[builder(default, setter(into))] + vrrp_id: Option>, + + #[builder(default, setter(into))] + vrrp_interface: Option>, + + #[builder(default, setter(into))] + vrrp_ip: Option>, + + #[builder(default, setter(into))] + vrrp_port_id: Option>, + + #[builder(default, setter(into))] + vrrp_priority: 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> { + /// Add a single header to the Amphorae. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "octavia/amphorae".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("cached_zone", self.cached_zone.as_ref()); + params.push_opt("cert_busy", self.cert_busy.as_ref()); + params.push_opt("cert_expiration", self.cert_expiration.as_ref()); + params.push_opt("compute_flavor", self.compute_flavor.as_ref()); + params.push_opt("compute_id", self.compute_id.as_ref()); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("ha_ip", self.ha_ip.as_ref()); + params.push_opt("ha_port_id", self.ha_port_id.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("image_id", self.image_id.as_ref()); + params.push_opt("lb_network_ip", self.lb_network_ip.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("loadbalancer_id", self.loadbalancer_id.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("role", self.role.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + params.push_opt("vrrp_id", self.vrrp_id.as_ref()); + params.push_opt("vrrp_interface", self.vrrp_interface.as_ref()); + params.push_opt("vrrp_ip", self.vrrp_ip.as_ref()); + params.push_opt("vrrp_port_id", self.vrrp_port_id.as_ref()); + params.push_opt("vrrp_priority", self.vrrp_priority.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("amphorae".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "amphorae" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/octavia/amphorae".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "amphorae": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/octavia/amphorae".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "amphorae": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/amphorae/stats.rs b/sdk/load-balancer/src/v2/amphorae/stats.rs new file mode 100644 index 000000000..b34a5072c --- /dev/null +++ b/sdk/load-balancer/src/v2/amphorae/stats.rs @@ -0,0 +1,198 @@ +// 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 statistics for an amphora. +//! +//! If you are not an administrative user, the service returns the HTTP +//! `Forbidden (403)` response code. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. +//! +//! **New in version 2.3** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// amphora_id parameter for /v2/octavia/amphorae/{amphora_id}/stats API + #[builder(default, setter(into))] + amphora_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 Amphorae. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "octavia/amphorae/{amphora_id}/stats", + amphora_id = self.amphora_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/octavia/amphorae/{amphora_id}/stats", + amphora_id = "amphora_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().amphora_id("amphora_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/octavia/amphorae/{amphora_id}/stats", + amphora_id = "amphora_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() + .amphora_id("amphora_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone.rs b/sdk/load-balancer/src/v2/availability_zone.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/availability_zone.rs rename to sdk/load-balancer/src/v2/availability_zone.rs diff --git a/sdk/load-balancer/src/v2/availability_zone/create.rs b/sdk/load-balancer/src/v2/availability_zone/create.rs new file mode 100644 index 000000000..636d23188 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone/create.rs @@ -0,0 +1,254 @@ +// 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`. + +//! Creates an Availability Zone. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AvailabilityZone<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) availability_zone_profile_id: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) availability_zone: AvailabilityZone<'a>, + + #[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 Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/availabilityzones".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "availability_zone", + serde_json::to_value(&self.availability_zone)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .availability_zone( + AvailabilityZoneBuilder::default() + .availability_zone_profile_id("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .availability_zone( + AvailabilityZoneBuilder::default() + .availability_zone_profile_id("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "availability_zone" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/availabilityzones".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone": {} })); + }); + + let endpoint = Request::builder() + .availability_zone( + AvailabilityZoneBuilder::default() + .availability_zone_profile_id("foo") + .name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/availabilityzones".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone": {} })); + }); + + let endpoint = Request::builder() + .availability_zone( + AvailabilityZoneBuilder::default() + .availability_zone_profile_id("foo") + .name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone/delete.rs b/sdk/load-balancer/src/v2/availability_zone/delete.rs new file mode 100644 index 000000000..3c7f63d0a --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone/delete.rs @@ -0,0 +1,182 @@ +// 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`. + +//! Deletes an Availability Zone +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// availabilityzone_id parameter for + /// /v2/lbaas/availabilityzones/{availabilityzone_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<'a> RequestBuilder<'a> { + /// Add a single header to the Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/availabilityzones/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/availabilityzones/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/availabilityzones/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone/get.rs b/sdk/load-balancer/src/v2/availability_zone/get.rs new file mode 100644 index 000000000..ec65e1ba0 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone/get.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Gets an Availability Zone's detail. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// availabilityzone_id parameter for + /// /v2/lbaas/availabilityzones/{availabilityzone_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<'a> RequestBuilder<'a> { + /// Add a single header to the Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/availabilityzones/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availability_zone" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/availabilityzones/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/availabilityzones/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone/list.rs b/sdk/load-balancer/src/v2/availability_zone/list.rs new file mode 100644 index 000000000..70d72e724 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone/list.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Lists all Availability Zones. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + availability_zone_profile_id: Option>, + + #[builder(default, setter(into))] + description: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + name: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + #[builder(default, setter(into))] + status: 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> { + /// Add a single header to the Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/availabilityzones".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt( + "availability_zone_profile_id", + self.availability_zone_profile_id.as_ref(), + ); + params.push_opt("description", self.description.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("status", self.status.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zones".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availability_zones" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/availabilityzones".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zones": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/availabilityzones".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zones": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone/set.rs b/sdk/load-balancer/src/v2/availability_zone/set.rs new file mode 100644 index 000000000..c3d5939bf --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone/set.rs @@ -0,0 +1,227 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines the attributes of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AvailabilityZone<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines the attributes of a PUT request. + #[builder(setter(into))] + pub(crate) availability_zone: AvailabilityZone<'a>, + + /// availabilityzone_id parameter for + /// /v2/lbaas/availabilityzones/{availabilityzone_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<'a> RequestBuilder<'a> { + /// Add a single header to the Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/availabilityzones/{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( + "availability_zone", + serde_json::to_value(&self.availability_zone)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "availability_zone" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/availabilityzones/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/availabilityzones/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .availability_zone(AvailabilityZoneBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/availability_zone_profile.rs b/sdk/load-balancer/src/v2/availability_zone_profile.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/availability_zone_profile.rs rename to sdk/load-balancer/src/v2/availability_zone_profile.rs diff --git a/sdk/load-balancer/src/v2/availability_zone_profile/create.rs b/sdk/load-balancer/src/v2/availability_zone_profile/create.rs new file mode 100644 index 000000000..bf0bfc464 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone_profile/create.rs @@ -0,0 +1,254 @@ +// 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`. + +//! Creates an Availability Zone Profile. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AvailabilityZoneProfile<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) availability_zone_data: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) provider_name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) availability_zone_profile: AvailabilityZoneProfile<'a>, + + #[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 Availability_Zone_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/availabilityzoneprofiles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "availability_zone_profile", + serde_json::to_value(&self.availability_zone_profile)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .availability_zone_profile( + AvailabilityZoneProfileBuilder::default() + .availability_zone_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .availability_zone_profile( + AvailabilityZoneProfileBuilder::default() + .availability_zone_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "availability_zone_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/availabilityzoneprofiles".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profile": {} })); + }); + + let endpoint = Request::builder() + .availability_zone_profile( + AvailabilityZoneProfileBuilder::default() + .availability_zone_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/availabilityzoneprofiles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profile": {} })); + }); + + let endpoint = Request::builder() + .availability_zone_profile( + AvailabilityZoneProfileBuilder::default() + .availability_zone_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone_profile/delete.rs b/sdk/load-balancer/src/v2/availability_zone_profile/delete.rs new file mode 100644 index 000000000..8e18bef11 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone_profile/delete.rs @@ -0,0 +1,182 @@ +// 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`. + +//! Deletes an Availability Zone Profile +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// availabilityzoneprofile_id parameter for + /// /v2/lbaas/availabilityzoneprofiles/{availabilityzoneprofile_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<'a> RequestBuilder<'a> { + /// Add a single header to the Availability_Zone_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/availabilityzoneprofiles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/availabilityzoneprofiles/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/availabilityzoneprofiles/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone_profile/find.rs b/sdk/load-balancer/src/v2/availability_zone_profile/find.rs new file mode 100644 index 000000000..46e9e4e55 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone_profile/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::availability_zone_profile::{get as Get, list as List}; + +/// Find for availability_zone_profile 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone_profile/get.rs b/sdk/load-balancer/src/v2/availability_zone_profile/get.rs new file mode 100644 index 000000000..b52da2709 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone_profile/get.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Gets an Availability Zone Profile's detail. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// availabilityzoneprofile_id parameter for + /// /v2/lbaas/availabilityzoneprofiles/{availabilityzoneprofile_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<'a> RequestBuilder<'a> { + /// Add a single header to the Availability_Zone_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/availabilityzoneprofiles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availability_zone_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profile": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone_profile/list.rs b/sdk/load-balancer/src/v2/availability_zone_profile/list.rs new file mode 100644 index 000000000..a8c96f353 --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone_profile/list.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Lists all Availability Zone Profiles. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + availability_zone_data: Option>, + + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + name: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + #[builder(default, setter(into))] + provider_name: 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> { + /// Add a single header to the Availability_Zone_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/availabilityzoneprofiles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt( + "availability_zone_data", + self.availability_zone_data.as_ref(), + ); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("provider_name", self.provider_name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone_profiles".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availability_zone_profiles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/availabilityzoneprofiles".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profiles": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/availabilityzoneprofiles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profiles": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/availability_zone_profile/set.rs b/sdk/load-balancer/src/v2/availability_zone_profile/set.rs new file mode 100644 index 000000000..e5e7708df --- /dev/null +++ b/sdk/load-balancer/src/v2/availability_zone_profile/set.rs @@ -0,0 +1,237 @@ +// 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`. + +//! Updates an Availability Zone Profile. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines the attributes of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AvailabilityZoneProfile<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone_data: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) provider_name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines the attributes of a PUT request. + #[builder(setter(into))] + pub(crate) availability_zone_profile: AvailabilityZoneProfile<'a>, + + /// availabilityzoneprofile_id parameter for + /// /v2/lbaas/availabilityzoneprofiles/{availabilityzoneprofile_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<'a> RequestBuilder<'a> { + /// Add a single header to the Availability_Zone_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/availabilityzoneprofiles/{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( + "availability_zone_profile", + serde_json::to_value(&self.availability_zone_profile)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .availability_zone_profile( + AvailabilityZoneProfileBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .availability_zone_profile( + AvailabilityZoneProfileBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "availability_zone_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .availability_zone_profile(AvailabilityZoneProfileBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/availabilityzoneprofiles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_profile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .availability_zone_profile(AvailabilityZoneProfileBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor.rs b/sdk/load-balancer/src/v2/flavor.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/flavor.rs rename to sdk/load-balancer/src/v2/flavor.rs diff --git a/sdk/load-balancer/src/v2/flavor/create.rs b/sdk/load-balancer/src/v2/flavor/create.rs new file mode 100644 index 000000000..ef4c0550d --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor/create.rs @@ -0,0 +1,251 @@ +// 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`. + +//! Creates a flavor. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) flavor_profile_id: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) flavor: Flavor<'a>, + + #[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 Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/flavors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("flavor", serde_json::to_value(&self.flavor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavor( + FlavorBuilder::default() + .flavor_profile_id("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavor( + FlavorBuilder::default() + .flavor_profile_id("foo") + .name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/flavors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor( + FlavorBuilder::default() + .flavor_profile_id("foo") + .name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/flavors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor( + FlavorBuilder::default() + .flavor_profile_id("foo") + .name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor/delete.rs b/sdk/load-balancer/src/v2/flavor/delete.rs new file mode 100644 index 000000000..bcb9bbe9f --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor/delete.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Deletes a Flavor +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2/lbaas/flavors/{flavor_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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/flavors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/flavors/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/flavors/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor/find.rs b/sdk/load-balancer/src/v2/flavor/find.rs new file mode 100644 index 000000000..b2a897d22 --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::flavor::{get as Get, list as List}; + +/// Find for flavor 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/flavor/get.rs b/sdk/load-balancer/src/v2/flavor/get.rs new file mode 100644 index 000000000..e74078a8f --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor/get.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Gets a flavor's detail. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2/lbaas/flavors/{flavor_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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/flavors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/flavors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/flavors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor/list.rs b/sdk/load-balancer/src/v2/flavor/list.rs new file mode 100644 index 000000000..28fbe4a37 --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor/list.rs @@ -0,0 +1,218 @@ +// 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`. + +//! Lists all flavors. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + description: Option>, + + #[builder(default)] + enabled: Option, + + #[builder(default, setter(into))] + flavor_profile_id: Option>, + + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + name: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: 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> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/flavors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("description", self.description.as_ref()); + params.push_opt("enabled", self.enabled); + params.push_opt("flavor_profile_id", self.flavor_profile_id.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavors".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavors" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/flavors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/flavors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor/set.rs b/sdk/load-balancer/src/v2/flavor/set.rs new file mode 100644 index 000000000..911d88da3 --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor/set.rs @@ -0,0 +1,227 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines the attributes of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines the attributes of a PUT request. + #[builder(setter(into))] + pub(crate) flavor: Flavor<'a>, + + /// flavor_id parameter for /v2/lbaas/flavors/{flavor_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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/flavors/{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("flavor", serde_json::to_value(&self.flavor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/flavors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/flavors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .flavor(FlavorBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/flavor_profile.rs b/sdk/load-balancer/src/v2/flavor_profile.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/flavor_profile.rs rename to sdk/load-balancer/src/v2/flavor_profile.rs diff --git a/sdk/load-balancer/src/v2/flavor_profile/create.rs b/sdk/load-balancer/src/v2/flavor_profile/create.rs new file mode 100644 index 000000000..1285a0fcf --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor_profile/create.rs @@ -0,0 +1,251 @@ +// 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`. + +//! Creates a flavor Profile. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavorprofile<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) flavor_data: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) provider_name: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) flavorprofile: Flavorprofile<'a>, + + #[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 Flavor_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/flavorprofiles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("flavorprofile", serde_json::to_value(&self.flavorprofile)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavorprofile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavorprofile( + FlavorprofileBuilder::default() + .flavor_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavorprofile( + FlavorprofileBuilder::default() + .flavor_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavorprofile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/flavorprofiles".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavorprofile": {} })); + }); + + let endpoint = Request::builder() + .flavorprofile( + FlavorprofileBuilder::default() + .flavor_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/flavorprofiles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavorprofile": {} })); + }); + + let endpoint = Request::builder() + .flavorprofile( + FlavorprofileBuilder::default() + .flavor_data("foo") + .name("foo") + .provider_name("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor_profile/delete.rs b/sdk/load-balancer/src/v2/flavor_profile/delete.rs new file mode 100644 index 000000000..51fe1d7be --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor_profile/delete.rs @@ -0,0 +1,182 @@ +// 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`. + +//! Deletes a Flavor Profile +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavorprofile_id parameter for + /// /v2/lbaas/flavorprofiles/{flavorprofile_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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/flavorprofiles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/flavorprofiles/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/flavorprofiles/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor_profile/find.rs b/sdk/load-balancer/src/v2/flavor_profile/find.rs new file mode 100644 index 000000000..7a33c8e7e --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor_profile/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::flavor_profile::{get as Get, list as List}; + +/// Find for flavor_profile 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/flavor_profile/get.rs b/sdk/load-balancer/src/v2/flavor_profile/get.rs new file mode 100644 index 000000000..e84bf2567 --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor_profile/get.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Gets a flavor profile's detail. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavorprofile_id parameter for + /// /v2/lbaas/flavorprofiles/{flavorprofile_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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/flavorprofiles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavorprofile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavorprofile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavorprofile": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavorprofile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor_profile/list.rs b/sdk/load-balancer/src/v2/flavor_profile/list.rs new file mode 100644 index 000000000..fc2eda132 --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor_profile/list.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`. + +//! Lists all flavor profiles. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + flavor_data: Option>, + + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + name: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + #[builder(default, setter(into))] + provider_name: 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> { + /// Add a single header to the Flavor_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/flavorprofiles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("flavor_data", self.flavor_data.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("provider_name", self.provider_name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/flavorprofiles".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/flavorprofiles".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/flavor_profile/set.rs b/sdk/load-balancer/src/v2/flavor_profile/set.rs new file mode 100644 index 000000000..a110a2657 --- /dev/null +++ b/sdk/load-balancer/src/v2/flavor_profile/set.rs @@ -0,0 +1,230 @@ +// 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`. + +//! Updates a flavor Profile. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines the attributes of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavorprofile<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) flavor_data: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) provider_name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines the attributes of a PUT request. + #[builder(setter(into))] + pub(crate) flavorprofile: Flavorprofile<'a>, + + /// flavorprofile_id parameter for + /// /v2/lbaas/flavorprofiles/{flavorprofile_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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/flavorprofiles/{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("flavorprofile", serde_json::to_value(&self.flavorprofile)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavorprofile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavorprofile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavorprofile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/flavorprofiles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavorprofile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .flavorprofile(FlavorprofileBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/healthmonitor.rs b/sdk/load-balancer/src/v2/healthmonitor.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/healthmonitor.rs rename to sdk/load-balancer/src/v2/healthmonitor.rs diff --git a/sdk/load-balancer/src/v2/healthmonitor/create.rs b/sdk/load-balancer/src/v2/healthmonitor/create.rs new file mode 100644 index 000000000..e2a7c8c05 --- /dev/null +++ b/sdk/load-balancer/src/v2/healthmonitor/create.rs @@ -0,0 +1,422 @@ +// 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`. + +//! Creates a health monitor on a pool. +//! +//! Health monitors define how the load balancer monitors backend servers to +//! determine if they are available to service requests. +//! +//! This operation provisions a new health monitor by using the configuration +//! that you define in the request object. After the API validates the request +//! and starts the provisioning process, the API returns a response object that +//! contains a unique ID and the status of provisioning the health monitor. +//! +//! In the response, the health monitor [provisioning status](#prov-status) is +//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. +//! +//! If the status is `PENDING_CREATE`, issue GET +//! `/v2/lbaas/healthmonitors/{healthmonitor_id}` to view the progress of the +//! provisioning operation. When the health monitor status changes to `ACTIVE`, +//! the health monitor is successfully provisioned and is ready for further +//! configuration. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! Specifying a project_id is deprecated. The health monitor will inherit the +//! project_id of the parent load balancer. +//! +//! At a minimum, you must specify these health monitor attributes: +//! +//! Some attributes receive default values if you omit them from the request: +//! +//! To create a health monitor, the parent load balancer must have an `ACTIVE` +//! provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HttpMethod { + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "PATCH")] + Patch, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "TRACE")] + Trace, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PING")] + Ping, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TLS-HELLO")] + TlsHello, + #[serde(rename = "UDP-CONNECT")] + UdpConnect, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Healthmonitor<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// The time, in seconds, between sending probes to members. + #[serde()] + #[builder(setter(into))] + pub(crate) delay: i32, + + /// The domain name, which be injected into the HTTP Host Header to the + /// backend server for HTTP health check. + /// + /// **New in version 2.10** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + /// The list of HTTP status codes expected in response from the member to + /// declare it healthy. Specify one of the following values: + /// + /// - A single value, such as `200` + /// - A list, such as `200, 202` + /// - A range, such as `200-204` + /// + /// The default is 200. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + /// The HTTP method that the health monitor uses for requests. One of + /// `CONNECT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, `PATCH`, `POST`, `PUT`, + /// or `TRACE`. The default is `GET`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + /// The HTTP version. One of `1.0` or `1.1`. The default is `1.0`. + /// + /// **New in version 2.10** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + /// The number of successful checks before changing the `operating status` + /// of the member to `ONLINE`. A valid value is from `1` to `10`. + #[serde()] + #[builder(setter(into))] + pub(crate) max_retries: i32, + + /// The number of allowed check failures before changing the + /// `operating status` of the member to `ERROR`. A valid value is from `1` + /// to `10`. The default is `3`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the pool. + #[serde()] + #[builder(setter(into))] + pub(crate) pool_id: Cow<'a, str>, + + /// The ID of the project owning this resource. (deprecated) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The maximum time, in seconds, that a monitor waits to connect before it + /// times out. This value must be less than the delay value. + #[serde()] + #[builder(setter(into))] + pub(crate) timeout: i32, + + /// The type of health monitor. One of `HTTP`, `HTTPS`, `PING`, `SCTP`, + /// `TCP`, `TLS-HELLO`, or `UDP-CONNECT`. + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, + + /// The HTTP URL path of the request sent by the monitor to test the health + /// of a backend member. Must be a string that begins with a forward slash + /// (`/`). The default URL path is `/`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) healthmonitor: Healthmonitor<'a>, + + #[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 Healthmonitor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/healthmonitors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("healthmonitor", serde_json::to_value(&self.healthmonitor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("healthmonitor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .healthmonitor( + HealthmonitorBuilder::default() + ._type(Type::Http) + .delay(123) + .max_retries(123) + .pool_id("foo") + .timeout(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .healthmonitor( + HealthmonitorBuilder::default() + ._type(Type::Http) + .delay(123) + .max_retries(123) + .pool_id("foo") + .timeout(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "healthmonitor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/healthmonitors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitor": {} })); + }); + + let endpoint = Request::builder() + .healthmonitor( + HealthmonitorBuilder::default() + ._type(Type::Http) + .delay(123) + .max_retries(123) + .pool_id("foo") + .timeout(123) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/healthmonitors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitor": {} })); + }); + + let endpoint = Request::builder() + .healthmonitor( + HealthmonitorBuilder::default() + ._type(Type::Http) + .delay(123) + .max_retries(123) + .pool_id("foo") + .timeout(123) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/healthmonitor/delete.rs b/sdk/load-balancer/src/v2/healthmonitor/delete.rs new file mode 100644 index 000000000..aac1a5de5 --- /dev/null +++ b/sdk/load-balancer/src/v2/healthmonitor/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Removes a health monitor and its associated configuration from the project. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// healthmonitor_id parameter for + /// /v2/lbaas/healthmonitors/{healthmonitor_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<'a> RequestBuilder<'a> { + /// Add a single header to the Healthmonitor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/healthmonitors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/healthmonitors/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/healthmonitors/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/healthmonitor/find.rs b/sdk/load-balancer/src/v2/healthmonitor/find.rs new file mode 100644 index 000000000..74d3f4da0 --- /dev/null +++ b/sdk/load-balancer/src/v2/healthmonitor/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::healthmonitor::{get as Get, list as List}; + +/// Find for healthmonitor 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/healthmonitor/get.rs b/sdk/load-balancer/src/v2/healthmonitor/get.rs new file mode 100644 index 000000000..e6360ce53 --- /dev/null +++ b/sdk/load-balancer/src/v2/healthmonitor/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows the details of a health monitor. +//! +//! If you are not an administrative user and the parent load balancer does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// healthmonitor_id parameter for + /// /v2/lbaas/healthmonitors/{healthmonitor_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<'a> RequestBuilder<'a> { + /// Add a single header to the Healthmonitor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/healthmonitors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("healthmonitor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "healthmonitor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/healthmonitors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitor": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/healthmonitors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/healthmonitor/list.rs b/sdk/load-balancer/src/v2/healthmonitor/list.rs new file mode 100644 index 000000000..58de82642 --- /dev/null +++ b/sdk/load-balancer/src/v2/healthmonitor/list.rs @@ -0,0 +1,326 @@ +// 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`. + +//! Lists all health monitors for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list health monitors for other projects. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The type of health monitor. + #[builder(default, setter(into))] + _type: Option>, + + /// The administrative state of the resource + #[builder(default)] + admin_state_up: Option, + + /// The UTC date and timestamp when the resource was created. + #[builder(default, setter(into))] + created_at: Option>, + + /// The time, in seconds, between sending probes to members. + #[builder(default)] + delay: Option, + + /// A human-readable description for the resource. + #[builder(default, setter(into))] + description: Option>, + + /// The list of HTTP status codes expected in response from the member to + /// declare it healthy. + #[builder(default, setter(into))] + expected_codes: Option>, + + /// The HTTP method that the health monitor uses for requests. + #[builder(default, setter(into))] + http_method: Option>, + + /// The ID of the resource + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + /// The number of successful checks before changing the operating status of + /// the member to ONLINE. A valid value is from 1 to 10. + #[builder(default)] + max_retries: Option, + + /// The number of allowed check failures before changing the operating + /// status of the member to ERROR. A valid value is from 1 to 10. + #[builder(default)] + max_retries_down: Option, + + /// Human-readable name of the resource. + #[builder(default, setter(into))] + name: Option>, + + /// Return the list of entities that do not have one or more of the given + /// tags. + #[builder(default, setter(into))] + not_tags: Option>, + + /// Return the list of entities that do not have at least one of the given + /// tags. + #[builder(default, setter(into))] + not_tags_any: Option>, + + /// The operating status of the resource. + #[builder(default, setter(into))] + operating_status: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + /// The ID of the pool. + #[builder(default, setter(into))] + pool_id: Option>, + + /// The ID of the project owning this resource. + #[builder(default, setter(into))] + project_id: Option>, + + /// The provisioning status of the resource. + #[builder(default, setter(into))] + provisioning_status: Option>, + + /// Return the list of entities that have this tag or tags. + #[builder(default, setter(into))] + tags: Option>, + + /// Return the list of entities that have one or more of the given tags. + #[builder(default, setter(into))] + tags_any: Option>, + + /// The maximum time, in seconds, that a monitor waits to connect before it + /// times out. + #[builder(default)] + timeout: Option, + + /// The UTC date and timestamp when the resource was last updated. + #[builder(default, setter(into))] + updated_at: Option>, + + /// The HTTP URL path of the request sent by the monitor to test the health + /// of a backend member. Must be a string that begins with a forward slash + /// (/). + #[builder(default, setter(into))] + url_path: 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> { + /// Add a single header to the Healthmonitor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/healthmonitors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("delay", self.delay); + params.push_opt("description", self.description.as_ref()); + params.push_opt("expected_codes", self.expected_codes.as_ref()); + params.push_opt("http_method", self.http_method.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("max_retries", self.max_retries); + params.push_opt("max_retries_down", self.max_retries_down); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("operating_status", self.operating_status.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("pool_id", self.pool_id.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("provisioning_status", self.provisioning_status.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("timeout", self.timeout); + params.push_opt("type", self._type.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + params.push_opt("url_path", self.url_path.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("healthmonitors".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "healthmonitors" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/healthmonitors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitors": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/healthmonitors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitors": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/healthmonitor/set.rs b/sdk/load-balancer/src/v2/healthmonitor/set.rs new file mode 100644 index 000000000..788a5b364 --- /dev/null +++ b/sdk/load-balancer/src/v2/healthmonitor/set.rs @@ -0,0 +1,331 @@ +// 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 an existing health monitor. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the update, check that the health monitor provisioning +//! status is `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation +//! to poll the health monitor object for changes. +//! +//! This operation returns the updated health monitor object with the `ACTIVE`, +//! `PENDING_UPDATE`, or `ERROR` provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HttpMethod { + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "PATCH")] + Patch, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "TRACE")] + Trace, +} + +/// Defines attributes that are acceptable of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Healthmonitor<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// The time, in seconds, between sending probes to members. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) delay: Option, + + /// The domain name, which be injected into the HTTP Host Header to the + /// backend server for HTTP health check. + /// + /// **New in version 2.10** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + /// The list of HTTP status codes expected in response from the member to + /// declare it healthy. Specify one of the following values: + /// + /// - A single value, such as `200` + /// - A list, such as `200, 202` + /// - A range, such as `200-204` + /// + /// The default is 200. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + /// The HTTP method that the health monitor uses for requests. One of + /// `CONNECT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, `PATCH`, `POST`, `PUT`, + /// or `TRACE`. The default is `GET`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + /// The HTTP version. One of `1.0` or `1.1`. The default is `1.0`. + /// + /// **New in version 2.10** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + /// The number of successful checks before changing the `operating status` + /// of the member to `ONLINE`. A valid value is from `1` to `10`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries: Option, + + /// The number of allowed check failures before changing the + /// `operating status` of the member to `ERROR`. A valid value is from `1` + /// to `10`. The default is `3`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// The maximum time, in seconds, that a monitor waits to connect before it + /// times out. This value must be less than the delay value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout: Option, + + /// The HTTP URL path of the request sent by the monitor to test the health + /// of a backend member. Must be a string that begins with a forward slash + /// (`/`). The default URL path is `/`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines attributes that are acceptable of a PUT request. + #[builder(setter(into))] + pub(crate) healthmonitor: Healthmonitor<'a>, + + /// healthmonitor_id parameter for + /// /v2/lbaas/healthmonitors/{healthmonitor_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<'a> RequestBuilder<'a> { + /// Add a single header to the Healthmonitor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/healthmonitors/{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("healthmonitor", serde_json::to_value(&self.healthmonitor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("healthmonitor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "healthmonitor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/healthmonitors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/healthmonitors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "healthmonitor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .healthmonitor(HealthmonitorBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy.rs b/sdk/load-balancer/src/v2/l7policy.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/l7policy.rs rename to sdk/load-balancer/src/v2/l7policy.rs diff --git a/sdk/load-balancer/src/v2/l7policy/create.rs b/sdk/load-balancer/src/v2/l7policy/create.rs new file mode 100644 index 000000000..dc8853aab --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/create.rs @@ -0,0 +1,432 @@ +// 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`. + +//! Creates a L7 policy. +//! +//! This operation provisions a new L7 policy by using the configuration that +//! you define in the request object. After the API validates the request and +//! starts the provisioning process, the API returns a response object that +//! contains a unique ID and the status of provisioning the L7 policy. +//! +//! In the response, the L7 policy [provisioning status](#prov-status) is +//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. +//! +//! If the status is `PENDING_CREATE`, issue GET +//! `/v2/lbaas/l7policies/{l7policy_id}` to view the progress of the +//! provisioning operation. When the L7 policy status changes to `ACTIVE`, the +//! L7 policy is successfully provisioned and is ready for further +//! configuration. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! All the rules associated with a given policy are logically ANDead together. +//! A request must match all the policy’s rules to match the policy. +//! +//! If you need to express a logical OR operation between rules, then do this +//! by creating multiple policies with the same action. +//! +//! If a new policy is created with a position that matches that of an existing +//! policy, then the new policy is inserted at the given position. +//! +//! L7 policies with `action` of `REDIRECT_TO_URL` will return the default HTTP +//! `Found (302)` response code with the `redirect_url`. Also, specify +//! `redirect_http_code` to configure the needed HTTP response code, such as, +//! 301, 302, 303, 307 and 308. +//! +//! L7 policies with `action` of `REJECT` will return a `Forbidden (403)` +//! response code to the requester. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Action { + #[serde(rename = "REDIRECT_PREFIX")] + RedirectPrefix, + #[serde(rename = "REDIRECT_TO_POOL")] + RedirectToPool, + #[serde(rename = "REDIRECT_TO_URL")] + RedirectToUrl, + #[serde(rename = "REJECT")] + Reject, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum CompareType { + #[serde(rename = "CONTAINS")] + Contains, + #[serde(rename = "ENDS_WITH")] + EndsWith, + #[serde(rename = "EQUAL_TO")] + EqualTo, + #[serde(rename = "REGEX")] + Regex, + #[serde(rename = "STARTS_WITH")] + StartsWith, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "COOKIE")] + Cookie, + #[serde(rename = "FILE_TYPE")] + FileType, + #[serde(rename = "HEADER")] + Header, + #[serde(rename = "HOST_NAME")] + HostName, + #[serde(rename = "PATH")] + Path, + #[serde(rename = "SSL_CONN_HAS_CERT")] + SslConnHasCert, + #[serde(rename = "SSL_DN_FIELD")] + SslDnField, + #[serde(rename = "SSL_VERIFY_RESULT")] + SslVerifyResult, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Rules<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder()] + pub(crate) compare_type: CompareType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) invert: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, + + #[serde()] + #[builder(setter(into))] + pub(crate) value: Cow<'a, str>, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct L7policy<'a> { + /// The L7 policy action. One of `REDIRECT_PREFIX`, `REDIRECT_TO_POOL`, + /// `REDIRECT_TO_URL`, or `REJECT`. + #[serde()] + #[builder()] + pub(crate) action: Action, + + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The ID of the listener. + #[serde()] + #[builder(setter(into))] + pub(crate) listener_id: Cow<'a, str>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The position of this policy on the listener. Positions start at 1. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) position: Option, + + /// The ID of the project owning this resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// Requests matching this policy will be redirected to the specified URL + /// or Prefix URL with the HTTP response code. Valid if `action` is + /// `REDIRECT_TO_URL` or `REDIRECT_PREFIX`. Valid options are: 301, 302, + /// 303, 307, or 308. Default is 302. + /// + /// **New in version 2.9** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_http_code: Option, + + /// Requests matching this policy will be redirected to the pool with this + /// ID. Only valid if `action` is `REDIRECT_TO_POOL`. The pool has some + /// restrictions, See + /// [Protocol Combinations (Listener/Pool)](#valid-protocol). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_pool_id: Option>, + + /// Requests matching this policy will be redirected to this Prefix URL. + /// Only valid if `action` is `REDIRECT_PREFIX`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_prefix: Option>, + + /// Requests matching this policy will be redirected to this URL. Only + /// valid if `action` is `REDIRECT_TO_URL`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_url: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rules: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) l7policy: L7policy<'a>, + + #[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 L7Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/l7policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("l7policy", serde_json::to_value(&self.l7policy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("l7policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .l7policy( + L7policyBuilder::default() + .action(Action::RedirectPrefix) + .listener_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .l7policy( + L7policyBuilder::default() + .action(Action::RedirectPrefix) + .listener_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "l7policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/l7policies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policy": {} })); + }); + + let endpoint = Request::builder() + .l7policy( + L7policyBuilder::default() + .action(Action::RedirectPrefix) + .listener_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/l7policies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policy": {} })); + }); + + let endpoint = Request::builder() + .l7policy( + L7policyBuilder::default() + .action(Action::RedirectPrefix) + .listener_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/delete.rs b/sdk/load-balancer/src/v2/l7policy/delete.rs new file mode 100644 index 000000000..2f18317da --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Removes a L7 policy and its associated configuration from the project. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// l7policy_id parameter for /v2/lbaas/l7policies/{l7policy_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<'a> RequestBuilder<'a> { + /// Add a single header to the L7Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/l7policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/l7policies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/l7policies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/find.rs b/sdk/load-balancer/src/v2/l7policy/find.rs new file mode 100644 index 000000000..08470a61c --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::l7policy::{get as Get, list as List}; + +/// Find for l7policy 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/get.rs b/sdk/load-balancer/src/v2/l7policy/get.rs new file mode 100644 index 000000000..ff4250f9f --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/get.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Shows the details of a L7 policy. +//! +//! If you are not an administrative user and the L7 policy object does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// l7policy_id parameter for /v2/lbaas/l7policies/{l7policy_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<'a> RequestBuilder<'a> { + /// Add a single header to the L7Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/l7policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("l7policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "l7policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/l7policies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policy": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/l7policies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/list.rs b/sdk/load-balancer/src/v2/l7policy/list.rs new file mode 100644 index 000000000..4034cde4d --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/list.rs @@ -0,0 +1,256 @@ +// 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`. + +//! Lists all L7 policies for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list L7 policies for other projects. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + action: Option>, + + #[builder(default)] + admin_state_up: Option, + + #[builder(default, setter(into))] + description: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + #[builder(default, setter(into))] + listener_id: Option>, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + name: Option>, + + #[builder(default, setter(into))] + operating_status: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + #[builder(default, setter(into))] + position: Option>, + + #[builder(default, setter(into))] + project_id: Option>, + + #[builder(default, setter(into))] + provisioning_status: Option>, + + #[builder(default, setter(into))] + redirect_pool_id: Option>, + + #[builder(default, setter(into))] + redirect_prefix: Option>, + + #[builder(default, setter(into))] + redirect_url: 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> { + /// Add a single header to the L7Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/l7policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("action", self.action.as_ref()); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("description", self.description.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("listener_id", self.listener_id.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("operating_status", self.operating_status.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("position", self.position.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("provisioning_status", self.provisioning_status.as_ref()); + params.push_opt("redirect_pool_id", self.redirect_pool_id.as_ref()); + params.push_opt("redirect_prefix", self.redirect_prefix.as_ref()); + params.push_opt("redirect_url", self.redirect_url.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("l7policies".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "l7policies" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/l7policies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policies": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/l7policies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policies": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/l7policy/rule.rs b/sdk/load-balancer/src/v2/l7policy/rule.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/l7policy/rule.rs rename to sdk/load-balancer/src/v2/l7policy/rule.rs diff --git a/sdk/load-balancer/src/v2/l7policy/rule/create.rs b/sdk/load-balancer/src/v2/l7policy/rule/create.rs new file mode 100644 index 000000000..b7f8ef746 --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/rule/create.rs @@ -0,0 +1,366 @@ +// 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`. + +//! Creates a L7 rule. +//! +//! This operation provisions a new L7 rule by using the configuration that you +//! define in the request object. After the API validates the request and +//! starts the provisioning process, the API returns a response object that +//! contains a unique ID and the status of provisioning the L7 rule. +//! +//! In the response, the L7 rule [provisioning status](#prov-status) is +//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. +//! +//! If the status is `PENDING_CREATE`, issue GET +//! `/v2/lbaas/l7policies/{l7policy_id}/rules/{l7rule_id}` to view the progress +//! of the provisioning operation. When the L7 rule status changes to `ACTIVE`, +//! the L7 rule is successfully provisioned and is ready for further +//! configuration. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! All the rules associated with a given policy are logically ANDead together. +//! A request must match all the policy’s rules to match the policy. +//! +//! If you need to express a logical OR operation between rules, then do this +//! by creating multiple policies with the same action. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum CompareType { + #[serde(rename = "CONTAINS")] + Contains, + #[serde(rename = "ENDS_WITH")] + EndsWith, + #[serde(rename = "EQUAL_TO")] + EqualTo, + #[serde(rename = "REGEX")] + Regex, + #[serde(rename = "STARTS_WITH")] + StartsWith, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "COOKIE")] + Cookie, + #[serde(rename = "FILE_TYPE")] + FileType, + #[serde(rename = "HEADER")] + Header, + #[serde(rename = "HOST_NAME")] + HostName, + #[serde(rename = "PATH")] + Path, + #[serde(rename = "SSL_CONN_HAS_CERT")] + SslConnHasCert, + #[serde(rename = "SSL_DN_FIELD")] + SslDnField, + #[serde(rename = "SSL_VERIFY_RESULT")] + SslVerifyResult, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Rule<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// The comparison type for the L7 rule. One of `CONTAINS`, `ENDS_WITH`, + /// `EQUAL_TO`, `REGEX`, or `STARTS_WITH`. + #[serde()] + #[builder()] + pub(crate) compare_type: CompareType, + + /// When `true` the logic of the rule is inverted. For example, with invert + /// `true`, equal to would become not equal to. Default is `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) invert: Option, + + /// The key to use for the comparison. For example, the name of the cookie + /// to evaluate. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key: Option>, + + /// The ID of the project owning this resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The L7 rule type. One of `COOKIE`, `FILE_TYPE`, `HEADER`, `HOST_NAME`, + /// `PATH`, `SSL_CONN_HAS_CERT`, `SSL_VERIFY_RESULT`, or `SSL_DN_FIELD`. + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: Type, + + /// The value to use for the comparison. For example, the file type to + /// compare. + #[serde()] + #[builder(setter(into))] + pub(crate) value: Cow<'a, str>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) rule: Rule<'a>, + + /// l7policy_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + l7policy_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 Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "lbaas/l7policies/{l7policy_id}/rules", + l7policy_id = self.l7policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("rule", serde_json::to_value(&self.rule)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .rule( + RuleBuilder::default() + ._type(Type::Cookie) + .compare_type(CompareType::Contains) + .value("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .rule( + RuleBuilder::default() + ._type(Type::Cookie) + .compare_type(CompareType::Contains) + .value("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/lbaas/l7policies/{l7policy_id}/rules", + l7policy_id = "l7policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .rule( + RuleBuilder::default() + ._type(Type::Cookie) + .compare_type(CompareType::Contains) + .value("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/lbaas/l7policies/{l7policy_id}/rules", + l7policy_id = "l7policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .rule( + RuleBuilder::default() + ._type(Type::Cookie) + .compare_type(CompareType::Contains) + .value("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/rule/delete.rs b/sdk/load-balancer/src/v2/l7policy/rule/delete.rs new file mode 100644 index 000000000..e875536bf --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/rule/delete.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`. + +//! Removes a L7 rule and its associated configuration from the project. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// rule_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// l7policy_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + l7policy_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 Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = self.l7policy_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = "l7policy_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = "l7policy_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() + .l7policy_id("l7policy_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/rule/get.rs b/sdk/load-balancer/src/v2/l7policy/rule/get.rs new file mode 100644 index 000000000..6c2e33673 --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/rule/get.rs @@ -0,0 +1,213 @@ +// 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`. + +//! Shows the details of a L7 rule. +//! +//! If you are not an administrative user and the L7 rule object does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// rule_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// l7policy_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + l7policy_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 Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = self.l7policy_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = "l7policy_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = "l7policy_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/rule/list.rs b/sdk/load-balancer/src/v2/l7policy/rule/list.rs new file mode 100644 index 000000000..cef8095e3 --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/rule/list.rs @@ -0,0 +1,270 @@ +// 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`. + +//! Lists all L7 rules for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list L7 policies for other projects. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + _type: Option>, + + #[builder(default)] + admin_state_up: Option, + + #[builder(default, setter(into))] + compare_type: Option>, + + #[builder(default, setter(into))] + created_at: Option>, + + #[builder(default, setter(into))] + invert: Option>, + + #[builder(default, setter(into))] + key: Option>, + + /// l7policy_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + l7policy_id: Cow<'a, str>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + operating_status: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + #[builder(default, setter(into))] + project_id: Option>, + + #[builder(default, setter(into))] + provisioning_status: Option>, + + #[builder(default, setter(into))] + rule_value: Option>, + + #[builder(default, setter(into))] + 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<'a> RequestBuilder<'a> { + /// Add a single header to the Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/l7policies/{l7policy_id}/rules", + l7policy_id = self.l7policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("compare_type", self.compare_type.as_ref()); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("invert", self.invert.as_ref()); + params.push_opt("key", self.key.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("operating_status", self.operating_status.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("provisioning_status", self.provisioning_status.as_ref()); + params.push_opt("rule_value", self.rule_value.as_ref()); + params.push_opt("type", self._type.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/lbaas/l7policies/{l7policy_id}/rules", + l7policy_id = "l7policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rules": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/lbaas/l7policies/{l7policy_id}/rules", + l7policy_id = "l7policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rules": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/rule/set.rs b/sdk/load-balancer/src/v2/l7policy/rule/set.rs new file mode 100644 index 000000000..b272f7ba5 --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/rule/set.rs @@ -0,0 +1,322 @@ +// 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`. + +//! Updates a L7 rule. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the update, check that the L7 rule provisioning status is +//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll +//! the L7 rule object for changes. +//! +//! This operation returns the updated L7 rule object with the `ACTIVE`, +//! `PENDING_UPDATE`, or `ERROR` provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum CompareType { + #[serde(rename = "CONTAINS")] + Contains, + #[serde(rename = "ENDS_WITH")] + EndsWith, + #[serde(rename = "EQUAL_TO")] + EqualTo, + #[serde(rename = "REGEX")] + Regex, + #[serde(rename = "STARTS_WITH")] + StartsWith, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "COOKIE")] + Cookie, + #[serde(rename = "FILE_TYPE")] + FileType, + #[serde(rename = "HEADER")] + Header, + #[serde(rename = "HOST_NAME")] + HostName, + #[serde(rename = "PATH")] + Path, + #[serde(rename = "SSL_CONN_HAS_CERT")] + SslConnHasCert, + #[serde(rename = "SSL_DN_FIELD")] + SslDnField, + #[serde(rename = "SSL_VERIFY_RESULT")] + SslVerifyResult, +} + +/// Defines attributes that are acceptable of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Rule<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// The comparison type for the L7 rule. One of `CONTAINS`, `ENDS_WITH`, + /// `EQUAL_TO`, `REGEX`, or `STARTS_WITH`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) compare_type: Option, + + /// When `true` the logic of the rule is inverted. For example, with invert + /// `true`, equal to would become not equal to. Default is `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) invert: Option, + + /// The key to use for the comparison. For example, the name of the cookie + /// to evaluate. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// The L7 rule type. One of `COOKIE`, `FILE_TYPE`, `HEADER`, `HOST_NAME`, + /// `PATH`, `SSL_CONN_HAS_CERT`, `SSL_VERIFY_RESULT`, or `SSL_DN_FIELD`. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, + + /// The value to use for the comparison. For example, the file type to + /// compare. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) value: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines attributes that are acceptable of a PUT request. + #[builder(setter(into))] + pub(crate) rule: Rule<'a>, + + /// rule_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// l7policy_id parameter for + /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API + #[builder(default, setter(into))] + l7policy_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 Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = self.l7policy_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("rule", serde_json::to_value(&self.rule)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .rule(RuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .rule(RuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = "l7policy_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .id("id") + .rule(RuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/lbaas/l7policies/{l7policy_id}/rules/{id}", + l7policy_id = "l7policy_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule": {} })); + }); + + let endpoint = Request::builder() + .l7policy_id("l7policy_id") + .id("id") + .rule(RuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/l7policy/set.rs b/sdk/load-balancer/src/v2/l7policy/set.rs new file mode 100644 index 000000000..8bef0179c --- /dev/null +++ b/sdk/load-balancer/src/v2/l7policy/set.rs @@ -0,0 +1,304 @@ +// 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`. + +//! Updates a L7 policy. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the update, check that the L7 policy provisioning status +//! is `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll +//! the L7 policy object for changes. +//! +//! This operation returns the updated L7 policy object with the `ACTIVE`, +//! `PENDING_UPDATE`, or `ERROR` provisioning status. +//! +//! If a policy is updated with a position that matches that of an existing +//! policy, then the updated policy is inserted at the given position. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Action { + #[serde(rename = "REDIRECT_PREFIX")] + RedirectPrefix, + #[serde(rename = "REDIRECT_TO_POOL")] + RedirectToPool, + #[serde(rename = "REDIRECT_TO_URL")] + RedirectToUrl, + #[serde(rename = "REJECT")] + Reject, +} + +/// Defines attributes that are acceptable of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct L7policy<'a> { + /// The L7 policy action. One of `REDIRECT_PREFIX`, `REDIRECT_TO_POOL`, + /// `REDIRECT_TO_URL`, or `REJECT`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) action: Option, + + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The position of this policy on the listener. Positions start at 1. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) position: Option, + + /// Requests matching this policy will be redirected to the specified URL + /// or Prefix URL with the HTTP response code. Valid if `action` is + /// `REDIRECT_TO_URL` or `REDIRECT_PREFIX`. Valid options are: 301, 302, + /// 303, 307, or 308. Default is 302. + /// + /// **New in version 2.9** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_http_code: Option, + + /// Requests matching this policy will be redirected to the pool with this + /// ID. Only valid if `action` is `REDIRECT_TO_POOL`. The pool has some + /// restrictions, See + /// [Protocol Combinations (Listener/Pool)](#valid-protocol). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_pool_id: Option>, + + /// Requests matching this policy will be redirected to this Prefix URL. + /// Only valid if `action` is `REDIRECT_PREFIX`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_prefix: Option>, + + /// Requests matching this policy will be redirected to this URL. Only + /// valid if `action` is `REDIRECT_TO_URL`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_url: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines attributes that are acceptable of a PUT request. + #[builder(setter(into))] + pub(crate) l7policy: L7policy<'a>, + + /// l7policy_id parameter for /v2/lbaas/l7policies/{l7policy_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<'a> RequestBuilder<'a> { + /// Add a single header to the L7Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/l7policies/{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("l7policy", serde_json::to_value(&self.l7policy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("l7policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .l7policy(L7policyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .l7policy(L7policyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "l7policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/l7policies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .l7policy(L7policyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/l7policies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "l7policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .l7policy(L7policyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/listener.rs b/sdk/load-balancer/src/v2/listener.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/listener.rs rename to sdk/load-balancer/src/v2/listener.rs diff --git a/sdk/load-balancer/src/v2/listener/create.rs b/sdk/load-balancer/src/v2/listener/create.rs new file mode 100644 index 000000000..9424b11fa --- /dev/null +++ b/sdk/load-balancer/src/v2/listener/create.rs @@ -0,0 +1,1115 @@ +// 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`. + +//! Creates a listener for a load balancer. +//! +//! The listener configures a port and protocol for the load balancer to listen +//! on for incoming requests. A load balancer may have zero or more listeners +//! configured. +//! +//! This operation provisions a new listener by using the configuration that +//! you define in the request object. After the API validates the request and +//! starts the provisioning process, the API returns a response object that +//! contains a unique ID and the status of provisioning the listener. +//! +//! In the response, the listener [provisioning status](#prov-status) is +//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. +//! +//! If the status is `PENDING_CREATE`, issue GET +//! `/v2/lbaas/listeners/{listener_id}` to view the progress of the +//! provisioning operation. When the listener status changes to `ACTIVE`, the +//! listener is successfully provisioned and is ready for further +//! configuration. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! Specifying a project_id is deprecated. The listener will inherit the +//! project_id of the parent load balancer. +//! +//! You can configure all documented features of the listener at creation time +//! by specifying the additional elements or attributes in the request. +//! +//! To create a listener, the parent load balancer must have an `ACTIVE` +//! provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 ClientAuthentication { + #[serde(rename = "MANDATORY")] + Mandatory, + #[serde(rename = "NONE")] + None, + #[serde(rename = "OPTIONAL")] + Optional, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HttpMethod { + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "PATCH")] + Patch, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "TRACE")] + Trace, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HealthmonitorType { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PING")] + Ping, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TLS-HELLO")] + TlsHello, + #[serde(rename = "UDP-CONNECT")] + UdpConnect, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Healthmonitor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) delay: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) max_retries: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) timeout: i32, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: HealthmonitorType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum LbAlgorithm { + #[serde(rename = "LEAST_CONNECTIONS")] + LeastConnections, + #[serde(rename = "ROUND_ROBIN")] + RoundRobin, + #[serde(rename = "SOURCE_IP")] + SourceIp, + #[serde(rename = "SOURCE_IP_PORT")] + SourceIpPort, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Members<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) address: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) backup: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_address: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_port: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_port: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) request_sriov: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) weight: Option, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum DefaultPoolProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROXY")] + Proxy, + #[serde(rename = "PROXYV2")] + Proxyv2, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum SessionPersistenceType { + #[serde(rename = "APP_COOKIE")] + AppCookie, + #[serde(rename = "HTTP_COOKIE")] + HttpCookie, + #[serde(rename = "SOURCE_IP")] + SourceIp, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SessionPersistence<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cookie_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_granularity: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_timeout: Option, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: SessionPersistenceType, +} + +/// A pool object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct DefaultPool<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 + /// + /// **New in version 2.20** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ca_tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) crl_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) healthmonitor: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) lb_algorithm: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) members: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) session_persistence: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// List of ciphers in OpenSSL format (colon-separated). See + /// + /// + /// **New in version 2.15** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_enabled: Option, + + /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, + /// TLSv1.1, TLSv1.2, TLSv1.3 + /// + /// **New in version 2.17** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Action { + #[serde(rename = "REDIRECT_PREFIX")] + RedirectPrefix, + #[serde(rename = "REDIRECT_TO_POOL")] + RedirectToPool, + #[serde(rename = "REDIRECT_TO_URL")] + RedirectToUrl, + #[serde(rename = "REJECT")] + Reject, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum RedirectPoolHealthmonitorType { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PING")] + Ping, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TLS-HELLO")] + TlsHello, + #[serde(rename = "UDP-CONNECT")] + UdpConnect, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RedirectPoolHealthmonitor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) delay: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) max_retries: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) timeout: i32, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: RedirectPoolHealthmonitorType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum RedirectPoolProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROXY")] + Proxy, + #[serde(rename = "PROXYV2")] + Proxyv2, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "APP_COOKIE")] + AppCookie, + #[serde(rename = "HTTP_COOKIE")] + HttpCookie, + #[serde(rename = "SOURCE_IP")] + SourceIp, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RedirectPool<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ca_tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) crl_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) healthmonitor: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) lb_algorithm: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) members: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) session_persistence: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_enabled: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum CompareType { + #[serde(rename = "CONTAINS")] + Contains, + #[serde(rename = "ENDS_WITH")] + EndsWith, + #[serde(rename = "EQUAL_TO")] + EqualTo, + #[serde(rename = "REGEX")] + Regex, + #[serde(rename = "STARTS_WITH")] + StartsWith, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum RulesType { + #[serde(rename = "COOKIE")] + Cookie, + #[serde(rename = "FILE_TYPE")] + FileType, + #[serde(rename = "HEADER")] + Header, + #[serde(rename = "HOST_NAME")] + HostName, + #[serde(rename = "PATH")] + Path, + #[serde(rename = "SSL_CONN_HAS_CERT")] + SslConnHasCert, + #[serde(rename = "SSL_DN_FIELD")] + SslDnField, + #[serde(rename = "SSL_VERIFY_RESULT")] + SslVerifyResult, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Rules<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder()] + pub(crate) compare_type: CompareType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) invert: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: RulesType, + + #[serde()] + #[builder(setter(into))] + pub(crate) value: Cow<'a, str>, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct L7policies<'a> { + #[serde()] + #[builder()] + pub(crate) action: Action, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) position: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_http_code: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_pool: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_url: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rules: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum ListenerProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROMETHEUS")] + Prometheus, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TERMINATED_HTTPS")] + TerminatedHttps, + #[serde(rename = "UDP")] + Udp, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Listener<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A list of IPv4, IPv6 or mix of both CIDRs. The default is all allowed. + /// When a list of CIDRs is provided, the default switches to deny all. + /// + /// **New in version 2.12** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allowed_cidrs: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + /// The TLS client authentication mode. One of the options `NONE`, + /// `OPTIONAL` or `MANDATORY`. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) client_authentication: Option, + + /// The ref of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format client CA certificate bundle for + /// `TERMINATED_HTTPS` listeners. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) client_ca_tls_container_ref: Option>, + + /// The URI of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format CA revocation list file for + /// `TERMINATED_HTTPS` listeners. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) client_crl_container_ref: Option>, + + /// The maximum number of connections permitted for this listener. Default + /// value is -1 which represents infinite connections or a default value + /// defined by the provider driver. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) connection_limit: Option, + + /// A pool object. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_pool: Option>, + + /// The ID of the pool used by the listener if no L7 policies match. The + /// pool has some restrictions. See + /// [Protocol Combinations (Listener/Pool)](#valid-protocol). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_pool_id: Option>, + + /// The URI of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PKCS12 format certificate/key bundle for + /// `TERMINATED_HTTPS` listeners. DEPRECATED: A secret container of type + /// “certificate” containing the certificate and key for `TERMINATED_HTTPS` + /// listeners. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_tls_container_ref: Option>, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines whether the `includeSubDomains` directive should be added to + /// the Strict-Transport-Security HTTP response header. This requires + /// setting the `hsts_max_age` option as well in order to become effective. + /// + /// **New in version 2.27** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_include_subdomains: Option, + + /// The value of the `max_age` directive for the Strict-Transport-Security + /// HTTP response header. Setting this enables HTTP Strict Transport + /// Security (HSTS) for the TLS-terminated listener. + /// + /// **New in version 2.27** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_max_age: Option, + + /// Defines whether the `preload` directive should be added to the + /// Strict-Transport-Security HTTP response header. This requires setting + /// the `hsts_max_age` option as well in order to become effective. + /// + /// **New in version 2.27** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_preload: Option, + + /// A dictionary of optional headers to insert into the request before it + /// is sent to the backend `member`. See + /// [Supported HTTP Header Insertions](#header-insertions). Both keys and + /// values are always specified as strings. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_insert_headers"))] + pub(crate) insert_headers: Option, Cow<'a, str>>>, + + /// A list of L7 policy objects. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) l7policies: Option>>, + + /// The ID of the load balancer. + #[serde()] + #[builder(setter(into))] + pub(crate) loadbalancer_id: Cow<'a, str>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the project owning this resource. (deprecated) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The protocol for the resource. One of `HTTP`, `HTTPS`, `SCTP`, + /// `PROMETHEUS`, `TCP`, `TERMINATED_HTTPS`, or `UDP`. + #[serde()] + #[builder()] + pub(crate) protocol: ListenerProtocol, + + /// The protocol port number for the resource. + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_port: i32, + + /// A list of URIs to the + /// [key manager service](https://docs.openstack.org/barbican/latest/) + /// secrets containing PKCS12 format certificate/key bundles for + /// `TERMINATED_HTTPS` listeners. (DEPRECATED) Secret containers of type + /// “certificate” containing the certificates and keys for + /// `TERMINATED_HTTPS` listeners. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) sni_container_refs: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// Frontend client inactivity timeout in milliseconds. Default: 50000. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_client_data: Option, + + /// Backend member connection timeout in milliseconds. Default: 5000. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_member_connect: Option, + + /// Backend member inactivity timeout in milliseconds. Default: 50000. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_member_data: Option, + + /// Time, in milliseconds, to wait for additional TCP packets for content + /// inspection. Default: 0. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_tcp_inspect: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +impl<'a> ListenerBuilder<'a> { + /// A dictionary of optional headers to insert into the request before it + /// is sent to the backend `member`. See + /// [Supported HTTP Header Insertions](#header-insertions). Both keys and + /// values are always specified as strings. + pub fn insert_headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.insert_headers + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) listener: Listener<'a>, + + #[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 Listener. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/listeners".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("listener", serde_json::to_value(&self.listener)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("listener".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .listener( + ListenerBuilder::default() + .loadbalancer_id("foo") + .protocol(ListenerProtocol::Http) + .protocol_port(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .listener( + ListenerBuilder::default() + .loadbalancer_id("foo") + .protocol(ListenerProtocol::Http) + .protocol_port(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "listener" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/listeners".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listener": {} })); + }); + + let endpoint = Request::builder() + .listener( + ListenerBuilder::default() + .loadbalancer_id("foo") + .protocol(ListenerProtocol::Http) + .protocol_port(123) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/listeners".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listener": {} })); + }); + + let endpoint = Request::builder() + .listener( + ListenerBuilder::default() + .loadbalancer_id("foo") + .protocol(ListenerProtocol::Http) + .protocol_port(123) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/listener/delete.rs b/sdk/load-balancer/src/v2/listener/delete.rs new file mode 100644 index 000000000..afa24efa0 --- /dev/null +++ b/sdk/load-balancer/src/v2/listener/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Removes a listener and its associated configuration from the project. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// listener_id parameter for /v2/lbaas/listeners/{listener_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<'a> RequestBuilder<'a> { + /// Add a single header to the Listener. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/listeners/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/listeners/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/listeners/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/listener/find.rs b/sdk/load-balancer/src/v2/listener/find.rs new file mode 100644 index 000000000..cebc74e36 --- /dev/null +++ b/sdk/load-balancer/src/v2/listener/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::listener::{get as Get, list as List}; + +/// Find for listener 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/listener/get.rs b/sdk/load-balancer/src/v2/listener/get.rs new file mode 100644 index 000000000..23880e188 --- /dev/null +++ b/sdk/load-balancer/src/v2/listener/get.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Shows the details of a listener. +//! +//! If you are not an administrative user and the parent load balancer does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// listener_id parameter for /v2/lbaas/listeners/{listener_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<'a> RequestBuilder<'a> { + /// Add a single header to the Listener. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/listeners/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("listener".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "listener" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/listeners/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listener": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/listeners/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listener": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/listener/list.rs b/sdk/load-balancer/src/v2/listener/list.rs new file mode 100644 index 000000000..e4e33ace9 --- /dev/null +++ b/sdk/load-balancer/src/v2/listener/list.rs @@ -0,0 +1,356 @@ +// 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`. + +//! Lists all listeners for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list listeners for other projects. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The administrative state of the resource + #[builder(default)] + admin_state_up: Option, + + /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 + #[builder(default, setter(into))] + alpn_protocols: Option>, + + /// The maximum number of connections permitted for this listener. Default + /// value is -1 which represents infinite connections or a default value + /// defined by the provider driver. + #[builder(default, setter(into))] + connection_limit: Option>, + + /// The UTC date and timestamp when the resource was created. + #[builder(default, setter(into))] + created_at: Option>, + + /// The ID of the pool used by the listener if no L7 policies match. + #[builder(default, setter(into))] + default_pool_id: Option>, + + /// A human-readable description for the resource. + #[builder(default, setter(into))] + description: Option>, + + /// Defines whether the includeSubDomains directive should be added to the + /// Strict-Transport-Security HTTP response header. + #[builder(default)] + hsts_include_subdomains: Option, + + /// The value of the max_age directive for the Strict-Transport-Security + /// HTTP response header. + #[builder(default)] + hsts_max_age: Option, + + /// Defines whether the preload directive should be added to the + /// Strict-Transport-Security HTTP response header. + #[builder(default)] + hsts_preload: Option, + + /// The ID of the resource + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// Load balancer ID + #[builder(default, setter(into))] + load_balancer_id: Option>, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + /// Human-readable name of the resource. + #[builder(default, setter(into))] + name: Option>, + + /// Return the list of entities that do not have one or more of the given + /// tags. + #[builder(default, setter(into))] + not_tags: Option>, + + /// Return the list of entities that do not have at least one of the given + /// tags. + #[builder(default, setter(into))] + not_tags_any: Option>, + + /// The operating status of the resource. + #[builder(default, setter(into))] + operating_status: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + /// The ID of the project owning this resource. + #[builder(default, setter(into))] + project_id: Option>, + + /// The protocol for the resource. + #[builder(default, setter(into))] + protocol: Option>, + + /// The protocol port number for the resource. + #[builder(default)] + protocol_port: Option, + + /// The provisioning status of the resource. + #[builder(default, setter(into))] + provisioning_status: Option>, + + /// Return the list of entities that have this tag or tags. + #[builder(default, setter(into))] + tags: Option>, + + /// Return the list of entities that have one or more of the given tags. + #[builder(default, setter(into))] + tags_any: Option>, + + /// Frontend client inactivity timeout in milliseconds. + #[builder(default)] + timeout_client_data: Option, + + /// Backend member connection timeout in milliseconds. + #[builder(default)] + timeout_member_connect: Option, + + /// Backend member inactivity timeout in milliseconds. + #[builder(default)] + timeout_member_data: Option, + + /// Time, in milliseconds, to wait for additional TCP packets for content + /// inspection. + #[builder(default)] + timeout_tcp_inspect: Option, + + /// List of ciphers in OpenSSL format + #[builder(default, setter(into))] + tls_ciphers: Option>, + + /// A list of TLS protocol versions. + #[builder(default, setter(into))] + tls_versions: Option>, + + /// The UTC date and timestamp when the resource was last updated. + #[builder(default, setter(into))] + 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<'a> RequestBuilder<'a> { + /// Add a single header to the Listener. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/listeners".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("alpn_protocols", self.alpn_protocols.as_ref()); + params.push_opt("connection_limit", self.connection_limit.as_ref()); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("default_pool_id", self.default_pool_id.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("hsts_include_subdomains", self.hsts_include_subdomains); + params.push_opt("hsts_max_age", self.hsts_max_age); + params.push_opt("hsts_preload", self.hsts_preload); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("load_balancer_id", self.load_balancer_id.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("operating_status", self.operating_status.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("protocol", self.protocol.as_ref()); + params.push_opt("protocol_port", self.protocol_port); + params.push_opt("provisioning_status", self.provisioning_status.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("timeout_client_data", self.timeout_client_data); + params.push_opt("timeout_member_connect", self.timeout_member_connect); + params.push_opt("timeout_member_data", self.timeout_member_data); + params.push_opt("timeout_tcp_inspect", self.timeout_tcp_inspect); + params.push_opt("tls_ciphers", self.tls_ciphers.as_ref()); + params.push_opt("tls_versions", self.tls_versions.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("listeners".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "listeners" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/listeners".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listeners": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/listeners".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listeners": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/listener/set.rs b/sdk/load-balancer/src/v2/listener/set.rs new file mode 100644 index 000000000..244343d6d --- /dev/null +++ b/sdk/load-balancer/src/v2/listener/set.rs @@ -0,0 +1,435 @@ +// 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 an existing listener. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the update, check that the listener provisioning status is +//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll +//! the listener object for changes. +//! +//! This operation returns the updated listener object with the `ACTIVE`, +//! `PENDING_UPDATE`, or `ERROR` provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 ClientAuthentication { + #[serde(rename = "MANDATORY")] + Mandatory, + #[serde(rename = "NONE")] + None, + #[serde(rename = "OPTIONAL")] + Optional, +} + +/// Defines attributes that are acceptable of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Listener<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A list of IPv4, IPv6 or mix of both CIDRs. The default is all allowed. + /// When a list of CIDRs is provided, the default switches to deny all. + /// + /// **New in version 2.12** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allowed_cidrs: Option>>, + + /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 + /// + /// **New in version 2.20** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + /// The TLS client authentication mode. One of the options `NONE`, + /// `OPTIONAL` or `MANDATORY`. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) client_authentication: Option, + + /// The ref of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format client CA certificate bundle for + /// `TERMINATED_HTTPS` listeners. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) client_ca_tls_container_ref: Option>, + + /// The URI of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format CA revocation list file for + /// `TERMINATED_HTTPS` listeners. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) client_crl_container_ref: Option>, + + /// The maximum number of connections permitted for this listener. Default + /// value is -1 which represents infinite connections or a default value + /// defined by the provider driver. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) connection_limit: Option, + + /// The ID of the pool used by the listener if no L7 policies match. The + /// pool has some restrictions. See + /// [Protocol Combinations (Listener/Pool)](#valid-protocol). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_pool_id: Option>, + + /// The URI of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PKCS12 format certificate/key bundle for + /// `TERMINATED_HTTPS` listeners. DEPRECATED: A secret container of type + /// “certificate” containing the certificate and key for `TERMINATED_HTTPS` + /// listeners. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_tls_container_ref: Option>, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines whether the `includeSubDomains` directive should be added to + /// the Strict-Transport-Security HTTP response header. This requires + /// setting the `hsts_max_age` option as well in order to become effective. + /// + /// **New in version 2.27** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_include_subdomains: Option, + + /// The value of the `max_age` directive for the Strict-Transport-Security + /// HTTP response header. Setting this enables HTTP Strict Transport + /// Security (HSTS) for the TLS-terminated listener. + /// + /// **New in version 2.27** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_max_age: Option, + + /// Defines whether the `preload` directive should be added to the + /// Strict-Transport-Security HTTP response header. This requires setting + /// the `hsts_max_age` option as well in order to become effective. + /// + /// **New in version 2.27** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_preload: Option, + + /// A dictionary of optional headers to insert into the request before it + /// is sent to the backend `member`. See + /// [Supported HTTP Header Insertions](#header-insertions). Both keys and + /// values are always specified as strings. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_insert_headers"))] + pub(crate) insert_headers: Option, Cow<'a, str>>>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of URIs to the + /// [key manager service](https://docs.openstack.org/barbican/latest/) + /// secrets containing PKCS12 format certificate/key bundles for + /// `TERMINATED_HTTPS` listeners. (DEPRECATED) Secret containers of type + /// “certificate” containing the certificates and keys for + /// `TERMINATED_HTTPS` listeners. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) sni_container_refs: Option>>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// Frontend client inactivity timeout in milliseconds. Default: 50000. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_client_data: Option, + + /// Backend member connection timeout in milliseconds. Default: 5000. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_member_connect: Option, + + /// Backend member inactivity timeout in milliseconds. Default: 50000. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_member_data: Option, + + /// Time, in milliseconds, to wait for additional TCP packets for content + /// inspection. Default: 0. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_tcp_inspect: Option, + + /// List of ciphers in OpenSSL format (colon-separated). See + /// + /// + /// **New in version 2.15** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, + /// TLSv1.1, TLSv1.2, TLSv1.3 + /// + /// **New in version 2.17** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +impl<'a> ListenerBuilder<'a> { + /// A dictionary of optional headers to insert into the request before it + /// is sent to the backend `member`. See + /// [Supported HTTP Header Insertions](#header-insertions). Both keys and + /// values are always specified as strings. + pub fn insert_headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.insert_headers + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines attributes that are acceptable of a PUT request. + #[builder(setter(into))] + pub(crate) listener: Listener<'a>, + + /// listener_id parameter for /v2/lbaas/listeners/{listener_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<'a> RequestBuilder<'a> { + /// Add a single header to the Listener. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/listeners/{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("listener", serde_json::to_value(&self.listener)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("listener".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .listener(ListenerBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .listener(ListenerBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "listener" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/listeners/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listener": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .listener(ListenerBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/listeners/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "listener": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .listener(ListenerBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/listener/stats.rs b/sdk/load-balancer/src/v2/listener/stats.rs new file mode 100644 index 000000000..43b28fadb --- /dev/null +++ b/sdk/load-balancer/src/v2/listener/stats.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows the current statistics for a listener. +//! +//! This operation returns the statistics of a listener object identified by +//! listener_id. +//! +//! If you are not an administrative user and the parent load balancer does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// listener_id parameter for /v2/lbaas/listeners/{listener_id}/stats 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<'a> RequestBuilder<'a> { + /// Add a single header to the Listener. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/listeners/{id}/stats", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("stats".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "stats" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/listeners/{id}/stats", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stats": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/listeners/{id}/stats", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stats": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer.rs b/sdk/load-balancer/src/v2/loadbalancer.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/loadbalancer.rs rename to sdk/load-balancer/src/v2/loadbalancer.rs diff --git a/sdk/load-balancer/src/v2/loadbalancer/create.rs b/sdk/load-balancer/src/v2/loadbalancer/create.rs new file mode 100644 index 000000000..9506388f4 --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/create.rs @@ -0,0 +1,1288 @@ +// 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`. + +//! Creates a load balancer. +//! +//! This operation provisions a new load balancer by using the configuration +//! that you define in the request object. After the API validates the request +//! and starts the provisioning process, the API returns a response object that +//! contains a unique ID and the status of provisioning the load balancer. +//! +//! In the response, the load balancer [provisioning status](#prov-status) is +//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. +//! +//! If the status is `PENDING_CREATE`, issue GET +//! `/v2/lbaas/loadbalancers/{loadbalancer_id}` to view the progress of the +//! provisioning operation. When the load balancer status changes to `ACTIVE`, +//! the load balancer is successfully provisioned and is ready for further +//! configuration. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! Administrative users can specify a project ID that is different than their +//! own to create load balancers for other projects. +//! +//! An optional `flavor_id` attribute can be used to create the load balancer +//! using a pre-configured octavia flavor. Flavors are created by the operator +//! to allow custom load balancer configurations, such as allocating more +//! memory for the load balancer. +//! +//! An optional `vip_qos_policy_id` attribute from Neutron can be used to apply +//! QoS policies on a loadbalancer VIP, also could pass a ‘null’ value to +//! remove QoS policies. +//! +//! You can also specify the `provider` attribute when you create a load +//! balancer. The `provider` attribute specifies which backend should be used +//! to create the load balancer. This could be the default provider (`octavia`) +//! or a vendor supplied `provider` if one has been installed. Setting both a +//! flavor_id and a provider will result in a conflict error if the provider +//! does not match the provider of the configured flavor profiles. +//! +//! Specifying a Virtual IP (VIP) is mandatory. There are three ways to specify +//! a VIP network for the load balancer: +//! +//! Additional VIPs may also be specified in the `additional_vips` field, by +//! providing a list of JSON objects containing a `subnet_id` and optionally an +//! `ip_address`. All additional subnets must be part of the same network as +//! the primary VIP. +//! +//! An optional `vip_sg_ids` attribute can be used to set custom Neutron +//! Security Groups that are applied on the VIP port of the Load Balancer. When +//! this option is used, Octavia does not manage the security of the Listeners, +//! the user must set Security Group Rules to allow the network traffic on the +//! VIP port. `vip_sg_ids` are incompatible with SR-IOV load balancer and +//! cannot be set if the load balancer has a listener that uses +//! `allowed_cidrs`. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// Type for additional vips +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AdditionalVips<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_id: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) subnet_id: Cow<'a, str>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum ClientAuthentication { + #[serde(rename = "MANDATORY")] + Mandatory, + #[serde(rename = "NONE")] + None, + #[serde(rename = "OPTIONAL")] + Optional, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HttpMethod { + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "PATCH")] + Patch, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "TRACE")] + Trace, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HealthmonitorType { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PING")] + Ping, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TLS-HELLO")] + TlsHello, + #[serde(rename = "UDP-CONNECT")] + UdpConnect, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Healthmonitor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) delay: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) max_retries: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) timeout: i32, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: HealthmonitorType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum LbAlgorithm { + #[serde(rename = "LEAST_CONNECTIONS")] + LeastConnections, + #[serde(rename = "ROUND_ROBIN")] + RoundRobin, + #[serde(rename = "SOURCE_IP")] + SourceIp, + #[serde(rename = "SOURCE_IP_PORT")] + SourceIpPort, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Members<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) address: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) backup: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_address: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_port: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_port: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) request_sriov: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) weight: Option, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum DefaultPoolProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROXY")] + Proxy, + #[serde(rename = "PROXYV2")] + Proxyv2, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum SessionPersistenceType { + #[serde(rename = "APP_COOKIE")] + AppCookie, + #[serde(rename = "HTTP_COOKIE")] + HttpCookie, + #[serde(rename = "SOURCE_IP")] + SourceIp, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SessionPersistence<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cookie_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_granularity: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_timeout: Option, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: SessionPersistenceType, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct DefaultPool<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ca_tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) crl_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) healthmonitor: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) lb_algorithm: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) members: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) session_persistence: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_enabled: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Action { + #[serde(rename = "REDIRECT_PREFIX")] + RedirectPrefix, + #[serde(rename = "REDIRECT_TO_POOL")] + RedirectToPool, + #[serde(rename = "REDIRECT_TO_URL")] + RedirectToUrl, + #[serde(rename = "REJECT")] + Reject, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum RedirectPoolHealthmonitorType { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PING")] + Ping, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TLS-HELLO")] + TlsHello, + #[serde(rename = "UDP-CONNECT")] + UdpConnect, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RedirectPoolHealthmonitor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) delay: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) max_retries: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) timeout: i32, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: RedirectPoolHealthmonitorType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum RedirectPoolProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROXY")] + Proxy, + #[serde(rename = "PROXYV2")] + Proxyv2, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "APP_COOKIE")] + AppCookie, + #[serde(rename = "HTTP_COOKIE")] + HttpCookie, + #[serde(rename = "SOURCE_IP")] + SourceIp, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RedirectPool<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ca_tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) crl_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) healthmonitor: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) lb_algorithm: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) members: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) session_persistence: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_enabled: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum CompareType { + #[serde(rename = "CONTAINS")] + Contains, + #[serde(rename = "ENDS_WITH")] + EndsWith, + #[serde(rename = "EQUAL_TO")] + EqualTo, + #[serde(rename = "REGEX")] + Regex, + #[serde(rename = "STARTS_WITH")] + StartsWith, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum RulesType { + #[serde(rename = "COOKIE")] + Cookie, + #[serde(rename = "FILE_TYPE")] + FileType, + #[serde(rename = "HEADER")] + Header, + #[serde(rename = "HOST_NAME")] + HostName, + #[serde(rename = "PATH")] + Path, + #[serde(rename = "SSL_CONN_HAS_CERT")] + SslConnHasCert, + #[serde(rename = "SSL_DN_FIELD")] + SslDnField, + #[serde(rename = "SSL_VERIFY_RESULT")] + SslVerifyResult, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Rules<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder()] + pub(crate) compare_type: CompareType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) invert: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) key: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: RulesType, + + #[serde()] + #[builder(setter(into))] + pub(crate) value: Cow<'a, str>, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct L7policies<'a> { + #[serde()] + #[builder()] + pub(crate) action: Action, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) position: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_http_code: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_pool: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) redirect_url: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rules: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum ListenersProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROMETHEUS")] + Prometheus, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TERMINATED_HTTPS")] + TerminatedHttps, + #[serde(rename = "UDP")] + Udp, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Listeners<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allowed_cidrs: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) client_authentication: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) client_ca_tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) client_crl_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) connection_limit: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_pool: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_pool_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_include_subdomains: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_max_age: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) hsts_preload: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_insert_headers"))] + pub(crate) insert_headers: Option, Cow<'a, str>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) l7policies: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde()] + #[builder()] + pub(crate) protocol: ListenersProtocol, + + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_port: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) sni_container_refs: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_client_data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_member_connect: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_member_data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) timeout_tcp_inspect: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +impl<'a> ListenersBuilder<'a> { + pub fn insert_headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.insert_headers + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum PoolsHealthmonitorType { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PING")] + Ping, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TLS-HELLO")] + TlsHello, + #[serde(rename = "UDP-CONNECT")] + UdpConnect, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PoolsHealthmonitor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) delay: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) max_retries: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) timeout: i32, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: PoolsHealthmonitorType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum PoolsProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROXY")] + Proxy, + #[serde(rename = "PROXYV2")] + Proxyv2, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Pools<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ca_tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) crl_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) healthmonitor: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) lb_algorithm: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) members: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) session_persistence: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_container_ref: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_enabled: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +/// A load balancer object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Loadbalancer<'a> { + /// A list of JSON objects defining “additional VIPs”. The format for these + /// is `{"subnet_id": , "ip_address": }`, where the + /// `subnet_id` field is mandatory and the `ip_address` field is optional. + /// Additional VIP subnets must all belong to the same network as the + /// primary VIP. + /// + /// **New in version 2.26** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) additional_vips: Option>>, + + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// An availability zone name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The ID of the flavor. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) flavor_id: Option>, + + /// The associated listener IDs, if any. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) listeners: Option>>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) pools: Option>>, + + /// The ID of the project owning this resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// Provider name for the load balancer. Default is `octavia`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) provider: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The IP address of the Virtual IP (VIP). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_address: Option>, + + /// The ID of the network for the Virtual IP (VIP). One of + /// `vip_network_id`, `vip_port_id`, or `vip_subnet_id` must be specified. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_network_id: Option>, + + /// The ID of the Virtual IP (VIP) port. One of `vip_network_id`, + /// `vip_port_id`, or `vip_subnet_id` must be specified. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_port_id: Option>, + + /// The ID of the QoS Policy which will apply to the Virtual IP (VIP). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_qos_policy_id: Option>, + + /// The list of Security Group IDs of the Virtual IP (VIP) port of the Load + /// Balancer. + /// + /// **New in version 2.29** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_sg_ids: Option>>, + + /// The ID of the subnet for the Virtual IP (VIP). One of `vip_network_id`, + /// `vip_port_id`, or `vip_subnet_id` must be specified. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_subnet_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A load balancer object. + #[builder(setter(into))] + pub(crate) loadbalancer: Loadbalancer<'a>, + + #[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 Loadbalancer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/loadbalancers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("loadbalancer", serde_json::to_value(&self.loadbalancer)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("loadbalancer".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "loadbalancer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/loadbalancers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancer": {} })); + }); + + let endpoint = Request::builder() + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/loadbalancers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancer": {} })); + }); + + let endpoint = Request::builder() + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/loadbalancer/delete.rs b/sdk/load-balancer/src/v2/loadbalancer/delete.rs new file mode 100644 index 000000000..a1c1f121b --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/delete.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Removes a load balancer and its associated configuration from the project. +//! +//! The optional parameter `cascade` when defined as `true` will delete all +//! child objects of the load balancer. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// If true will delete all child objects of the load balancer. + #[builder(default)] + cascade: Option, + + /// loadbalancer_id parameter for /v2/lbaas/loadbalancers/{loadbalancer_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<'a> RequestBuilder<'a> { + /// Add a single header to the Loadbalancer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/loadbalancers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("cascade", self.cascade); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/loadbalancers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/loadbalancers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/loadbalancer/failover.rs b/sdk/load-balancer/src/v2/loadbalancer/failover.rs new file mode 100644 index 000000000..42cf51f41 --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/failover.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Performs a failover of a load balancer. +//! +//! This operation is only available to users with load balancer administrative +//! rights. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// loadbalancer_id parameter for + /// /v2/lbaas/loadbalancers/{loadbalancer_id}/failover 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<'a> RequestBuilder<'a> { + /// Add a single header to the Loadbalancer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/loadbalancers/{id}/failover", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/loadbalancers/{id}/failover", 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/loadbalancers/{id}/failover", 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/loadbalancer/find.rs b/sdk/load-balancer/src/v2/loadbalancer/find.rs new file mode 100644 index 000000000..df83e14c1 --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::loadbalancer::{get as Get, list as List}; + +/// Find for loadbalancer 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/loadbalancer/get.rs b/sdk/load-balancer/src/v2/loadbalancer/get.rs new file mode 100644 index 000000000..d095b6a2f --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows the details of a load balancer. +//! +//! If you are not an administrative user and the load balancer object does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// loadbalancer_id parameter for /v2/lbaas/loadbalancers/{loadbalancer_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<'a> RequestBuilder<'a> { + /// Add a single header to the Loadbalancer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/loadbalancers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("loadbalancer".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "loadbalancer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/loadbalancers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancer": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/loadbalancers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/loadbalancer/list.rs b/sdk/load-balancer/src/v2/loadbalancer/list.rs new file mode 100644 index 000000000..0a0577ad8 --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/list.rs @@ -0,0 +1,310 @@ +// 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`. + +//! Lists all load balancers for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list load balancers for other projects. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An availability zone name. + #[builder(default, setter(into))] + availability_zone: Option>, + + /// The UTC date and timestamp when the resource was created. + #[builder(default, setter(into))] + created_at: Option>, + + /// A human-readable description for the resource. + #[builder(default, setter(into))] + description: Option>, + + /// The ID of the flavor. + #[builder(default, setter(into))] + flavor_id: Option>, + + /// The ID of the resource + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + /// Human-readable name of the resource. + #[builder(default, setter(into))] + name: Option>, + + /// Return the list of entities that do not have one or more of the given + /// tags. + #[builder(default, setter(into))] + not_tags: Option>, + + /// Return the list of entities that do not have at least one of the given + /// tags. + #[builder(default, setter(into))] + not_tags_any: Option>, + + /// The operating status of the resource. + #[builder(default, setter(into))] + operating_status: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + /// The ID of the project owning this resource. + #[builder(default, setter(into))] + project_id: Option>, + + /// Provider name for the load balancer. + #[builder(default, setter(into))] + provider: Option>, + + /// The provisioning status of the resource. + #[builder(default, setter(into))] + provisioning_status: Option>, + + /// Return the list of entities that have this tag or tags. + #[builder(default, setter(into))] + tags: Option>, + + /// Return the list of entities that have one or more of the given tags. + #[builder(default, setter(into))] + tags_any: Option>, + + /// The UTC date and timestamp when the resource was last updated. + #[builder(default, setter(into))] + updated_at: Option>, + + /// The IP address of the Virtual IP (VIP). + #[builder(default, setter(into))] + vip_address: Option>, + + /// The ID of the network for the Virtual IP (VIP). + #[builder(default, setter(into))] + vip_network_id: Option>, + + /// The ID of the Virtual IP (VIP) port. + #[builder(default, setter(into))] + vip_port_id: Option>, + + /// The ID of the QoS Policy which will apply to the Virtual IP (VIP). + #[builder(default, setter(into))] + vip_qos_policy_id: Option>, + + /// The ID of the subnet for the Virtual IP (VIP). + #[builder(default, setter(into))] + vip_subnet_id: 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> { + /// Add a single header to the Loadbalancer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/loadbalancers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("availability_zone", self.availability_zone.as_ref()); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("flavor_id", self.flavor_id.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("operating_status", self.operating_status.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("provider", self.provider.as_ref()); + params.push_opt("provisioning_status", self.provisioning_status.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + params.push_opt("vip_address", self.vip_address.as_ref()); + params.push_opt("vip_network_id", self.vip_network_id.as_ref()); + params.push_opt("vip_port_id", self.vip_port_id.as_ref()); + params.push_opt("vip_qos_policy_id", self.vip_qos_policy_id.as_ref()); + params.push_opt("vip_subnet_id", self.vip_subnet_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("loadbalancers".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "loadbalancers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/loadbalancers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/loadbalancers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/loadbalancer/set.rs b/sdk/load-balancer/src/v2/loadbalancer/set.rs new file mode 100644 index 000000000..b57ebbbfa --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/set.rs @@ -0,0 +1,258 @@ +// 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`. + +//! Updates a load balancer. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the update, check that the load balancer provisioning +//! status is `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation +//! to poll the load balancer object for changes. +//! +//! This operation returns the updated load balancer object with the `ACTIVE`, +//! `PENDING_UPDATE`, or `ERROR` provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A load balancer object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Loadbalancer<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// The ID of the QoS Policy which will apply to the Virtual IP (VIP). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_qos_policy_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vip_sg_ids: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A load balancer object. + #[builder(setter(into))] + pub(crate) loadbalancer: Loadbalancer<'a>, + + /// loadbalancer_id parameter for /v2/lbaas/loadbalancers/{loadbalancer_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<'a> RequestBuilder<'a> { + /// Add a single header to the Loadbalancer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/loadbalancers/{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("loadbalancer", serde_json::to_value(&self.loadbalancer)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("loadbalancer".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "loadbalancer" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/loadbalancers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/loadbalancers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loadbalancer": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .loadbalancer(LoadbalancerBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/loadbalancer/stats.rs b/sdk/load-balancer/src/v2/loadbalancer/stats.rs new file mode 100644 index 000000000..2931570c0 --- /dev/null +++ b/sdk/load-balancer/src/v2/loadbalancer/stats.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Shows the current statistics for a load balancer. +//! +//! This operation returns the statistics of a load balancer object identified +//! by loadbalancer_id. +//! +//! If you are not an administrative user and the load balancer object does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// loadbalancer_id parameter for + /// /v2/lbaas/loadbalancers/{loadbalancer_id}/stats 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<'a> RequestBuilder<'a> { + /// Add a single header to the Loadbalancer. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/loadbalancers/{id}/stats", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("stats".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "stats" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/loadbalancers/{id}/stats", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stats": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/loadbalancers/{id}/stats", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "stats": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/status.rs b/sdk/load-balancer/src/v2/loadbalancer/status.rs similarity index 98% rename from openstack_sdk/src/api/load_balancer/v2/loadbalancer/status.rs rename to sdk/load-balancer/src/v2/loadbalancer/status.rs index 2d89e895c..523aed01b 100644 --- a/openstack_sdk/src/api/load_balancer/v2/loadbalancer/status.rs +++ b/sdk/load-balancer/src/v2/loadbalancer/status.rs @@ -130,7 +130,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/load_balancer/v2/octavia.rs b/sdk/load-balancer/src/v2/octavia.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/octavia.rs rename to sdk/load-balancer/src/v2/octavia.rs diff --git a/sdk/load-balancer/src/v2/octavia/get.rs b/sdk/load-balancer/src/v2/octavia/get.rs new file mode 100644 index 000000000..cfebeaa20 --- /dev/null +++ b/sdk/load-balancer/src/v2/octavia/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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 Octavia. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "octavia".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/octavia".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/octavia".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool.rs b/sdk/load-balancer/src/v2/pool.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/pool.rs rename to sdk/load-balancer/src/v2/pool.rs diff --git a/sdk/load-balancer/src/v2/pool/create.rs b/sdk/load-balancer/src/v2/pool/create.rs new file mode 100644 index 000000000..8e835635f --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/create.rs @@ -0,0 +1,614 @@ +// 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`. + +//! Creates a pool for a load balancer. +//! +//! The pool defines how requests should be balanced across the backend member +//! servers. +//! +//! This operation provisions a pool by using the configuration that you define +//! in the request object. After the API validates the request and starts the +//! provisioning process, the API returns a response object, which contains a +//! unique ID. +//! +//! In the response, the pool [provisioning status](#prov-status) is `ACTIVE`, +//! `PENDING_CREATE`, or `ERROR`. +//! +//! If the status is `PENDING_CREATE`, issue GET `/v2/lbaas/pools/{pool_id}` to +//! view the progress of the provisioning operation. When the pool status +//! changes to `ACTIVE`, the pool is successfully provisioned and is ready for +//! further configuration. +//! +//! At a minimum, you must specify these pool attributes: +//! +//! Some attributes receive default values if you omit them from the request: +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! Specifying a project_id is deprecated. The pool will inherit the project_id +//! of the parent load balancer. +//! +//! You can configure all documented features of the pool at creation time by +//! specifying the additional elements or attributes in the request. +//! +//! To create a pool, the parent load balancer must have an `ACTIVE` +//! provisioning status. +//! +//! `SOURCE_IP_PORT` algorithm is available from version 2.13. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HttpMethod { + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "PATCH")] + Patch, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "TRACE")] + Trace, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum HealthmonitorType { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PING")] + Ping, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "TLS-HELLO")] + TlsHello, + #[serde(rename = "UDP-CONNECT")] + UdpConnect, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Healthmonitor<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) delay: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) domain_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) expected_codes: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) http_method: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) http_version: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) max_retries: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_retries_down: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) timeout: i32, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: HealthmonitorType, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) url_path: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum LbAlgorithm { + #[serde(rename = "LEAST_CONNECTIONS")] + LeastConnections, + #[serde(rename = "ROUND_ROBIN")] + RoundRobin, + #[serde(rename = "SOURCE_IP")] + SourceIp, + #[serde(rename = "SOURCE_IP_PORT")] + SourceIpPort, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Members<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) address: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) backup: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_address: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_port: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_port: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) request_sriov: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) weight: Option, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Protocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "HTTPS")] + Https, + #[serde(rename = "PROXY")] + Proxy, + #[serde(rename = "PROXYV2")] + Proxyv2, + #[serde(rename = "SCTP")] + Sctp, + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum SessionPersistenceType { + #[serde(rename = "APP_COOKIE")] + AppCookie, + #[serde(rename = "HTTP_COOKIE")] + HttpCookie, + #[serde(rename = "SOURCE_IP")] + SourceIp, +} + +/// A JSON object specifying the session persistence for the pool or `null` for +/// no session persistence. See +/// [Pool Session Persistence](#session-persistence). Default is `null`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SessionPersistence<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cookie_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_granularity: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_timeout: Option, + + #[serde(rename = "type")] + #[builder()] + pub(crate) _type: SessionPersistenceType, +} + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Pool<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 + /// + /// **New in version 2.24** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + /// The reference of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format CA certificate bundle for `tls_enabled` + /// pools. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ca_tls_container_ref: Option>, + + /// The reference of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format CA revocation list file for + /// `tls_enabled` pools. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) crl_container_ref: Option>, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Defines mandatory and optional attributes of a POST request. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) healthmonitor: Option>, + + /// The load balancing algorithm for the pool. One of `LEAST_CONNECTIONS`, + /// `ROUND_ROBIN`, `SOURCE_IP`, or `SOURCE_IP_PORT`. + #[serde()] + #[builder()] + pub(crate) lb_algorithm: LbAlgorithm, + + /// The ID of the listener for the pool. Either `listener_id` or + /// `loadbalancer_id` must be specified. The listener has some + /// restrictions, See + /// [Protocol Combinations (Listener/Pool)](#valid-protocol). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) listener_id: Option>, + + /// The ID of the load balancer for the pool. Either `listener_id` or + /// `loadbalancer_id` must be specified. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) loadbalancer_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) members: Option>>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the project owning this resource. (deprecated) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The protocol for the resource. One of `HTTP`, `HTTPS`, `PROXY`, + /// `PROXYV2`, `SCTP`, `TCP`, or `UDP`. + #[serde()] + #[builder()] + pub(crate) protocol: Protocol, + + /// A JSON object specifying the session persistence for the pool or `null` + /// for no session persistence. See + /// [Pool Session Persistence](#session-persistence). Default is `null`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) session_persistence: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// List of ciphers in OpenSSL format (colon-separated). See + /// + /// + /// **New in version 2.15** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + /// The reference to the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PKCS12 format certificate/key bundle for + /// `tls_enabled` pools for TLS client authentication to the member + /// servers. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_container_ref: Option>, + + /// When `true` connections to backend member servers will use TLS + /// encryption. Default is `false`. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_enabled: Option, + + /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, + /// TLSv1.1, TLSv1.2, TLSv1.3 + /// + /// **New in version 2.17** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) pool: Pool<'a>, + + #[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 Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/pools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("pool", serde_json::to_value(&self.pool)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("pool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .pool( + PoolBuilder::default() + .lb_algorithm(LbAlgorithm::LeastConnections) + .protocol(Protocol::Http) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .pool( + PoolBuilder::default() + .lb_algorithm(LbAlgorithm::LeastConnections) + .protocol(Protocol::Http) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "pool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/pools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pool": {} })); + }); + + let endpoint = Request::builder() + .pool( + PoolBuilder::default() + .lb_algorithm(LbAlgorithm::LeastConnections) + .protocol(Protocol::Http) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/lbaas/pools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pool": {} })); + }); + + let endpoint = Request::builder() + .pool( + PoolBuilder::default() + .lb_algorithm(LbAlgorithm::LeastConnections) + .protocol(Protocol::Http) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/delete.rs b/sdk/load-balancer/src/v2/pool/delete.rs new file mode 100644 index 000000000..9555dbf03 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Removes a pool and its associated configuration from the load balancer. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// pool_id parameter for /v2/lbaas/pools/{pool_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<'a> RequestBuilder<'a> { + /// Add a single header to the Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/pools/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/pools/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/lbaas/pools/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/find.rs b/sdk/load-balancer/src/v2/pool/find.rs new file mode 100644 index 000000000..91a40f6b6 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::pool::{get as Get, list as List}; + +/// Find for pool 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/pool/get.rs b/sdk/load-balancer/src/v2/pool/get.rs new file mode 100644 index 000000000..a73d7e51c --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/get.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Shows the details of a pool. +//! +//! If you are not an administrative user and the parent load balancer does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// pool_id parameter for /v2/lbaas/pools/{pool_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<'a> RequestBuilder<'a> { + /// Add a single header to the Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("lbaas/pools/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("pool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "pool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/pools/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pool": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/lbaas/pools/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/list.rs b/sdk/load-balancer/src/v2/pool/list.rs new file mode 100644 index 000000000..50d0ac94a --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/list.rs @@ -0,0 +1,299 @@ +// 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`. + +//! Lists all pools for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list pools for other projects. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The administrative state of the resource + #[builder(default)] + admin_state_up: Option, + + /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 + #[builder(default, setter(into))] + alpn_protocols: Option>, + + /// The UTC date and timestamp when the resource was created. + #[builder(default, setter(into))] + created_at: Option>, + + /// A human-readable description for the resource. + #[builder(default, setter(into))] + description: Option>, + + /// The ID of the resource + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// The ID of the load balancer for the pool. + #[builder(default, setter(into))] + loadbalancer_id: Option>, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + /// Human-readable name of the resource. + #[builder(default, setter(into))] + name: Option>, + + /// Return the list of entities that do not have one or more of the given + /// tags. + #[builder(default, setter(into))] + not_tags: Option>, + + /// Return the list of entities that do not have at least one of the given + /// tags. + #[builder(default, setter(into))] + not_tags_any: Option>, + + /// The operating status of the resource. + #[builder(default, setter(into))] + operating_status: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + /// The ID of the project owning this resource. + #[builder(default, setter(into))] + project_id: Option>, + + /// The provisioning status of the resource. + #[builder(default, setter(into))] + provisioning_status: Option>, + + /// Return the list of entities that have this tag or tags. + #[builder(default, setter(into))] + tags: Option>, + + /// Return the list of entities that have one or more of the given tags. + #[builder(default, setter(into))] + tags_any: Option>, + + /// List of ciphers in OpenSSL format + #[builder(default, setter(into))] + tls_ciphers: Option>, + + #[builder(default)] + tls_enabled: Option, + + /// A list of TLS protocol versions. + #[builder(default, setter(into))] + tls_versions: Option>, + + /// The UTC date and timestamp when the resource was last updated. + #[builder(default, setter(into))] + 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<'a> RequestBuilder<'a> { + /// Add a single header to the Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/pools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("alpn_protocols", self.alpn_protocols.as_ref()); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("loadbalancer_id", self.loadbalancer_id.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("operating_status", self.operating_status.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("provisioning_status", self.provisioning_status.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tls_ciphers", self.tls_ciphers.as_ref()); + params.push_opt("tls_enabled", self.tls_enabled); + params.push_opt("tls_versions", self.tls_versions.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("pools".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "pools" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/pools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pools": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/pools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pools": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/pool/member.rs b/sdk/load-balancer/src/v2/pool/member.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/pool/member.rs rename to sdk/load-balancer/src/v2/pool/member.rs diff --git a/sdk/load-balancer/src/v2/pool/member/create.rs b/sdk/load-balancer/src/v2/pool/member/create.rs new file mode 100644 index 000000000..685a0238d --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/member/create.rs @@ -0,0 +1,368 @@ +// 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`. + +//! This operation provisions a member and adds it to a pool by using the +//! configuration that you define in the request object. After the API +//! validates the request and starts the provisioning process, it returns a +//! response object, which contains a unique ID. +//! +//! In the response, the member [provisioning status](#prov-status) is +//! `ACTIVE`, `PENDING_CREATE`, or `ERROR`. +//! +//! If the status is `PENDING_CREATE`, issue GET +//! `/v2/lbaas/pools/{pool_id}/members/{member_id}` to view the progress of the +//! provisioning operation. When the member status changes to `ACTIVE`, the +//! member is successfully provisioned and is ready for further configuration. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! At a minimum, you must specify these member attributes: +//! +//! Some attributes receive default values if you omit them from the request: +//! +//! If you omit the `subnet_id` parameter, the `vip_subnet_id` for the parent +//! load balancer will be used for the member subnet UUID. +//! +//! The member `address` does not necessarily need to be a member of the +//! `subnet_id` subnet. Members can be routable from the subnet specified +//! either via the default route or by using `host_routes` defined on the +//! subnet. +//! +//! Administrative users can specify a project ID that is different than their +//! own to create members for other projects. +//! +//! `monitor_address` and/or `monitor_port` can be used to have the health +//! monitor, if one is configured for the pool, connect to an alternate IP +//! address and port when executing a health check on the member. +//! +//! To create a member, the load balancer must have an `ACTIVE` provisioning +//! status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Member<'a> { + /// The IP address of the resource. + #[serde()] + #[builder(setter(into))] + pub(crate) address: Cow<'a, str>, + + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// Is the member a backup? Backup members only receive traffic when all + /// non-backup members are down. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) backup: Option, + + /// An alternate IP address used for health monitoring a backend member. + /// Default is `null` which monitors the member `address`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_address: Option>, + + /// An alternate protocol port used for health monitoring a backend member. + /// Default is `null` which monitors the member `protocol_port`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_port: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the project owning this resource. (deprecated) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The protocol port number for the resource. + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_port: i32, + + /// Request that an SR-IOV VF be used for the member network port. Defaults + /// to `false`. + /// + /// **New in version 2.29** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) request_sriov: Option, + + /// The subnet ID the member service is accessible from. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The weight of a member determines the portion of requests or + /// connections it services compared to the other members of the pool. For + /// example, a member with a weight of 10 receives five times as many + /// requests as a member with a weight of 2. A value of 0 means the member + /// does not receive new connections but continues to service existing + /// connections. A valid value is from `0` to `256`. Default is `1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) weight: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines mandatory and optional attributes of a POST request. + #[builder(setter(into))] + pub(crate) member: Member<'a>, + + /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API + #[builder(default, setter(into))] + pool_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "lbaas/pools/{pool_id}/members", + pool_id = self.pool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("member", serde_json::to_value(&self.member)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("member".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .member( + MemberBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .member( + MemberBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "member" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/lbaas/pools/{pool_id}/members", + pool_id = "pool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .pool_id("pool_id") + .member( + MemberBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/lbaas/pools/{pool_id}/members", + pool_id = "pool_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .pool_id("pool_id") + .member( + MemberBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/member/delete.rs b/sdk/load-balancer/src/v2/pool/member/delete.rs new file mode 100644 index 000000000..533a670f1 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/member/delete.rs @@ -0,0 +1,206 @@ +// 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`. + +//! Removes a member and its associated configuration from the pool. +//! +//! The API immediately purges any and all configuration data, depending on the +//! configuration settings. You cannot recover it. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// member_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API + #[builder(default, setter(into))] + pool_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/pools/{pool_id}/members/{id}", + id = self.id.as_ref(), + pool_id = self.pool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/lbaas/pools/{pool_id}/members/{id}", + id = "id", + pool_id = "pool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .pool_id("pool_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/lbaas/pools/{pool_id}/members/{id}", + id = "id", + pool_id = "pool_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") + .pool_id("pool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/member/find.rs b/sdk/load-balancer/src/v2/pool/member/find.rs new file mode 100644 index 000000000..0577e35d7 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/member/find.rs @@ -0,0 +1,96 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::pool::member::{get as Get, list as List}; + +/// Find for pool/member by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[builder(default, setter(into))] + pool_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 Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.pool_id(self.pool_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + let mut ep = List::Request::builder(); + ep.pool_id(self.pool_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/load-balancer/src/v2/pool/member/get.rs b/sdk/load-balancer/src/v2/pool/member/get.rs new file mode 100644 index 000000000..2eb32af86 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/member/get.rs @@ -0,0 +1,212 @@ +// 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`. + +//! Shows the details of a pool member. +//! +//! If you are not an administrative user and the parent load balancer does not +//! belong to your project, the service returns the HTTP `Forbidden (403)` +//! response code. +//! +//! This operation does not require a request body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// member_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API + #[builder(default, setter(into))] + pool_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/pools/{pool_id}/members/{id}", + id = self.id.as_ref(), + pool_id = self.pool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("member".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "member" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/lbaas/pools/{pool_id}/members/{id}", + id = "id", + pool_id = "pool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .pool_id("pool_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/lbaas/pools/{pool_id}/members/{id}", + id = "id", + pool_id = "pool_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .pool_id("pool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/member/list.rs b/sdk/load-balancer/src/v2/pool/member/list.rs new file mode 100644 index 000000000..1f8b949a1 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/member/list.rs @@ -0,0 +1,325 @@ +// 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`. + +//! Lists all members for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list members for other projects. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The IP address of the backend member server. + #[builder(default, setter(into))] + address: Option>, + + /// The administrative state of the resource + #[builder(default)] + admin_state_up: Option, + + /// Is the member a backup? + #[builder(default)] + backup: Option, + + /// The UTC date and timestamp when the resource was created. + #[builder(default, setter(into))] + created_at: Option>, + + /// A human-readable description for the resource. + #[builder(default, setter(into))] + description: Option>, + + /// The ID of the resource + #[builder(default, setter(into))] + id: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + /// An alternate IP address used for health monitoring a backend member. + #[builder(default, setter(into))] + monitor_address: Option>, + + /// An alternate protocol port used for health monitoring a backend member. + #[builder(default, setter(into))] + monitor_port: Option>, + + /// Human-readable name of the resource. + #[builder(default, setter(into))] + name: Option>, + + /// Return the list of entities that do not have one or more of the given + /// tags. + #[builder(default, setter(into))] + not_tags: Option>, + + /// Return the list of entities that do not have at least one of the given + /// tags. + #[builder(default, setter(into))] + not_tags_any: Option>, + + /// The operating status of the resource. + #[builder(default, setter(into))] + operating_status: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: Option, + + /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API + #[builder(default, setter(into))] + pool_id: Cow<'a, str>, + + /// The ID of the project owning this resource. + #[builder(default, setter(into))] + project_id: Option>, + + /// The protocol port number the backend member server is listening on. + #[builder(default)] + protocol_port: Option, + + /// The provisioning status of the resource. + #[builder(default, setter(into))] + provisioning_status: Option>, + + /// The subnet ID the member service is accessible from. + #[builder(default, setter(into))] + subnet_id: Option>, + + /// Return the list of entities that have this tag or tags. + #[builder(default, setter(into))] + tags: Option>, + + /// Return the list of entities that have one or more of the given tags. + #[builder(default, setter(into))] + tags_any: Option>, + + /// The UTC date and timestamp when the resource was last updated. + #[builder(default, setter(into))] + updated_at: Option>, + + /// The weight of a member determines the portion of requests or + /// connections it services compared to the other members of the pool. + #[builder(default)] + weight: 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> { + /// Add a single header to the Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/pools/{pool_id}/members", + pool_id = self.pool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("address", self.address.as_ref()); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("backup", self.backup); + params.push_opt("created_at", self.created_at.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("monitor_address", self.monitor_address.as_ref()); + params.push_opt("monitor_port", self.monitor_port.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("operating_status", self.operating_status.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("protocol_port", self.protocol_port); + params.push_opt("provisioning_status", self.provisioning_status.as_ref()); + params.push_opt("subnet_id", self.subnet_id.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("updated_at", self.updated_at.as_ref()); + params.push_opt("weight", self.weight); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("members".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "members" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/lbaas/pools/{pool_id}/members", + pool_id = "pool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "members": {} })); + }); + + let endpoint = Request::builder().pool_id("pool_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/lbaas/pools/{pool_id}/members", + pool_id = "pool_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "members": {} })); + }); + + let endpoint = Request::builder() + .pool_id("pool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/member/replace.rs b/sdk/load-balancer/src/v2/pool/member/replace.rs new file mode 100644 index 000000000..a37585143 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/member/replace.rs @@ -0,0 +1,347 @@ +// 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 the state of members for a pool in one API call. This may include +//! creating new members, deleting old members, and updating existing members. +//! Existing members are matched based on address/port combination. +//! +//! For example, assume a pool currently has two members. These members have +//! the following address/port combinations: ‘192.0.2.15:80’ and +//! ‘192.0.2.16:80’. Now assume a PUT request is made that includes members +//! with address/port combinations: ‘192.0.2.16:80’ and ‘192.0.2.17:80’. +//! +//! The member ‘192.0.2.15:80’ will be deleted, because it was not in the +//! request. +//! +//! The member ‘192.0.2.16:80’ will be updated to match the request data for +//! that member, because it was matched. +//! +//! The member ‘192.0.2.17:80’ will be created, because no such member existed. +//! +//! The optional parameter `additive_only` when defined as `true` will skip +//! deletions for members missing from the provided list. If this were set in +//! the above example, the member ‘192.0.2.15:80’ would have remained in the +//! pool. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the updates, check that the member provisioning statuses +//! are `ACTIVE` for new or updated members, and that any unspecified members +//! were correctly deleted. If the statuses are `PENDING_UPDATE` or +//! `PENDING_DELETE`, use GET to poll the member objects for changes. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines mandatory and optional attributes of a POST request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Members<'a> { + /// The IP address of the resource. + #[serde()] + #[builder(setter(into))] + pub(crate) address: Cow<'a, str>, + + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// Is the member a backup? Backup members only receive traffic when all + /// non-backup members are down. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) backup: Option, + + /// An alternate IP address used for health monitoring a backend member. + /// Default is `null` which monitors the member `address`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_address: Option>, + + /// An alternate protocol port used for health monitoring a backend member. + /// Default is `null` which monitors the member `protocol_port`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_port: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the project owning this resource. (deprecated) + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The protocol port number for the resource. + #[serde()] + #[builder(setter(into))] + pub(crate) protocol_port: i32, + + /// Request that an SR-IOV VF be used for the member network port. Defaults + /// to `false`. + /// + /// **New in version 2.29** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) request_sriov: Option, + + /// The subnet ID the member service is accessible from. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The weight of a member determines the portion of requests or + /// connections it services compared to the other members of the pool. For + /// example, a member with a weight of 10 receives five times as many + /// requests as a member with a weight of 2. A value of 0 means the member + /// does not receive new connections but continues to service existing + /// connections. A valid value is from `0` to `256`. Default is `1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) weight: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) members: Vec>, + + /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API + #[builder(default, setter(into))] + pool_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "lbaas/pools/{pool_id}/members", + pool_id = self.pool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("members", serde_json::to_value(&self.members)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("member".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .members(Vec::from([MembersBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap()])) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .members(Vec::from([MembersBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "member" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/lbaas/pools/{pool_id}/members", + pool_id = "pool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .pool_id("pool_id") + .members(Vec::from([MembersBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/lbaas/pools/{pool_id}/members", + pool_id = "pool_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .pool_id("pool_id") + .members(Vec::from([MembersBuilder::default() + .address("foo") + .protocol_port(123) + .build() + .unwrap()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/member/set.rs b/sdk/load-balancer/src/v2/pool/member/set.rs new file mode 100644 index 000000000..004b5b77d --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/member/set.rs @@ -0,0 +1,296 @@ +// 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 an existing member. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the update, check that the member provisioning status is +//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll +//! the member object for changes. +//! +//! Setting the member weight to `0` means that the member will not receive new +//! requests but will finish any existing connections. This “drains” the +//! backend member of active connections. +//! +//! This operation returns the updated member object with the `ACTIVE`, +//! `PENDING_UPDATE`, or `ERROR` provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Defines attributes that are acceptable of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Member<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// Is the member a backup? Backup members only receive traffic when all + /// non-backup members are down. + /// + /// **New in version 2.1** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) backup: Option, + + /// An alternate IP address used for health monitoring a backend member. + /// Default is `null` which monitors the member `address`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_address: Option>, + + /// An alternate protocol port used for health monitoring a backend member. + /// Default is `null` which monitors the member `protocol_port`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) monitor_port: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// The weight of a member determines the portion of requests or + /// connections it services compared to the other members of the pool. For + /// example, a member with a weight of 10 receives five times as many + /// requests as a member with a weight of 2. A value of 0 means the member + /// does not receive new connections but continues to service existing + /// connections. A valid value is from `0` to `256`. Default is `1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) weight: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines attributes that are acceptable of a PUT request. + #[builder(setter(into))] + pub(crate) member: Member<'a>, + + /// member_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// pool_id parameter for /v2/lbaas/pools/{pool_id}/members/{member_id} API + #[builder(default, setter(into))] + pool_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 Member. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "lbaas/pools/{pool_id}/members/{id}", + id = self.id.as_ref(), + pool_id = self.pool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("member", serde_json::to_value(&self.member)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("member".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .member(MemberBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .member(MemberBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "member" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/lbaas/pools/{pool_id}/members/{id}", + id = "id", + pool_id = "pool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .pool_id("pool_id") + .member(MemberBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/lbaas/pools/{pool_id}/members/{id}", + id = "id", + pool_id = "pool_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "member": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .pool_id("pool_id") + .member(MemberBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/pool/set.rs b/sdk/load-balancer/src/v2/pool/set.rs new file mode 100644 index 000000000..e9d695d22 --- /dev/null +++ b/sdk/load-balancer/src/v2/pool/set.rs @@ -0,0 +1,366 @@ +// 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 an existing pool. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. To confirm the update, check that the pool provisioning status is +//! `ACTIVE`. If the status is `PENDING_UPDATE`, use a GET operation to poll +//! the pool object for changes. +//! +//! This operation returns the updated pool object with the `ACTIVE`, +//! `PENDING_UPDATE`, or `ERROR` provisioning status. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum LbAlgorithm { + #[serde(rename = "LEAST_CONNECTIONS")] + LeastConnections, + #[serde(rename = "ROUND_ROBIN")] + RoundRobin, + #[serde(rename = "SOURCE_IP")] + SourceIp, + #[serde(rename = "SOURCE_IP_PORT")] + SourceIpPort, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "APP_COOKIE")] + AppCookie, + #[serde(rename = "HTTP_COOKIE")] + HttpCookie, + #[serde(rename = "SOURCE_IP")] + SourceIp, +} + +/// A JSON object specifying the session persistence for the pool or `null` for +/// no session persistence. See +/// [Pool Session Persistence](#session-persistence). Default is `null`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SessionPersistence<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cookie_name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_granularity: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) persistence_timeout: Option, + + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +/// Defines attributes that are acceptable of a PUT request. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Pool<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A list of ALPN protocols. Available protocols: http/1.0, http/1.1, h2 + /// + /// **New in version 2.24** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) alpn_protocols: Option>>, + + /// The reference of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format CA certificate bundle for `tls_enabled` + /// pools. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ca_tls_container_ref: Option>, + + /// The reference of the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PEM format CA revocation list file for + /// `tls_enabled` pools. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) crl_container_ref: Option>, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The load balancing algorithm for the pool. One of `LEAST_CONNECTIONS`, + /// `ROUND_ROBIN`, or `SOURCE_IP`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) lb_algorithm: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A JSON object specifying the session persistence for the pool or `null` + /// for no session persistence. See + /// [Pool Session Persistence](#session-persistence). Default is `null`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) session_persistence: Option>, + + /// A list of simple strings assigned to the resource. + /// + /// **New in version 2.5** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// List of ciphers in OpenSSL format (colon-separated). See + /// + /// + /// **New in version 2.15** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_ciphers: Option>, + + /// The reference to the + /// [key manager service](https://docs.openstack.org/castellan/latest/) + /// secret containing a PKCS12 format certificate/key bundle for + /// `tls_enabled` pools for TLS client authentication to the member + /// servers. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_container_ref: Option>, + + /// When `true` connections to backend member servers will use TLS + /// encryption. Default is `false`. + /// + /// **New in version 2.8** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_enabled: Option, + + /// A list of TLS protocol versions. Available versions: SSLv3, TLSv1, + /// TLSv1.1, TLSv1.2, TLSv1.3 + /// + /// **New in version 2.17** + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tls_versions: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Defines attributes that are acceptable of a PUT request. + #[builder(setter(into))] + pub(crate) pool: Pool<'a>, + + /// pool_id parameter for /v2/lbaas/pools/{pool_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<'a> RequestBuilder<'a> { + /// Add a single header to the Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("lbaas/pools/{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("pool", serde_json::to_value(&self.pool)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("pool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .pool(PoolBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .pool(PoolBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "pool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/pools/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .pool(PoolBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/lbaas/pools/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "pool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .pool(PoolBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/provider.rs b/sdk/load-balancer/src/v2/provider.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/provider.rs rename to sdk/load-balancer/src/v2/provider.rs diff --git a/openstack_sdk/src/api/load_balancer/v2/provider/availability_zone_capability.rs b/sdk/load-balancer/src/v2/provider/availability_zone_capability.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/provider/availability_zone_capability.rs rename to sdk/load-balancer/src/v2/provider/availability_zone_capability.rs diff --git a/sdk/load-balancer/src/v2/provider/availability_zone_capability/list.rs b/sdk/load-balancer/src/v2/provider/availability_zone_capability/list.rs new file mode 100644 index 000000000..0d683f172 --- /dev/null +++ b/sdk/load-balancer/src/v2/provider/availability_zone_capability/list.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Shows the provider driver availability zone capabilities. These are the +//! features of the provider driver that can be configured in an Octavia +//! availability zone. This API returns a list of dictionaries with the name +//! and description of each availability zone capability of the provider. +//! +//! The list might be empty and a provider driver may not implement this +//! feature. +//! +//! **New in version 2.14** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// provider parameter for + /// /v2/lbaas/providers/{provider}/availability_zone_capabilities API + #[builder(default, setter(into))] + provider: 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 Availability_Zone_Capability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/providers/{provider}/availability_zone_capabilities", + provider = self.provider.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("availability_zone_capabilities".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availability_zone_capabilities" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/lbaas/providers/{provider}/availability_zone_capabilities", + provider = "provider", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_capabilities": {} })); + }); + + let endpoint = Request::builder().provider("provider").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/lbaas/providers/{provider}/availability_zone_capabilities", + provider = "provider", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zone_capabilities": {} })); + }); + + let endpoint = Request::builder() + .provider("provider") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/provider/flavor_capability.rs b/sdk/load-balancer/src/v2/provider/flavor_capability.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/provider/flavor_capability.rs rename to sdk/load-balancer/src/v2/provider/flavor_capability.rs diff --git a/sdk/load-balancer/src/v2/provider/flavor_capability/list.rs b/sdk/load-balancer/src/v2/provider/flavor_capability/list.rs new file mode 100644 index 000000000..8d6db88fd --- /dev/null +++ b/sdk/load-balancer/src/v2/provider/flavor_capability/list.rs @@ -0,0 +1,202 @@ +// 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`. + +//! Shows the provider driver flavor capabilities. These are the features of +//! the provider driver that can be configured in an Octavia flavor. This API +//! returns a list of dictionaries with the name and description of each flavor +//! capability of the provider. +//! +//! The list might be empty and a provider driver may not implement this +//! feature. +//! +//! **New in version 2.6** +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// provider parameter for + /// /v2/lbaas/providers/{provider}/flavor_capabilities API + #[builder(default, setter(into))] + provider: 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 Flavor_Capability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/providers/{provider}/flavor_capabilities", + provider = self.provider.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("flavor_capabilities".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavor_capabilities" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/lbaas/providers/{provider}/flavor_capabilities", + provider = "provider", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor_capabilities": {} })); + }); + + let endpoint = Request::builder().provider("provider").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/lbaas/providers/{provider}/flavor_capabilities", + provider = "provider", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor_capabilities": {} })); + }); + + let endpoint = Request::builder() + .provider("provider") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/provider/list.rs b/sdk/load-balancer/src/v2/provider/list.rs new file mode 100644 index 000000000..5ca1fb2b8 --- /dev/null +++ b/sdk/load-balancer/src/v2/provider/list.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`. + +//! Lists all enabled provider drivers. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default, setter(into))] + description: Option>, + + /// Page size + #[builder(default)] + limit: Option, + + /// ID of the last item in the previous list + #[builder(default, setter(into))] + marker: Option>, + + #[builder(default, setter(into))] + name: Option>, + + /// The page direction. + #[builder(default)] + page_reverse: 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> { + /// Add a single header to the Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("description", self.description.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("providers".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "providers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "providers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "providers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/quota.rs b/sdk/load-balancer/src/v2/quota.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/quota.rs rename to sdk/load-balancer/src/v2/quota.rs diff --git a/sdk/load-balancer/src/v2/quota/delete.rs b/sdk/load-balancer/src/v2/quota/delete.rs new file mode 100644 index 000000000..4d3eb230c --- /dev/null +++ b/sdk/load-balancer/src/v2/quota/delete.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Resets a project quota to use the deployment default quota. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v2/lbaas/quotas/{project_id} API + #[builder(default, setter(into))] + project_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 Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/quotas/{project_id}", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/lbaas/quotas/{project_id}", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/lbaas/quotas/{project_id}", + project_id = "project_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() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/quota/get.rs b/sdk/load-balancer/src/v2/quota/get.rs new file mode 100644 index 000000000..a04f330be --- /dev/null +++ b/sdk/load-balancer/src/v2/quota/get.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 the quota for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to show quota for other projects. +//! +//! A quota of `-1` means the quota is unlimited. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// project_id parameter for /v2/lbaas/quotas/{project_id} API + #[builder(default, setter(into))] + project_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 Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "lbaas/quotas/{project_id}", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("quota".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/lbaas/quotas/{project_id}", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + let endpoint = Request::builder().project_id("project_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/lbaas/quotas/{project_id}", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/quota/list.rs b/sdk/load-balancer/src/v2/quota/list.rs new file mode 100644 index 000000000..535a748b9 --- /dev/null +++ b/sdk/load-balancer/src/v2/quota/list.rs @@ -0,0 +1,192 @@ +// 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`. + +//! Lists all quotas for the project. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. Additionally, you can filter results by using query +//! string parameters. For information, see +//! [Filtering and column selection](#filtering). +//! +//! Administrative users can specify a project ID that is different than their +//! own to list quotas for other projects. +//! +//! If the quota is listed as `null` the quota is using the deployment default +//! quota settings. +//! +//! A quota of `-1` means the quota is unlimited. +//! +//! The list might be empty. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas/quotas".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quotas" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas/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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/load-balancer/src/v2/quota/set.rs b/sdk/load-balancer/src/v2/quota/set.rs new file mode 100644 index 000000000..1af495d50 --- /dev/null +++ b/sdk/load-balancer/src/v2/quota/set.rs @@ -0,0 +1,291 @@ +// 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`. + +//! Updates a quota for a project. +//! +//! If the request is valid, the service returns the `Accepted (202)` response +//! code. +//! +//! This operation returns the updated quota object. +//! +//! If the quota is specified as `null` the quota will use the deployment +//! default quota settings. +//! +//! Specifying a quota of `-1` means the quota is unlimited. +//! +//! Specifying a quota of `0` means the project cannot create any of the +//! resource. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// Individual quota definitions. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Quota { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) health_monitor: Option, + + /// The configured health monitor quota limit. A setting of `null` means it + /// is using the deployment default quota. A setting of `-1` means + /// unlimited. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) healthmonitor: Option, + + /// The configured l7policy quota limit. A setting of `null` means it is + /// using the deployment default quota. A setting of `-1` means unlimited. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) l7policy: Option, + + /// The configured l7rule quota limit. A setting of `null` means it is + /// using the deployment default quota. A setting of `-1` means unlimited. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) l7rule: Option, + + /// The configured listener quota limit. A setting of `null` means it is + /// using the deployment default quota. A setting of `-1` means unlimited. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) listener: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) load_balancer: Option, + + /// The configured load balancer quota limit. A setting of `null` means it + /// is using the deployment default quota. A setting of `-1` means + /// unlimited. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) loadbalancer: Option, + + /// The configured member quota limit. A setting of `null` means it is + /// using the deployment default quota. A setting of `-1` means unlimited. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) member: Option, + + /// The configured pool quota limit. A setting of `null` means it is using + /// the deployment default quota. A setting of `-1` means unlimited. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) pool: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Individual quota definitions. + #[builder(setter(into))] + pub(crate) quota: Quota, + + /// project_id parameter for /v2/lbaas/quotas/{project_id} API + #[builder(default, setter(into))] + project_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 Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "lbaas/quotas/{project_id}", + project_id = self.project_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("quota", serde_json::to_value(&self.quota)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + fn response_key(&self) -> Option> { + Some("quota".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota(QuotaBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota(QuotaBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/lbaas/quotas/{project_id}", + project_id = "project_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .quota(QuotaBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/lbaas/quotas/{project_id}", + project_id = "project_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .project_id("project_id") + .quota(QuotaBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/load_balancer/v2/version.rs b/sdk/load-balancer/src/v2/version.rs similarity index 100% rename from openstack_sdk/src/api/load_balancer/v2/version.rs rename to sdk/load-balancer/src/v2/version.rs diff --git a/sdk/load-balancer/src/v2/version/get.rs b/sdk/load-balancer/src/v2/version/get.rs new file mode 100644 index 000000000..fb5e53671 --- /dev/null +++ b/sdk/load-balancer/src/v2/version/get.rs @@ -0,0 +1,172 @@ +// 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 openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "lbaas".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::LoadBalancer + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::LoadBalancer + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/lbaas".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/Cargo.toml b/sdk/network/Cargo.toml new file mode 100644 index 000000000..2617a6f73 --- /dev/null +++ b/sdk/network/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "openstack-sdk-network" +description = "OpenStack SDK Network service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/network/src/lib.rs b/sdk/network/src/lib.rs new file mode 100644 index 000000000..f720afec7 --- /dev/null +++ b/sdk/network/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Network` Service bindings +pub mod v2; diff --git a/openstack_sdk/src/api/network/v2.rs b/sdk/network/src/v2.rs similarity index 100% rename from openstack_sdk/src/api/network/v2.rs rename to sdk/network/src/v2.rs diff --git a/openstack_sdk/src/api/network/v2/address_group.rs b/sdk/network/src/v2/address_group.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/address_group.rs rename to sdk/network/src/v2/address_group.rs diff --git a/openstack_sdk/src/api/network/v2/address_group/add_addresses.rs b/sdk/network/src/v2/address_group/add_addresses.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/address_group/add_addresses.rs rename to sdk/network/src/v2/address_group/add_addresses.rs index a65ac1ccb..80735cdb8 100644 --- a/openstack_sdk/src/api/network/v2/address_group/add_addresses.rs +++ b/sdk/network/src/v2/address_group/add_addresses.rs @@ -131,7 +131,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/network/src/v2/address_group/create.rs b/sdk/network/src/v2/address_group/create.rs new file mode 100644 index 000000000..5dc1985a5 --- /dev/null +++ b/sdk/network/src/v2/address_group/create.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`. + +//! Creates an address group. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// An `address group` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AddressGroup<'a> { + /// A list of IP addresses. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) addresses: Option>>, + + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `address group` object. + #[builder(setter(into))] + pub(crate) address_group: AddressGroup<'a>, + + #[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 Address_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "address-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("address_group", serde_json::to_value(&self.address_group)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .address_group(AddressGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .address_group(AddressGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "address_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/address-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_group": {} })); + }); + + let endpoint = Request::builder() + .address_group(AddressGroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/address-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_group": {} })); + }); + + let endpoint = Request::builder() + .address_group(AddressGroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/address_group/delete.rs b/sdk/network/src/v2/address_group/delete.rs new file mode 100644 index 000000000..b04824cf3 --- /dev/null +++ b/sdk/network/src/v2/address_group/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes an address group. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/address-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Address_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("address-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/address-groups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/address-groups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/address_group/find.rs b/sdk/network/src/v2/address_group/find.rs new file mode 100644 index 000000000..be4daade8 --- /dev/null +++ b/sdk/network/src/v2/address_group/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::address_group::{get as Get, list as List}; + +/// Find for address_group 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/address_group/get.rs b/sdk/network/src/v2/address_group/get.rs new file mode 100644 index 000000000..143b327aa --- /dev/null +++ b/sdk/network/src/v2/address_group/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows information for an address group. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/address-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Address_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("address-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "address_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/address-groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_group": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/address-groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/address_group/list.rs b/sdk/network/src/v2/address_group/list.rs new file mode 100644 index 000000000..b43294c5a --- /dev/null +++ b/sdk/network/src/v2/address_group/list.rs @@ -0,0 +1,293 @@ +// 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`. + +//! Lists address groups that the project has access to. +//! +//! Default policy settings return only the address groups owned by the project +//! of the user submitting the request, unless the user has administrative +//! role. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/address-groups API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/address-groups API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/address-groups API + #[builder(default, setter(into))] + name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// project_id query parameter for /v2.0/address-groups API + #[builder(default, setter(into))] + project_id: Option>, + + /// revision_number query parameter for /v2.0/address-groups API + #[builder(default, setter(into))] + revision_number: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Address_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "address-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_groups".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "address_groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/address-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/address-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/address_group/remove_addresses.rs b/sdk/network/src/v2/address_group/remove_addresses.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/address_group/remove_addresses.rs rename to sdk/network/src/v2/address_group/remove_addresses.rs index 761328de5..c10bda90e 100644 --- a/openstack_sdk/src/api/network/v2/address_group/remove_addresses.rs +++ b/sdk/network/src/v2/address_group/remove_addresses.rs @@ -135,7 +135,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/network/src/v2/address_group/set.rs b/sdk/network/src/v2/address_group/set.rs new file mode 100644 index 000000000..06faae075 --- /dev/null +++ b/sdk/network/src/v2/address_group/set.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Updates an address group. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// An `address group` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AddressGroup<'a> { + /// A human-readable description for the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `address group` object. + #[builder(setter(into))] + pub(crate) address_group: AddressGroup<'a>, + + /// id parameter for /v2.0/address-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Address_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("address-groups/{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("address_group", serde_json::to_value(&self.address_group)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .address_group(AddressGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .address_group(AddressGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "address_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/address-groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .address_group(AddressGroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/address-groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .address_group(AddressGroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/address_scope.rs b/sdk/network/src/v2/address_scope.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/address_scope.rs rename to sdk/network/src/v2/address_scope.rs diff --git a/sdk/network/src/v2/address_scope/create.rs b/sdk/network/src/v2/address_scope/create.rs new file mode 100644 index 000000000..af81b9af0 --- /dev/null +++ b/sdk/network/src/v2/address_scope/create.rs @@ -0,0 +1,238 @@ +// 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`. + +//! Creates an address scope. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// An `address scope` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AddressScope<'a> { + /// The IP protocol version. Valid value is `4` or `6`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_version: Option, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Indicates whether this resource is shared across all projects. By + /// default, only administrative users can change this value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `address scope` object. + #[builder(setter(into))] + pub(crate) address_scope: AddressScope<'a>, + + #[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 Address_Scope. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "address-scopes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("address_scope", serde_json::to_value(&self.address_scope)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_scope".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "address_scope" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/address-scopes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scope": {} })); + }); + + let endpoint = Request::builder() + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/address-scopes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scope": {} })); + }); + + let endpoint = Request::builder() + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/address_scope/delete.rs b/sdk/network/src/v2/address_scope/delete.rs new file mode 100644 index 000000000..5656040ca --- /dev/null +++ b/sdk/network/src/v2/address_scope/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes an address scope. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/address-scopes/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Address_Scope. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("address-scopes/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/address-scopes/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/address-scopes/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/address_scope/find.rs b/sdk/network/src/v2/address_scope/find.rs new file mode 100644 index 000000000..3979e2c8f --- /dev/null +++ b/sdk/network/src/v2/address_scope/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::address_scope::{get as Get, list as List}; + +/// Find for address_scope 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/address_scope/get.rs b/sdk/network/src/v2/address_scope/get.rs new file mode 100644 index 000000000..7f378e98c --- /dev/null +++ b/sdk/network/src/v2/address_scope/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows information for an address scope. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/address-scopes/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Address_Scope. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("address-scopes/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_scope".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "address_scope" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/address-scopes/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scope": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/address-scopes/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scope": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/address_scope/list.rs b/sdk/network/src/v2/address_scope/list.rs new file mode 100644 index 000000000..d2c02a0b2 --- /dev/null +++ b/sdk/network/src/v2/address_scope/list.rs @@ -0,0 +1,293 @@ +// 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`. + +//! Lists address scopes that the project has access to. +//! +//! Default policy settings return only the address scopes owned by the project +//! of the user submitting the request, unless the user has administrative +//! role. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id query parameter for /v2.0/address-scopes API + #[builder(default, setter(into))] + id: Option>, + + /// ip_version query parameter for /v2.0/address-scopes API + #[builder(default)] + ip_version: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/address-scopes API + #[builder(default, setter(into))] + name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// shared query parameter for /v2.0/address-scopes API + #[builder(default)] + shared: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tenant_id query parameter for /v2.0/address-scopes API + #[builder(default, setter(into))] + tenant_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Address_Scope. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "address-scopes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("id", self.id.as_ref()); + params.push_opt("ip_version", self.ip_version); + params.push_opt("name", self.name.as_ref()); + params.push_opt("shared", self.shared); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_scopes".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "address_scopes" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/address-scopes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scopes": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/address-scopes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scopes": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/address_scope/set.rs b/sdk/network/src/v2/address_scope/set.rs new file mode 100644 index 000000000..59170f04d --- /dev/null +++ b/sdk/network/src/v2/address_scope/set.rs @@ -0,0 +1,232 @@ +// 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`. + +//! Updates an address scope. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// An `address scope` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AddressScope<'a> { + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Indicates whether this resource is shared across all projects. By + /// default, only administrative users can change this value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `address scope` object. + #[builder(setter(into))] + pub(crate) address_scope: AddressScope<'a>, + + /// id parameter for /v2.0/address-scopes/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Address_Scope. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("address-scopes/{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("address_scope", serde_json::to_value(&self.address_scope)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("address_scope".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "address_scope" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/address-scopes/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scope": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/address-scopes/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "address_scope": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .address_scope(AddressScopeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/agent.rs b/sdk/network/src/v2/agent.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/agent.rs rename to sdk/network/src/v2/agent.rs diff --git a/sdk/network/src/v2/agent/create.rs b/sdk/network/src/v2/agent/create.rs new file mode 100644 index 000000000..9cb9c2f12 --- /dev/null +++ b/sdk/network/src/v2/agent/create.rs @@ -0,0 +1,214 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_agent"))] + pub(crate) agent: BTreeMap, Value>, + + #[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 agent(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.agent + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "agents".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("agent", serde_json::to_value(&self.agent)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("agent".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .agent(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .agent(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "agent" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/agents".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agent": {} })); + }); + + let endpoint = Request::builder() + .agent(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/agents".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agent": {} })); + }); + + let endpoint = Request::builder() + .agent(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/delete.rs b/sdk/network/src/v2/agent/delete.rs new file mode 100644 index 000000000..4b68d4230 --- /dev/null +++ b/sdk/network/src/v2/agent/delete.rs @@ -0,0 +1,186 @@ +// 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`. + +//! Agents that won’t be used anymore can be removed. Before deleting agents +//! via API, the agent should be stopped/disabled. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/agents/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("agents/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/agents/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/agents/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/agent/dhcp_network.rs b/sdk/network/src/v2/agent/dhcp_network.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/agent/dhcp_network.rs rename to sdk/network/src/v2/agent/dhcp_network.rs diff --git a/sdk/network/src/v2/agent/dhcp_network/create.rs b/sdk/network/src/v2/agent/dhcp_network/create.rs new file mode 100644 index 000000000..a87b17387 --- /dev/null +++ b/sdk/network/src/v2/agent/dhcp_network/create.rs @@ -0,0 +1,221 @@ +// 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`. + +//! Add a network to a DHCP agent +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 403, 409, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Dhcp_Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "agents/{agent_id}/dhcp-networks", + agent_id = self.agent_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/agents/{agent_id}/dhcp-networks", + agent_id = "agent_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().agent_id("agent_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/agents/{agent_id}/dhcp-networks", + agent_id = "agent_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() + .agent_id("agent_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/dhcp_network/delete.rs b/sdk/network/src/v2/agent/dhcp_network/delete.rs new file mode 100644 index 000000000..de1065c9a --- /dev/null +++ b/sdk/network/src/v2/agent/dhcp_network/delete.rs @@ -0,0 +1,206 @@ +// 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`. + +//! Removes a network from a dhcp agent. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Dhcp_Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "agents/{agent_id}/dhcp-networks/{id}", + agent_id = self.agent_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/agents/{agent_id}/dhcp-networks/{id}", + agent_id = "agent_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .agent_id("agent_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/agents/{agent_id}/dhcp-networks/{id}", + agent_id = "agent_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() + .agent_id("agent_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/dhcp_network/get.rs b/sdk/network/src/v2/agent/dhcp_network/get.rs new file mode 100644 index 000000000..fa1b93950 --- /dev/null +++ b/sdk/network/src/v2/agent/dhcp_network/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Dhcp_Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "agents/{agent_id}/dhcp-networks/{id}", + agent_id = self.agent_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/agents/{agent_id}/dhcp-networks/{id}", + agent_id = "agent_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .agent_id("agent_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/agents/{agent_id}/dhcp-networks/{id}", + agent_id = "agent_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() + .agent_id("agent_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/dhcp_network/list.rs b/sdk/network/src/v2/agent/dhcp_network/list.rs new file mode 100644 index 000000000..18a3d0b15 --- /dev/null +++ b/sdk/network/src/v2/agent/dhcp_network/list.rs @@ -0,0 +1,275 @@ +// 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`. + +//! Lists networks that a DHCP agent hosts. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Dhcp_Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "agents/{agent_id}/dhcp-networks", + agent_id = self.agent_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/agents/{agent_id}/dhcp-networks", + agent_id = "agent_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().agent_id("agent_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/agents/{agent_id}/dhcp-networks", + agent_id = "agent_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() + .agent_id("agent_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/dhcp_network/set.rs b/sdk/network/src/v2/agent/dhcp_network/set.rs new file mode 100644 index 000000000..07c6960e1 --- /dev/null +++ b/sdk/network/src/v2/agent/dhcp_network/set.rs @@ -0,0 +1,227 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// id parameter for /v2.0/agents/{agent_id}/dhcp-networks/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Dhcp_Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "agents/{agent_id}/dhcp-networks/{id}", + agent_id = self.agent_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/agents/{agent_id}/dhcp-networks/{id}", + agent_id = "agent_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .agent_id("agent_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/agents/{agent_id}/dhcp-networks/{id}", + agent_id = "agent_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() + .agent_id("agent_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/get.rs b/sdk/network/src/v2/agent/get.rs new file mode 100644 index 000000000..3c88f6607 --- /dev/null +++ b/sdk/network/src/v2/agent/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for an agent. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/agents/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("agents/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("agent".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "agent" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/agents/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agent": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/agents/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agent": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/agent/l3_router.rs b/sdk/network/src/v2/agent/l3_router.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/agent/l3_router.rs rename to sdk/network/src/v2/agent/l3_router.rs diff --git a/sdk/network/src/v2/agent/l3_router/create.rs b/sdk/network/src/v2/agent/l3_router/create.rs new file mode 100644 index 000000000..355eeb7be --- /dev/null +++ b/sdk/network/src/v2/agent/l3_router/create.rs @@ -0,0 +1,222 @@ +// 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`. + +//! Add a router to an l3 agent. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The ID of the router. + #[builder(setter(into))] + pub(crate) router_id: Cow<'a, str>, + + /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API + #[builder(default, setter(into))] + agent_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 L3_Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "agents/{agent_id}/l3-routers", + agent_id = self.agent_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("router_id", serde_json::to_value(&self.router_id)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .router_id("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .router_id("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/agents/{agent_id}/l3-routers", + agent_id = "agent_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .agent_id("agent_id") + .router_id("foo") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/agents/{agent_id}/l3-routers", + agent_id = "agent_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() + .agent_id("agent_id") + .router_id("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/l3_router/delete.rs b/sdk/network/src/v2/agent/l3_router/delete.rs new file mode 100644 index 000000000..de5d2deff --- /dev/null +++ b/sdk/network/src/v2/agent/l3_router/delete.rs @@ -0,0 +1,206 @@ +// 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`. + +//! Removes a router from an l3 agent. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// id parameter for /v2.0/agents/{agent_id}/l3-routers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the L3_Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "agents/{agent_id}/l3-routers/{id}", + agent_id = self.agent_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/agents/{agent_id}/l3-routers/{id}", + agent_id = "agent_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .agent_id("agent_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/agents/{agent_id}/l3-routers/{id}", + agent_id = "agent_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() + .agent_id("agent_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/l3_router/get.rs b/sdk/network/src/v2/agent/l3_router/get.rs new file mode 100644 index 000000000..bebb17f67 --- /dev/null +++ b/sdk/network/src/v2/agent/l3_router/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// id parameter for /v2.0/agents/{agent_id}/l3-routers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the L3_Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "agents/{agent_id}/l3-routers/{id}", + agent_id = self.agent_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/agents/{agent_id}/l3-routers/{id}", + agent_id = "agent_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .agent_id("agent_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/agents/{agent_id}/l3-routers/{id}", + agent_id = "agent_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() + .agent_id("agent_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/l3_router/list.rs b/sdk/network/src/v2/agent/l3_router/list.rs new file mode 100644 index 000000000..26bda5709 --- /dev/null +++ b/sdk/network/src/v2/agent/l3_router/list.rs @@ -0,0 +1,275 @@ +// 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`. + +//! Lists routers that an l3 agent hosts. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the L3_Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "agents/{agent_id}/l3-routers", + agent_id = self.agent_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/agents/{agent_id}/l3-routers", + agent_id = "agent_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().agent_id("agent_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/agents/{agent_id}/l3-routers", + agent_id = "agent_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() + .agent_id("agent_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/l3_router/set.rs b/sdk/network/src/v2/agent/l3_router/set.rs new file mode 100644 index 000000000..c4bd8862b --- /dev/null +++ b/sdk/network/src/v2/agent/l3_router/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// agent_id parameter for /v2.0/agents/{agent_id}/l3-routers/{id} API + #[builder(default, setter(into))] + agent_id: Cow<'a, str>, + + /// id parameter for /v2.0/agents/{agent_id}/l3-routers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the L3_Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "agents/{agent_id}/l3-routers/{id}", + agent_id = self.agent_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/agents/{agent_id}/l3-routers/{id}", + agent_id = "agent_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .agent_id("agent_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/agents/{agent_id}/l3-routers/{id}", + agent_id = "agent_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() + .agent_id("agent_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/list.rs b/sdk/network/src/v2/agent/list.rs new file mode 100644 index 000000000..da0a8c3b3 --- /dev/null +++ b/sdk/network/src/v2/agent/list.rs @@ -0,0 +1,309 @@ +// 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`. + +//! Lists all agents. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// admin_state_up query parameter for /v2.0/agents API + #[builder(default)] + admin_state_up: Option, + + /// agent_type query parameter for /v2.0/agents API + #[builder(default, setter(into))] + agent_type: Option>, + + /// alive query parameter for /v2.0/agents API + #[builder(default, setter(into))] + alive: Option>, + + /// availability_zone query parameter for /v2.0/agents API + #[builder(default, setter(into))] + availability_zone: Option>, + + /// binary query parameter for /v2.0/agents API + #[builder(default, setter(into))] + binary: Option>, + + /// description query parameter for /v2.0/agents API + #[builder(default, setter(into))] + description: Option>, + + /// host query parameter for /v2.0/agents API + #[builder(default, setter(into))] + host: Option>, + + /// id query parameter for /v2.0/agents API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// topic query parameter for /v2.0/agents API + #[builder(default, setter(into))] + topic: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "agents".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("agent_type", self.agent_type.as_ref()); + params.push_opt("alive", self.alive.as_ref()); + params.push_opt("availability_zone", self.availability_zone.as_ref()); + params.push_opt("binary", self.binary.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("host", self.host.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("topic", self.topic.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("agents".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "agents" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/agents".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agents": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/agents".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agents": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/agent/set.rs b/sdk/network/src/v2/agent/set.rs new file mode 100644 index 000000000..3128aace3 --- /dev/null +++ b/sdk/network/src/v2/agent/set.rs @@ -0,0 +1,231 @@ +// 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`. + +//! Updates an agent. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Agent<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) agent: Agent<'a>, + + /// id parameter for /v2.0/agents/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("agents/{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("agent", serde_json::to_value(&self.agent)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("agent".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .agent(AgentBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .agent(AgentBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "agent" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/agents/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agent": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .agent(AgentBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/agents/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "agent": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .agent(AgentBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/auto_allocated_topology.rs b/sdk/network/src/v2/auto_allocated_topology.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/auto_allocated_topology.rs rename to sdk/network/src/v2/auto_allocated_topology.rs diff --git a/sdk/network/src/v2/auto_allocated_topology/create.rs b/sdk/network/src/v2/auto_allocated_topology/create.rs new file mode 100644 index 000000000..745d79bf7 --- /dev/null +++ b/sdk/network/src/v2/auto_allocated_topology/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_auto_allocated_topology"))] + pub(crate) auto_allocated_topology: BTreeMap, Value>, + + #[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 auto_allocated_topology(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.auto_allocated_topology + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Auto_Allocated_Topology. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auto-allocated-topology".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "auto_allocated_topology", + serde_json::to_value(&self.auto_allocated_topology)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("auto_allocated_topology".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "auto_allocated_topology" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auto-allocated-topology".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topology": {} })); + }); + + let endpoint = Request::builder() + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/auto-allocated-topology".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topology": {} })); + }); + + let endpoint = Request::builder() + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/auto_allocated_topology/delete.rs b/sdk/network/src/v2/auto_allocated_topology/delete.rs new file mode 100644 index 000000000..334a1dcd9 --- /dev/null +++ b/sdk/network/src/v2/auto_allocated_topology/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes the auto allocated topology. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/auto-allocated-topology/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Auto_Allocated_Topology. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("auto-allocated-topology/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/auto-allocated-topology/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/auto-allocated-topology/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/auto_allocated_topology/get.rs b/sdk/network/src/v2/auto_allocated_topology/get.rs new file mode 100644 index 000000000..5ac5eb36e --- /dev/null +++ b/sdk/network/src/v2/auto_allocated_topology/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for an auto allocated topology. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/auto-allocated-topology/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Auto_Allocated_Topology. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("auto-allocated-topology/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("auto_allocated_topology".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "auto_allocated_topology" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/auto-allocated-topology/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topology": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/auto-allocated-topology/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topology": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/auto_allocated_topology/list.rs b/sdk/network/src/v2/auto_allocated_topology/list.rs new file mode 100644 index 000000000..6423043bc --- /dev/null +++ b/sdk/network/src/v2/auto_allocated_topology/list.rs @@ -0,0 +1,245 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Auto_Allocated_Topology. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "auto-allocated-topology".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("auto_allocated_topologies".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "auto_allocated_topologies" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auto-allocated-topology".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topologies": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/auto-allocated-topology".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topologies": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/auto_allocated_topology/set.rs b/sdk/network/src/v2/auto_allocated_topology/set.rs new file mode 100644 index 000000000..470537609 --- /dev/null +++ b/sdk/network/src/v2/auto_allocated_topology/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_auto_allocated_topology"))] + pub(crate) auto_allocated_topology: BTreeMap, Value>, + + /// id parameter for /v2.0/auto-allocated-topology/{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<'a> RequestBuilder<'a> { + pub fn auto_allocated_topology(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.auto_allocated_topology + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Auto_Allocated_Topology. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("auto-allocated-topology/{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( + "auto_allocated_topology", + serde_json::to_value(&self.auto_allocated_topology)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("auto_allocated_topology".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "auto_allocated_topology" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/auto-allocated-topology/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topology": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/auto-allocated-topology/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "auto_allocated_topology": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .auto_allocated_topology(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/availability_zone.rs b/sdk/network/src/v2/availability_zone.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/availability_zone.rs rename to sdk/network/src/v2/availability_zone.rs diff --git a/sdk/network/src/v2/availability_zone/list.rs b/sdk/network/src/v2/availability_zone/list.rs new file mode 100644 index 000000000..2ca0351fb --- /dev/null +++ b/sdk/network/src/v2/availability_zone/list.rs @@ -0,0 +1,279 @@ +// 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`. + +//! Lists all availability zones. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/availability_zones API + #[builder(default, setter(into))] + name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// resource query parameter for /v2.0/availability_zones API + #[builder(default, setter(into))] + resource: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// state query parameter for /v2.0/availability_zones API + #[builder(default, setter(into))] + state: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Availability_Zone. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "availability_zones".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("name", self.name.as_ref()); + params.push_opt("resource", self.resource.as_ref()); + params.push_opt("state", self.state.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("availability_zones".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "availability_zones" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/availability_zones".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zones": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/availability_zones".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "availability_zones": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/default_security_group_rule.rs b/sdk/network/src/v2/default_security_group_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/default_security_group_rule.rs rename to sdk/network/src/v2/default_security_group_rule.rs diff --git a/sdk/network/src/v2/default_security_group_rule/create.rs b/sdk/network/src/v2/default_security_group_rule/create.rs new file mode 100644 index 000000000..fff644dfe --- /dev/null +++ b/sdk/network/src/v2/default_security_group_rule/create.rs @@ -0,0 +1,324 @@ +// 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`. + +//! Creates an Openstack Networking security group rule template. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Ethertype { + #[serde(rename = "IPv4")] + Ipv4, + #[serde(rename = "IPv6")] + Ipv6, +} + +/// A `default_security_group_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct DefaultSecurityGroupRule<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Ingress or egress, which is the direction in which the security group + /// rule is applied. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + /// Must be IPv4 or IPv6, and addresses represented in CIDR must match the + /// ingress or egress rules. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) ethertype: Option, + + /// The maximum port number in the range that is matched by the security + /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this + /// value must be greater than or equal to the `port_range_min` attribute + /// value. If the protocol is ICMP, this value must be an ICMP code. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_range_max: Option>, + + /// The minimum port number in the range that is matched by the security + /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this + /// value must be less than or equal to the `port_range_max` attribute + /// value. If the protocol is ICMP, this value must be an ICMP type. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_range_min: Option>, + + /// The IP protocol can be represented by a string, an integer, or `null`. + /// Valid string or integer values are `any` or `0`, `ah` or `51`, `dccp` + /// or `33`, `egp` or `8`, `esp` or `50`, `gre` or `47`, `icmp` or `1`, + /// `icmpv6` or `58`, `igmp` or `2`, `ipip` or `4`, `ipv6-encap` or `41`, + /// `ipv6-frag` or `44`, `ipv6-icmp` or `58`, `ipv6-nonxt` or `59`, + /// `ipv6-opts` or `60`, `ipv6-route` or `43`, `ospf` or `89`, `pgm` or + /// `113`, `rsvp` or `46`, `sctp` or `132`, `tcp` or `6`, `udp` or `17`, + /// `udplite` or `136`, `vrrp` or `112`. Additionally, any integer value + /// between [0-255] is also valid. The string `any` (or integer `0`) means + /// `all` IP protocols. See the constants in `neutron_lib.constants` for + /// the most up-to-date list of supported strings. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) protocol: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_address_group_id: Option>, + + /// The remote group UUID to associate with this security group rule. You + /// can specify either the `remote_group_id` or `remote_ip_prefix` + /// attribute in the request body. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_group_id: Option>, + + /// The remote IP prefix that is matched by this security group rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_ip_prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// Whether this security group rule template should be used in default + /// security group created automatically for each new project. Default + /// value is `False`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) used_in_default_sg: Option, + + /// Whether this security group rule template should be used in custom + /// security groups created by project user. Default value is `True`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) used_in_non_default_sg: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `default_security_group_rule` object. + #[builder(setter(into))] + pub(crate) default_security_group_rule: DefaultSecurityGroupRule<'a>, + + #[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 Default_Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "default-security-group-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "default_security_group_rule", + serde_json::to_value(&self.default_security_group_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("default_security_group_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .default_security_group_rule( + DefaultSecurityGroupRuleBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .default_security_group_rule( + DefaultSecurityGroupRuleBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "default_security_group_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/default-security-group-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .default_security_group_rule( + DefaultSecurityGroupRuleBuilder::default().build().unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/default-security-group-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .default_security_group_rule( + DefaultSecurityGroupRuleBuilder::default().build().unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/default_security_group_rule/delete.rs b/sdk/network/src/v2/default_security_group_rule/delete.rs new file mode 100644 index 000000000..1b0e6d567 --- /dev/null +++ b/sdk/network/src/v2/default_security_group_rule/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes an OpenStack Networking security group rule template. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/default-security-group-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Default_Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("default-security-group-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/default-security-group-rules/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/default-security-group-rules/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/default_security_group_rule/get.rs b/sdk/network/src/v2/default_security_group_rule/get.rs new file mode 100644 index 000000000..2acdc8a0f --- /dev/null +++ b/sdk/network/src/v2/default_security_group_rule/get.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Shows detailed information for a security group default rule. +//! +//! The response body contains the following information about the security +//! group rule: +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/default-security-group-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Default_Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("default-security-group-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("default_security_group_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "default_security_group_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/default-security-group-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rule": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/default-security-group-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/default_security_group_rule/list.rs b/sdk/network/src/v2/default_security_group_rule/list.rs new file mode 100644 index 000000000..fb5f1eb77 --- /dev/null +++ b/sdk/network/src/v2/default_security_group_rule/list.rs @@ -0,0 +1,340 @@ +// 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`. + +//! Lists a summary of all OpenStack Networking security group rules that are +//! used for every newly created Security Group. +//! +//! The list provides the ID for each security group default rule. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/default-security-group-rules API + #[builder(default, setter(into))] + description: Option>, + + /// direction query parameter for /v2.0/default-security-group-rules API + #[builder(default, setter(into))] + direction: Option>, + + /// ethertype query parameter for /v2.0/default-security-group-rules API + #[builder(default, setter(into))] + ethertype: Option>, + + /// id query parameter for /v2.0/default-security-group-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// port_range_max query parameter for /v2.0/default-security-group-rules + /// API + #[builder(default)] + port_range_max: Option, + + /// port_range_min query parameter for /v2.0/default-security-group-rules + /// API + #[builder(default)] + port_range_min: Option, + + /// protocol query parameter for /v2.0/default-security-group-rules API + #[builder(default, setter(into))] + protocol: Option>, + + /// remote_address_group_id query parameter for + /// /v2.0/default-security-group-rules API + #[builder(default, setter(into))] + remote_address_group_id: Option>, + + /// Filter the security group rule list result by the ID of the remote + /// group that associates with this security group rule. This field can + /// contains uuid of the security group or special word `PARENT` which + /// means that in the real rule created from this template, uuid of the + /// owner Security Group will be put as `remote_group_id`. + #[builder(default, setter(into))] + remote_group_id: Option>, + + /// remote_ip_prefix query parameter for /v2.0/default-security-group-rules + /// API + #[builder(default, setter(into))] + remote_ip_prefix: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// used_in_default_sg query parameter for + /// /v2.0/default-security-group-rules API + #[builder(default)] + used_in_default_sg: Option, + + /// used_in_non_default_sg query parameter for + /// /v2.0/default-security-group-rules API + #[builder(default)] + used_in_non_default_sg: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Default_Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "default-security-group-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("description", self.description.as_ref()); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("ethertype", self.ethertype.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("port_range_max", self.port_range_max); + params.push_opt("port_range_min", self.port_range_min); + params.push_opt("protocol", self.protocol.as_ref()); + params.push_opt( + "remote_address_group_id", + self.remote_address_group_id.as_ref(), + ); + params.push_opt("remote_group_id", self.remote_group_id.as_ref()); + params.push_opt("remote_ip_prefix", self.remote_ip_prefix.as_ref()); + params.push_opt("used_in_default_sg", self.used_in_default_sg); + params.push_opt("used_in_non_default_sg", self.used_in_non_default_sg); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("default_security_group_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "default_security_group_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/default-security-group-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rules": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/default-security-group-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rules": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/default_security_group_rule/set.rs b/sdk/network/src/v2/default_security_group_rule/set.rs new file mode 100644 index 000000000..9a50fae1f --- /dev/null +++ b/sdk/network/src/v2/default_security_group_rule/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_default_security_group_rule"))] + pub(crate) default_security_group_rule: BTreeMap, Value>, + + /// id parameter for /v2.0/default-security-group-rules/{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<'a> RequestBuilder<'a> { + pub fn default_security_group_rule(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.default_security_group_rule + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Default_Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("default-security-group-rules/{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( + "default_security_group_rule", + serde_json::to_value(&self.default_security_group_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("default_security_group_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .default_security_group_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .default_security_group_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "default_security_group_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/default-security-group-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .default_security_group_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/default-security-group-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "default_security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .default_security_group_rule(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/extension.rs b/sdk/network/src/v2/extension.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/extension.rs rename to sdk/network/src/v2/extension.rs diff --git a/sdk/network/src/v2/extension/get.rs b/sdk/network/src/v2/extension/get.rs new file mode 100644 index 000000000..f31e2b906 --- /dev/null +++ b/sdk/network/src/v2/extension/get.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows details for an extension, by alias. The response shows the extension +//! name and its alias. To show details for an extension, you specify the +//! alias. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/extensions/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Extension. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("extensions/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("extension".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "extension" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/extensions/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extension": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/extensions/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extension": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/extension/list.rs b/sdk/network/src/v2/extension/list.rs new file mode 100644 index 000000000..504520c45 --- /dev/null +++ b/sdk/network/src/v2/extension/list.rs @@ -0,0 +1,196 @@ +// 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`. + +//! Lists available extensions. +//! +//! Lists available Networking API v2.0 extensions. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Extension. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "extensions".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("extensions".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "extensions" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/extensions".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extensions": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/extensions".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "extensions": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/flavor.rs b/sdk/network/src/v2/flavor.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/flavor.rs rename to sdk/network/src/v2/flavor.rs diff --git a/sdk/network/src/v2/flavor/create.rs b/sdk/network/src/v2/flavor/create.rs new file mode 100644 index 000000000..2f1368a4d --- /dev/null +++ b/sdk/network/src/v2/flavor/create.rs @@ -0,0 +1,261 @@ +// 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`. + +//! Creates a flavor. +//! +//! This operation establishes a new flavor. +//! +//! The service_type to which the flavor applies is a required parameter. The +//! corresponding service plugin must have been activated as part of the +//! configuration. Check [Service providers](#list-service-providers) for how +//! to see currently loaded service types. Additionally the service plugin +//! needs to support the use of flavors. +//! +//! Creation currently limited to administrators. Other users will receive a +//! `Forbidden 403` response code with a response body NeutronError message +//! expressing that creation is disallowed by policy. +//! +//! Until one or more service profiles are associated with the flavor by the +//! operator, attempts to use the flavor during resource creations will +//! currently return a `Not Found 404` with a response body that indicates no +//! service profile could be found. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `flavor` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavor<'a> { + /// The human-readable description for the flavor. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Indicates whether the flavor is enabled or not. Default is true. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option>, + + /// Name of the flavor. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_profiles: Option>>, + + /// Service type for the flavor. Example: FIREWALL. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_type: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `flavor` object. + #[builder(setter(into))] + pub(crate) flavor: Flavor<'a>, + + #[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 Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "flavors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("flavor", serde_json::to_value(&self.flavor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/flavors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/flavors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/delete.rs b/sdk/network/src/v2/flavor/delete.rs new file mode 100644 index 000000000..2f8c9724d --- /dev/null +++ b/sdk/network/src/v2/flavor/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a flavor. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/flavors/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("flavors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/flavors/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/flavors/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/find.rs b/sdk/network/src/v2/flavor/find.rs new file mode 100644 index 000000000..b2a897d22 --- /dev/null +++ b/sdk/network/src/v2/flavor/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::flavor::{get as Get, list as List}; + +/// Find for flavor 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/flavor/get.rs b/sdk/network/src/v2/flavor/get.rs new file mode 100644 index 000000000..73637cecc --- /dev/null +++ b/sdk/network/src/v2/flavor/get.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Shows details for a flavor. +//! +//! This operation returns a flavor object by ID. If you are not an +//! administrative user and the flavor object is not visible to your project +//! account, the service returns the HTTP `Forbidden (403)` response code. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/flavors/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("flavors/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/flavors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/flavors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/list.rs b/sdk/network/src/v2/flavor/list.rs new file mode 100644 index 000000000..272c12dc0 --- /dev/null +++ b/sdk/network/src/v2/flavor/list.rs @@ -0,0 +1,291 @@ +// 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`. + +//! Lists all flavors visible to the project. +//! +//! The list can be empty. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/flavors API + #[builder(default, setter(into))] + description: Option>, + + /// enabled query parameter for /v2.0/flavors API + #[builder(default)] + enabled: Option, + + /// id query parameter for /v2.0/flavors API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/flavors API + #[builder(default, setter(into))] + name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// service_type query parameter for /v2.0/flavors API + #[builder(default, setter(into))] + service_type: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "flavors".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("description", self.description.as_ref()); + params.push_opt("enabled", self.enabled); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("service_type", self.service_type.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("flavors".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "flavors" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/flavors".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/flavors".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavors": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/flavor/next_provider.rs b/sdk/network/src/v2/flavor/next_provider.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/flavor/next_provider.rs rename to sdk/network/src/v2/flavor/next_provider.rs diff --git a/sdk/network/src/v2/flavor/next_provider/create.rs b/sdk/network/src/v2/flavor/next_provider/create.rs new file mode 100644 index 000000000..0d3c6e656 --- /dev/null +++ b/sdk/network/src/v2/flavor/next_provider/create.rs @@ -0,0 +1,231 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_next_provider"))] + pub(crate) next_provider: BTreeMap, Value>, + + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} + /// API + #[builder(default, setter(into))] + flavor_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> { + pub fn next_provider(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.next_provider + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Next_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "flavors/{flavor_id}/next_providers", + flavor_id = self.flavor_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("next_provider", serde_json::to_value(&self.next_provider)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("next_provider".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .next_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .next_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "next_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/flavors/{flavor_id}/next_providers", + flavor_id = "flavor_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_provider": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .next_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/flavors/{flavor_id}/next_providers", + flavor_id = "flavor_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_provider": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .next_provider(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/next_provider/delete.rs b/sdk/network/src/v2/flavor/next_provider/delete.rs new file mode 100644 index 000000000..c575e0bff --- /dev/null +++ b/sdk/network/src/v2/flavor/next_provider/delete.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.0/flavors/{flavor_id}/next_providers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Next_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/next_providers/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/flavors/{flavor_id}/next_providers/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/flavors/{flavor_id}/next_providers/{id}", + flavor_id = "flavor_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() + .flavor_id("flavor_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/next_provider/get.rs b/sdk/network/src/v2/flavor/next_provider/get.rs new file mode 100644 index 000000000..3274ff8d3 --- /dev/null +++ b/sdk/network/src/v2/flavor/next_provider/get.rs @@ -0,0 +1,204 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.0/flavors/{flavor_id}/next_providers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Next_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/next_providers/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("next_provider".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "next_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/flavors/{flavor_id}/next_providers/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_provider": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/flavors/{flavor_id}/next_providers/{id}", + flavor_id = "flavor_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_provider": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/next_provider/list.rs b/sdk/network/src/v2/flavor/next_provider/list.rs new file mode 100644 index 000000000..781d061a4 --- /dev/null +++ b/sdk/network/src/v2/flavor/next_provider/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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Next_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/next_providers", + flavor_id = self.flavor_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("next_providers".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "next_providers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/flavors/{flavor_id}/next_providers", + flavor_id = "flavor_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_providers": {} })); + }); + + let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/flavors/{flavor_id}/next_providers", + flavor_id = "flavor_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_providers": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/next_provider/set.rs b/sdk/network/src/v2/flavor/next_provider/set.rs new file mode 100644 index 000000000..d4ee0cc73 --- /dev/null +++ b/sdk/network/src/v2/flavor/next_provider/set.rs @@ -0,0 +1,240 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_next_provider"))] + pub(crate) next_provider: BTreeMap, Value>, + + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/next_providers/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.0/flavors/{flavor_id}/next_providers/{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<'a> RequestBuilder<'a> { + pub fn next_provider(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.next_provider + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Next_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "flavors/{flavor_id}/next_providers/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("next_provider", serde_json::to_value(&self.next_provider)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("next_provider".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .next_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .next_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "next_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/flavors/{flavor_id}/next_providers/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_provider": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .next_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/flavors/{flavor_id}/next_providers/{id}", + flavor_id = "flavor_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "next_provider": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .next_provider(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/flavor/service_profile.rs b/sdk/network/src/v2/flavor/service_profile.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/flavor/service_profile.rs rename to sdk/network/src/v2/flavor/service_profile.rs diff --git a/sdk/network/src/v2/flavor/service_profile/create.rs b/sdk/network/src/v2/flavor/service_profile/create.rs new file mode 100644 index 000000000..9b8f95d5a --- /dev/null +++ b/sdk/network/src/v2/flavor/service_profile/create.rs @@ -0,0 +1,243 @@ +// 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`. + +//! Associate a flavor with a service profile. +//! +//! A flavor can be associated with more than one profile. +//! +//! Will return `409 Conflict` if association already exists. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `service_profile` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ServiceProfile<'a> { + /// The UUID of the service profile. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `service_profile` object. + #[builder(setter(into))] + pub(crate) service_profile: ServiceProfile<'a>, + + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} + /// API + #[builder(default, setter(into))] + flavor_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 Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "flavors/{flavor_id}/service_profiles", + flavor_id = self.flavor_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "service_profile", + serde_json::to_value(&self.service_profile)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/flavors/{flavor_id}/service_profiles", + flavor_id = "flavor_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/flavors/{flavor_id}/service_profiles", + flavor_id = "flavor_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/service_profile/delete.rs b/sdk/network/src/v2/flavor/service_profile/delete.rs new file mode 100644 index 000000000..12a43bbf1 --- /dev/null +++ b/sdk/network/src/v2/flavor/service_profile/delete.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`. + +//! Disassociate a flavor from a service profile. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/service_profiles/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/flavors/{flavor_id}/service_profiles/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/flavors/{flavor_id}/service_profiles/{id}", + flavor_id = "flavor_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() + .flavor_id("flavor_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/service_profile/get.rs b/sdk/network/src/v2/flavor/service_profile/get.rs new file mode 100644 index 000000000..135c5861b --- /dev/null +++ b/sdk/network/src/v2/flavor/service_profile/get.rs @@ -0,0 +1,204 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/service_profiles/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/flavors/{flavor_id}/service_profiles/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/flavors/{flavor_id}/service_profiles/{id}", + flavor_id = "flavor_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/service_profile/list.rs b/sdk/network/src/v2/flavor/service_profile/list.rs new file mode 100644 index 000000000..15c3e9f7b --- /dev/null +++ b/sdk/network/src/v2/flavor/service_profile/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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "flavors/{flavor_id}/service_profiles", + flavor_id = self.flavor_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profiles".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_profiles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/flavors/{flavor_id}/service_profiles", + flavor_id = "flavor_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profiles": {} })); + }); + + let endpoint = Request::builder().flavor_id("flavor_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/flavors/{flavor_id}/service_profiles", + flavor_id = "flavor_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profiles": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/service_profile/set.rs b/sdk/network/src/v2/flavor/service_profile/set.rs new file mode 100644 index 000000000..44078f38e --- /dev/null +++ b/sdk/network/src/v2/flavor/service_profile/set.rs @@ -0,0 +1,243 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_service_profile"))] + pub(crate) service_profile: BTreeMap, Value>, + + /// flavor_id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{id} + /// API + #[builder(default, setter(into))] + flavor_id: Cow<'a, str>, + + /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { + pub fn service_profile(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.service_profile + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "flavors/{flavor_id}/service_profiles/{id}", + flavor_id = self.flavor_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "service_profile", + serde_json::to_value(&self.service_profile)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_profile(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_profile(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/flavors/{flavor_id}/service_profiles/{id}", + flavor_id = "flavor_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .service_profile(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/flavors/{flavor_id}/service_profiles/{id}", + flavor_id = "flavor_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .flavor_id("flavor_id") + .id("id") + .service_profile(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/flavor/set.rs b/sdk/network/src/v2/flavor/set.rs new file mode 100644 index 000000000..8946daf81 --- /dev/null +++ b/sdk/network/src/v2/flavor/set.rs @@ -0,0 +1,243 @@ +// 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`. + +//! Updates a flavor. +//! +//! The service_type cannot be updated as there may be associated service +//! profiles and consumers depending on the value. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `flavor` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Flavor<'a> { + /// The human-readable description for the flavor. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Indicates whether the flavor is enabled or not. Default is true. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option>, + + /// Name of the flavor. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_profiles: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `flavor` object. + #[builder(setter(into))] + pub(crate) flavor: Flavor<'a>, + + /// id parameter for /v2.0/flavors/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Flavor. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("flavors/{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("flavor", serde_json::to_value(&self.flavor)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("flavor".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "flavor" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/flavors/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .flavor(FlavorBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/flavors/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "flavor": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .flavor(FlavorBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/floatingip.rs b/sdk/network/src/v2/floatingip.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/floatingip.rs rename to sdk/network/src/v2/floatingip.rs diff --git a/sdk/network/src/v2/floatingip/create.rs b/sdk/network/src/v2/floatingip/create.rs new file mode 100644 index 000000000..610698ef7 --- /dev/null +++ b/sdk/network/src/v2/floatingip/create.rs @@ -0,0 +1,330 @@ +// 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`. + +//! Creates a floating IP, and, if you specify port information, associates the +//! floating IP with an internal port. +//! +//! To associate the floating IP with an internal port, specify the port ID +//! attribute in the request body. If you do not specify a port ID in the +//! request, you can issue a PUT request instead of a POST request. +//! +//! Default policy settings enable only administrative users to set floating IP +//! addresses and some non-administrative users might require a floating IP +//! address. If you do not specify a floating IP address in the request, the +//! operation automatically allocates one. +//! +//! By default, this operation associates the floating IP address with a single +//! fixed IP address that is configured on an OpenStack Networking port. If a +//! port has multiple IP addresses, you must specify the `fixed_ip_address` +//! attribute in the request body to associate a fixed IP address with the +//! floating IP address. +//! +//! You can create floating IPs on only external networks. When you create a +//! floating IP, you must specify the ID of the network on which you want to +//! create the floating IP. Alternatively, you can create a floating IP on a +//! subnet in the external network, based on the costs and quality of that +//! subnet. +//! +//! You must configure an IP address with the internal OpenStack Networking +//! port that is associated with the floating IP address. +//! +//! The operation returns the `Bad Request (400)` response code for one of +//! reasons: +//! +//! If the port ID is not valid, this operation returns `404` response code. +//! +//! The operation returns the `Conflict (409)` response code for one of +//! reasons: +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `floatingip` object. When you associate a floating IP address with a VM, +/// the instance has the same public IP address each time that it boots, +/// basically to maintain a consistent IP address for maintaining DNS +/// assignment. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Floatingip<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// A valid DNS domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_domain: Option>, + + /// A valid DNS name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_name: Option>, + + /// The fixed IP address that is associated with the floating IP. If an + /// internal port has multiple associated IP addresses, the service chooses + /// the first IP address unless you explicitly define a fixed IP address in + /// the `fixed_ip_address` parameter. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ip_address: Option>>, + + /// The floating IP address. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) floating_ip_address: Option>>, + + /// The ID of the network associated with the floating IP. + #[serde()] + #[builder(setter(into))] + pub(crate) floating_network_id: Cow<'a, str>, + + /// The ID of a port associated with the floating IP. To associate the + /// floating IP with a fixed IP at creation time, you must specify the + /// identifier of the internal port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_id: Option>>, + + /// The ID of the QoS policy associated with the floating IP. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, + + /// The subnet ID on which you want to create the floating IP. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>>, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `floatingip` object. When you associate a floating IP address with a + /// VM, the instance has the same public IP address each time that it + /// boots, basically to maintain a consistent IP address for maintaining + /// DNS assignment. + #[builder(setter(into))] + pub(crate) floatingip: Floatingip<'a>, + + #[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 Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "floatingips".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("floatingip", serde_json::to_value(&self.floatingip)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingip".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .floatingip( + FloatingipBuilder::default() + .floating_network_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .floatingip( + FloatingipBuilder::default() + .floating_network_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "floatingip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/floatingips".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip": {} })); + }); + + let endpoint = Request::builder() + .floatingip( + FloatingipBuilder::default() + .floating_network_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/floatingips".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip": {} })); + }); + + let endpoint = Request::builder() + .floatingip( + FloatingipBuilder::default() + .floating_network_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/delete.rs b/sdk/network/src/v2/floatingip/delete.rs new file mode 100644 index 000000000..0691d8533 --- /dev/null +++ b/sdk/network/src/v2/floatingip/delete.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Deletes a floating IP and, if present, its associated port. +//! +//! This example deletes a floating IP: +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/floatingips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("floatingips/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/floatingips/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/floatingips/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/find.rs b/sdk/network/src/v2/floatingip/find.rs new file mode 100644 index 000000000..b8d84e368 --- /dev/null +++ b/sdk/network/src/v2/floatingip/find.rs @@ -0,0 +1,87 @@ +// 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::v2::floatingip::{get as Get, list as List}; + +/// Find for floatingip by floating_ip_addressOrId. +#[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<'a> RequestBuilder<'a> { + /// 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<'a>; + 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<'a> { + 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.floating_ip_address(self.id.clone()); + ep.build().unwrap() + } +} diff --git a/sdk/network/src/v2/floatingip/get.rs b/sdk/network/src/v2/floatingip/get.rs new file mode 100644 index 000000000..6375fca6d --- /dev/null +++ b/sdk/network/src/v2/floatingip/get.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Shows details for a floating IP. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! This example request shows details for a floating IP in JSON format. This +//! example also filters the result by the `fixed_ip_address` and +//! `floating_ip_address` fields. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/floatingips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("floatingips/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingip".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floatingip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/floatingips/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/floatingips/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/list.rs b/sdk/network/src/v2/floatingip/list.rs new file mode 100644 index 000000000..f9b7171f3 --- /dev/null +++ b/sdk/network/src/v2/floatingip/list.rs @@ -0,0 +1,392 @@ +// 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`. + +//! Lists floating IPs visible to the user. +//! +//! Default policy settings return only the floating IPs owned by the user’s +//! project, unless the user has admin role. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! This example request lists floating IPs in JSON format: +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + description: Option>, + + /// fixed_ip_address query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + fixed_ip_address: Option>, + + /// floating_ip_address query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + floating_ip_address: Option>, + + /// floating_network_id query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + floating_network_id: Option>, + + /// id query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// not-tags query parameter for /v2.0/floatingips API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/floatingips API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// port_id query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + port_id: Option>, + + /// revision_number query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + revision_number: Option>, + + /// router_id query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + router_id: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// status query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + status: Option>, + + /// tags query parameter for /v2.0/floatingips API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/floatingips API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/floatingips API + #[builder(default, setter(into))] + tenant_id: 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> { + /// not-tags query parameter for /v2.0/floatingips API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/floatingips API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/floatingips API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/floatingips API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "floatingips".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("description", self.description.as_ref()); + params.push_opt("fixed_ip_address", self.fixed_ip_address.as_ref()); + params.push_opt("floating_ip_address", self.floating_ip_address.as_ref()); + params.push_opt("floating_network_id", self.floating_network_id.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("port_id", self.port_id.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("router_id", self.router_id.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingips".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floatingips" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/floatingips".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingips": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/floatingips".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingips": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/floatingip/port_forwarding.rs b/sdk/network/src/v2/floatingip/port_forwarding.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/floatingip/port_forwarding.rs rename to sdk/network/src/v2/floatingip/port_forwarding.rs diff --git a/sdk/network/src/v2/floatingip/port_forwarding/create.rs b/sdk/network/src/v2/floatingip/port_forwarding/create.rs new file mode 100644 index 000000000..d5a1ddfd5 --- /dev/null +++ b/sdk/network/src/v2/floatingip/port_forwarding/create.rs @@ -0,0 +1,301 @@ +// 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`. + +//! Creates a floating IP port forwarding. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Protocol { + #[serde(rename = "dccp")] + Dccp, + #[serde(rename = "icmp")] + Icmp, + #[serde(rename = "ipv6-icmp")] + Ipv6Icmp, + #[serde(rename = "sctp")] + Sctp, + #[serde(rename = "tcp")] + Tcp, + #[serde(rename = "udp")] + Udp, +} + +/// A `floating IP port forwarding` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PortForwarding<'a> { + /// A text describing the rule, which helps users to manage/find easily + /// theirs rules. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The TCP/UDP/other protocol port number of the port forwarding’s + /// floating IP address. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_port: Option>, + + /// The TCP/UDP/other protocol port range of the port forwarding’s floating + /// IP address. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_port_range: Option, + + /// The fixed IPv4 address of the Neutron port associated to the floating + /// IP port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_ip_address: Option>, + + /// The TCP/UDP/other protocol port number of the Neutron port fixed IP + /// address associated to the floating ip port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_port: Option>, + + /// The ID of the Neutron port associated to the floating IP port + /// forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_port_id: Option>, + + /// The TCP/UDP/other protocol port range of the Neutron port fixed IP + /// address associated to the floating ip port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_port_range: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The IP protocol used in the floating IP port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `floating IP port forwarding` object. + #[builder(setter(into))] + pub(crate) port_forwarding: PortForwarding<'a>, + + /// floatingip_id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API + #[builder(default, setter(into))] + floatingip_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 Port_Forwarding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "floatingips/{floatingip_id}/port_forwardings", + floatingip_id = self.floatingip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "port_forwarding", + serde_json::to_value(&self.port_forwarding)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_forwarding".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "port_forwarding" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/floatingips/{floatingip_id}/port_forwardings", + floatingip_id = "floatingip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwarding": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/floatingips/{floatingip_id}/port_forwardings", + floatingip_id = "floatingip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwarding": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/port_forwarding/delete.rs b/sdk/network/src/v2/floatingip/port_forwarding/delete.rs new file mode 100644 index 000000000..5916be22f --- /dev/null +++ b/sdk/network/src/v2/floatingip/port_forwarding/delete.rs @@ -0,0 +1,208 @@ +// 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`. + +//! Deletes a floating IP port forwarding. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// floatingip_id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Port_Forwarding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = self.floatingip_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = "floatingip_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = "floatingip_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() + .floatingip_id("floatingip_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/port_forwarding/find.rs b/sdk/network/src/v2/floatingip/port_forwarding/find.rs new file mode 100644 index 000000000..57dcf01d4 --- /dev/null +++ b/sdk/network/src/v2/floatingip/port_forwarding/find.rs @@ -0,0 +1,118 @@ +// 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 tracing::trace; + +use crate::api::find::Findable; +use crate::api::rest_endpoint_prelude::*; + +use crate::api::{ApiError, RestClient}; + +use crate::v2::floatingip::port_forwarding::{get as Get, list as List}; + +/// Find for floatingip/port_forwarding by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[builder(default, setter(into))] + floatingip_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 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<'a>; + fn get_ep(&self) -> Get::Request<'a> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.floatingip_id(self.floatingip_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<'a> { + let mut ep = List::Request::builder(); + ep.floatingip_id(self.floatingip_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().unwrap() + } + /// Locate floatingip/port_forwarding in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // floatingip/port_forwarding 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/sdk/network/src/v2/floatingip/port_forwarding/get.rs b/sdk/network/src/v2/floatingip/port_forwarding/get.rs new file mode 100644 index 000000000..dae36bc97 --- /dev/null +++ b/sdk/network/src/v2/floatingip/port_forwarding/get.rs @@ -0,0 +1,214 @@ +// 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`. + +//! Shows information for a floating IP port forwarding. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// floatingip_id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Port_Forwarding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = self.floatingip_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_forwarding".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "port_forwarding" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = "floatingip_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwarding": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = "floatingip_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwarding": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/port_forwarding/list.rs b/sdk/network/src/v2/floatingip/port_forwarding/list.rs new file mode 100644 index 000000000..b8de981d1 --- /dev/null +++ b/sdk/network/src/v2/floatingip/port_forwarding/list.rs @@ -0,0 +1,322 @@ +// 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`. + +//! Lists floating IP port forwardings that the project has access to. +//! +//! Default policy settings return only the port forwardings associated to +//! floating IPs owned by the project of the user submitting the request, +//! unless the user has administrative role. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings API + #[builder(default, setter(into))] + description: Option>, + + /// external_port query parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings API + #[builder(default)] + external_port: Option, + + /// external_port_range query parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings API + #[builder(default)] + external_port_range: Option, + + /// floatingip_id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// id query parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings API + #[builder(default, setter(into))] + id: Option>, + + /// internal_port_id query parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings API + #[builder(default, setter(into))] + internal_port_id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// protocol query parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings API + #[builder(default, setter(into))] + protocol: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Port_Forwarding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "floatingips/{floatingip_id}/port_forwardings", + floatingip_id = self.floatingip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("description", self.description.as_ref()); + params.push_opt("external_port", self.external_port); + params.push_opt("external_port_range", self.external_port_range); + params.push_opt("id", self.id.as_ref()); + params.push_opt("internal_port_id", self.internal_port_id.as_ref()); + params.push_opt("protocol", self.protocol.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_forwardings".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "port_forwardings" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/floatingips/{floatingip_id}/port_forwardings", + floatingip_id = "floatingip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwardings": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/floatingips/{floatingip_id}/port_forwardings", + floatingip_id = "floatingip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwardings": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/port_forwarding/set.rs b/sdk/network/src/v2/floatingip/port_forwarding/set.rs new file mode 100644 index 000000000..ce0c5cd37 --- /dev/null +++ b/sdk/network/src/v2/floatingip/port_forwarding/set.rs @@ -0,0 +1,305 @@ +// 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`. + +//! Updates a floating IP port forwarding. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Protocol { + #[serde(rename = "dccp")] + Dccp, + #[serde(rename = "icmp")] + Icmp, + #[serde(rename = "ipv6-icmp")] + Ipv6Icmp, + #[serde(rename = "sctp")] + Sctp, + #[serde(rename = "tcp")] + Tcp, + #[serde(rename = "udp")] + Udp, +} + +/// A `floating IP port forwarding` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PortForwarding<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The TCP/UDP/other protocol port number of the port forwarding’s + /// floating IP address. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_port: Option>, + + /// The TCP/UDP/other protocol port range of the port forwarding’s floating + /// IP address. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_port_range: Option, + + /// The fixed IPv4 address of the Neutron port associated to the floating + /// IP port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_ip_address: Option>, + + /// The TCP/UDP/other protocol port number of the Neutron port fixed IP + /// address associated to the floating ip port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_port: Option>, + + /// The ID of the Neutron port associated to the floating IP port + /// forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_port_id: Option>, + + /// The TCP/UDP/other protocol port range of the Neutron port fixed IP + /// address associated to the floating ip port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) internal_port_range: Option, + + /// The IP protocol used in the floating IP port forwarding. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `floating IP port forwarding` object. + #[builder(setter(into))] + pub(crate) port_forwarding: PortForwarding<'a>, + + /// floatingip_id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{id} API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// id parameter for + /// /v2.0/floatingips/{floatingip_id}/port_forwardings/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Port_Forwarding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = self.floatingip_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "port_forwarding", + serde_json::to_value(&self.port_forwarding)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_forwarding".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "port_forwarding" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = "floatingip_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwarding": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/floatingips/{floatingip_id}/port_forwardings/{id}", + floatingip_id = "floatingip_id", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_forwarding": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .port_forwarding(PortForwardingBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/set.rs b/sdk/network/src/v2/floatingip/set.rs new file mode 100644 index 000000000..0017ba70a --- /dev/null +++ b/sdk/network/src/v2/floatingip/set.rs @@ -0,0 +1,263 @@ +// 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`. + +//! Updates a floating IP and its association with an internal port. +//! +//! The association process is the same as the process for the create floating +//! IP operation. +//! +//! To disassociate a floating IP from a port, set the `port_id` attribute to +//! null or omit it from the request body. +//! +//! This example updates a floating IP: +//! +//! Depending on the request body that you submit, this request associates a +//! port with or disassociates a port from a floating IP. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404, 409, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `floatingip` object. When you associate a floating IP address with a VM, +/// the instance has the same public IP address each time that it boots, +/// basically to maintain a consistent IP address for maintaining DNS +/// assignment. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Floatingip<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The fixed IP address that is associated with the floating IP. If an + /// internal port has multiple associated IP addresses, the service chooses + /// the first IP address unless you explicitly define a fixed IP address in + /// the `fixed_ip_address` parameter. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ip_address: Option>>, + + /// The ID of a port associated with the floating IP. To associate the + /// floating IP with a fixed IP, you must specify the ID of the internal + /// port. To disassociate the floating IP, `null` should be specified. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_id: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `floatingip` object. When you associate a floating IP address with a + /// VM, the instance has the same public IP address each time that it + /// boots, basically to maintain a consistent IP address for maintaining + /// DNS assignment. + #[builder(setter(into))] + pub(crate) floatingip: Floatingip<'a>, + + /// id parameter for /v2.0/floatingips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floatingip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("floatingips/{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("floatingip", serde_json::to_value(&self.floatingip)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingip".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .floatingip(FloatingipBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .floatingip(FloatingipBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "floatingip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/floatingips/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .floatingip(FloatingipBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/floatingips/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .floatingip(FloatingipBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/floatingip/tag.rs b/sdk/network/src/v2/floatingip/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/floatingip/tag.rs rename to sdk/network/src/v2/floatingip/tag.rs diff --git a/sdk/network/src/v2/floatingip/tag/delete.rs b/sdk/network/src/v2/floatingip/tag/delete.rs new file mode 100644 index 000000000..e4e679111 --- /dev/null +++ b/sdk/network/src/v2/floatingip/tag/delete.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} + /// API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// id parameter for /v2.0/floatingips/{floatingip_id}/tags/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "floatingips/{floatingip_id}/tags/{id}", + floatingip_id = self.floatingip_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/floatingips/{floatingip_id}/tags/{id}", + floatingip_id = "floatingip_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/floatingips/{floatingip_id}/tags/{id}", + floatingip_id = "floatingip_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() + .floatingip_id("floatingip_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/tag/delete_all.rs b/sdk/network/src/v2/floatingip/tag/delete_all.rs new file mode 100644 index 000000000..6c2382ade --- /dev/null +++ b/sdk/network/src/v2/floatingip/tag/delete_all.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} + /// API + #[builder(default, setter(into))] + floatingip_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "floatingips/{floatingip_id}/tags", + floatingip_id = self.floatingip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/floatingips/{floatingip_id}/tags", + floatingip_id = "floatingip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/floatingips/{floatingip_id}/tags", + floatingip_id = "floatingip_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() + .floatingip_id("floatingip_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/tag/get.rs b/sdk/network/src/v2/floatingip/tag/get.rs new file mode 100644 index 000000000..5b2104da0 --- /dev/null +++ b/sdk/network/src/v2/floatingip/tag/get.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} + /// API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// id parameter for /v2.0/floatingips/{floatingip_id}/tags/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "floatingips/{floatingip_id}/tags/{id}", + floatingip_id = self.floatingip_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/floatingips/{floatingip_id}/tags/{id}", + floatingip_id = "floatingip_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/floatingips/{floatingip_id}/tags/{id}", + floatingip_id = "floatingip_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() + .floatingip_id("floatingip_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/tag/list.rs b/sdk/network/src/v2/floatingip/tag/list.rs new file mode 100644 index 000000000..063517a7d --- /dev/null +++ b/sdk/network/src/v2/floatingip/tag/list.rs @@ -0,0 +1,263 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} + /// API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "floatingips/{floatingip_id}/tags", + floatingip_id = self.floatingip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/floatingips/{floatingip_id}/tags", + floatingip_id = "floatingip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/floatingips/{floatingip_id}/tags", + floatingip_id = "floatingip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/tag/replace.rs b/sdk/network/src/v2/floatingip/tag/replace.rs new file mode 100644 index 000000000..f12bf7097 --- /dev/null +++ b/sdk/network/src/v2/floatingip/tag/replace.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} + /// API + #[builder(default, setter(into))] + floatingip_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "floatingips/{floatingip_id}/tags", + floatingip_id = self.floatingip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/floatingips/{floatingip_id}/tags", + floatingip_id = "floatingip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/floatingips/{floatingip_id}/tags", + floatingip_id = "floatingip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip/tag/set.rs b/sdk/network/src/v2/floatingip/tag/set.rs new file mode 100644 index 000000000..c6bb9cc43 --- /dev/null +++ b/sdk/network/src/v2/floatingip/tag/set.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// floatingip_id parameter for /v2.0/floatingips/{floatingip_id}/tags/{id} + /// API + #[builder(default, setter(into))] + floatingip_id: Cow<'a, str>, + + /// id parameter for /v2.0/floatingips/{floatingip_id}/tags/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "floatingips/{floatingip_id}/tags/{id}", + floatingip_id = self.floatingip_id.as_ref(), + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/floatingips/{floatingip_id}/tags/{id}", + floatingip_id = "floatingip_id", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .floatingip_id("floatingip_id") + .id("id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/floatingips/{floatingip_id}/tags/{id}", + floatingip_id = "floatingip_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() + .floatingip_id("floatingip_id") + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/floatingip_pool.rs b/sdk/network/src/v2/floatingip_pool.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/floatingip_pool.rs rename to sdk/network/src/v2/floatingip_pool.rs diff --git a/sdk/network/src/v2/floatingip_pool/create.rs b/sdk/network/src/v2/floatingip_pool/create.rs new file mode 100644 index 000000000..7f7b1e99c --- /dev/null +++ b/sdk/network/src/v2/floatingip_pool/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_floatingip_pool"))] + pub(crate) floatingip_pool: BTreeMap, Value>, + + #[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 floatingip_pool(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.floatingip_pool + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Floatingip_Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "floatingip-pools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "floatingip_pool", + serde_json::to_value(&self.floatingip_pool)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingip_pool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .floatingip_pool(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .floatingip_pool(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "floatingip_pool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/floatingip-pools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pool": {} })); + }); + + let endpoint = Request::builder() + .floatingip_pool(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/floatingip-pools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pool": {} })); + }); + + let endpoint = Request::builder() + .floatingip_pool(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip_pool/delete.rs b/sdk/network/src/v2/floatingip_pool/delete.rs new file mode 100644 index 000000000..b5dda5ae3 --- /dev/null +++ b/sdk/network/src/v2/floatingip_pool/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/floatingip-pools/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floatingip_Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("floatingip-pools/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/floatingip-pools/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/floatingip-pools/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip_pool/get.rs b/sdk/network/src/v2/floatingip_pool/get.rs new file mode 100644 index 000000000..6d78fa71a --- /dev/null +++ b/sdk/network/src/v2/floatingip_pool/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/floatingip-pools/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Floatingip_Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("floatingip-pools/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingip_pool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floatingip_pool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/floatingip-pools/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pool": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/floatingip-pools/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip_pool/list.rs b/sdk/network/src/v2/floatingip_pool/list.rs new file mode 100644 index 000000000..c489af559 --- /dev/null +++ b/sdk/network/src/v2/floatingip_pool/list.rs @@ -0,0 +1,245 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Floatingip_Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "floatingip-pools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingip_pools".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "floatingip_pools" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/floatingip-pools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pools": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/floatingip-pools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pools": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/floatingip_pool/set.rs b/sdk/network/src/v2/floatingip_pool/set.rs new file mode 100644 index 000000000..529d00b82 --- /dev/null +++ b/sdk/network/src/v2/floatingip_pool/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_floatingip_pool"))] + pub(crate) floatingip_pool: BTreeMap, Value>, + + /// id parameter for /v2.0/floatingip-pools/{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<'a> RequestBuilder<'a> { + pub fn floatingip_pool(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.floatingip_pool + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Floatingip_Pool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("floatingip-pools/{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( + "floatingip_pool", + serde_json::to_value(&self.floatingip_pool)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("floatingip_pool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .floatingip_pool(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .floatingip_pool(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "floatingip_pool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/floatingip-pools/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .floatingip_pool(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/floatingip-pools/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "floatingip_pool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .floatingip_pool(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/local_ip.rs b/sdk/network/src/v2/local_ip.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/local_ip.rs rename to sdk/network/src/v2/local_ip.rs diff --git a/sdk/network/src/v2/local_ip/create.rs b/sdk/network/src/v2/local_ip/create.rs new file mode 100644 index 000000000..8b5edd116 --- /dev/null +++ b/sdk/network/src/v2/local_ip/create.rs @@ -0,0 +1,243 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum IpMode { + #[serde(rename = "passthrough")] + Passthrough, + #[serde(rename = "translate")] + Translate, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct LocalIp<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) ip_mode: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) local_ip_address: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) local_port_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) network_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) local_ip: LocalIp<'a>, + + #[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 Local_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "local-ips".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("local_ip", serde_json::to_value(&self.local_ip)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("local_ip".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .local_ip(LocalIpBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .local_ip(LocalIpBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "local_ip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/local-ips".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ip": {} })); + }); + + let endpoint = Request::builder() + .local_ip(LocalIpBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/local-ips".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ip": {} })); + }); + + let endpoint = Request::builder() + .local_ip(LocalIpBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/delete.rs b/sdk/network/src/v2/local_ip/delete.rs new file mode 100644 index 000000000..fa2bc9ee6 --- /dev/null +++ b/sdk/network/src/v2/local_ip/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/local-ips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Local_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("local-ips/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/local-ips/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/local-ips/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/find.rs b/sdk/network/src/v2/local_ip/find.rs new file mode 100644 index 000000000..29fa877d8 --- /dev/null +++ b/sdk/network/src/v2/local_ip/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::local_ip::{get as Get, list as List}; + +/// Find for local_ip 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/local_ip/get.rs b/sdk/network/src/v2/local_ip/get.rs new file mode 100644 index 000000000..824d383b8 --- /dev/null +++ b/sdk/network/src/v2/local_ip/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/local-ips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Local_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("local-ips/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("local_ip".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "local_ip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/local-ips/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ip": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/local-ips/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ip": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/list.rs b/sdk/network/src/v2/local_ip/list.rs new file mode 100644 index 000000000..f1cc55aa1 --- /dev/null +++ b/sdk/network/src/v2/local_ip/list.rs @@ -0,0 +1,290 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + id: Option>, + + /// ip_mode query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + ip_mode: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// local_ip_address query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + local_ip_address: Option>, + + /// local_port_id query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + local_port_id: Option>, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + name: Option>, + + /// network_id query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + network_id: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// project_id query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + project_id: Option>, + + /// revision_number query parameter for /v2.0/local-ips API + #[builder(default, setter(into))] + revision_number: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Local_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "local-ips".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("ip_mode", self.ip_mode.as_ref()); + params.push_opt("local_ip_address", self.local_ip_address.as_ref()); + params.push_opt("local_port_id", self.local_port_id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("network_id", self.network_id.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("local_ips".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "local_ips" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/local-ips".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ips": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/local-ips".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ips": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/local_ip/port_association.rs b/sdk/network/src/v2/local_ip/port_association.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/local_ip/port_association.rs rename to sdk/network/src/v2/local_ip/port_association.rs diff --git a/sdk/network/src/v2/local_ip/port_association/create.rs b/sdk/network/src/v2/local_ip/port_association/create.rs new file mode 100644 index 000000000..1d8341389 --- /dev/null +++ b/sdk/network/src/v2/local_ip/port_association/create.rs @@ -0,0 +1,250 @@ +// 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`. + +//! Creates a Local IP association with a given Port. If a Port has multiple +//! fixed IPs user must specify which IP to use for association. +//! +//! The operation returns the `Conflict (409)` response code for one of +//! reasons: +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PortAssociation<'a> { + /// The requested IP of the port associated with the Local IP. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ip: Option>>, + + /// The requested ID of the port associated with the Local IP. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_port_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) port_association: PortAssociation<'a>, + + /// local_ip_id parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API + #[builder(default, setter(into))] + local_ip_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 Port_Association. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "local_ips/{local_ip_id}/port_associations", + local_ip_id = self.local_ip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "port_association", + serde_json::to_value(&self.port_association)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_association".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .port_association(PortAssociationBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .port_association(PortAssociationBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "port_association" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/local_ips/{local_ip_id}/port_associations", + local_ip_id = "local_ip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_association": {} })); + }); + + let endpoint = Request::builder() + .local_ip_id("local_ip_id") + .port_association(PortAssociationBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/local_ips/{local_ip_id}/port_associations", + local_ip_id = "local_ip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_association": {} })); + }); + + let endpoint = Request::builder() + .local_ip_id("local_ip_id") + .port_association(PortAssociationBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/port_association/delete.rs b/sdk/network/src/v2/local_ip/port_association/delete.rs new file mode 100644 index 000000000..a05acb224 --- /dev/null +++ b/sdk/network/src/v2/local_ip/port_association/delete.rs @@ -0,0 +1,208 @@ +// 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`. + +//! Deletes a Local IP association. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/local_ips/{local_ip_id}/port_associations/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// local_ip_id parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API + #[builder(default, setter(into))] + local_ip_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 Port_Association. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "local_ips/{local_ip_id}/port_associations/{id}", + id = self.id.as_ref(), + local_ip_id = self.local_ip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/local_ips/{local_ip_id}/port_associations/{id}", + id = "id", + local_ip_id = "local_ip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .local_ip_id("local_ip_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/local_ips/{local_ip_id}/port_associations/{id}", + id = "id", + local_ip_id = "local_ip_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") + .local_ip_id("local_ip_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/port_association/get.rs b/sdk/network/src/v2/local_ip/port_association/get.rs new file mode 100644 index 000000000..fd032a56d --- /dev/null +++ b/sdk/network/src/v2/local_ip/port_association/get.rs @@ -0,0 +1,205 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/local_ips/{local_ip_id}/port_associations/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// local_ip_id parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API + #[builder(default, setter(into))] + local_ip_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 Port_Association. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "local_ips/{local_ip_id}/port_associations/{id}", + id = self.id.as_ref(), + local_ip_id = self.local_ip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_association".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "port_association" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/local_ips/{local_ip_id}/port_associations/{id}", + id = "id", + local_ip_id = "local_ip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_association": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .local_ip_id("local_ip_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/local_ips/{local_ip_id}/port_associations/{id}", + id = "id", + local_ip_id = "local_ip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_association": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .local_ip_id("local_ip_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/port_association/list.rs b/sdk/network/src/v2/local_ip/port_association/list.rs new file mode 100644 index 000000000..ebaddbd8e --- /dev/null +++ b/sdk/network/src/v2/local_ip/port_association/list.rs @@ -0,0 +1,306 @@ +// 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`. + +//! Lists Associations for the given Local IP. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// fixed_ip query parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations API + #[builder(default, setter(into))] + fixed_ip: Option>, + + /// fixed_port_id query parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations API + #[builder(default, setter(into))] + fixed_port_id: Option>, + + /// host query parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations API + #[builder(default, setter(into))] + host: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// local_ip_address query parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations API + #[builder(default, setter(into))] + local_ip_address: Option>, + + /// local_ip_id parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API + #[builder(default, setter(into))] + local_ip_id: Cow<'a, str>, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Port_Association. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "local_ips/{local_ip_id}/port_associations", + local_ip_id = self.local_ip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("fixed_ip", self.fixed_ip.as_ref()); + params.push_opt("fixed_port_id", self.fixed_port_id.as_ref()); + params.push_opt("host", self.host.as_ref()); + params.push_opt("local_ip_address", self.local_ip_address.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_associations".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "port_associations" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/local_ips/{local_ip_id}/port_associations", + local_ip_id = "local_ip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_associations": {} })); + }); + + let endpoint = Request::builder() + .local_ip_id("local_ip_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/local_ips/{local_ip_id}/port_associations", + local_ip_id = "local_ip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_associations": {} })); + }); + + let endpoint = Request::builder() + .local_ip_id("local_ip_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/port_association/set.rs b/sdk/network/src/v2/local_ip/port_association/set.rs new file mode 100644 index 000000000..de1d5c9b6 --- /dev/null +++ b/sdk/network/src/v2/local_ip/port_association/set.rs @@ -0,0 +1,244 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_port_association"))] + pub(crate) port_association: BTreeMap, Value>, + + /// id parameter for /v2.0/local_ips/{local_ip_id}/port_associations/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// local_ip_id parameter for + /// /v2.0/local_ips/{local_ip_id}/port_associations/{id} API + #[builder(default, setter(into))] + local_ip_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> { + pub fn port_association(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.port_association + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Port_Association. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "local_ips/{local_ip_id}/port_associations/{id}", + id = self.id.as_ref(), + local_ip_id = self.local_ip_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "port_association", + serde_json::to_value(&self.port_association)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port_association".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .port_association(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .port_association(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "port_association" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/local_ips/{local_ip_id}/port_associations/{id}", + id = "id", + local_ip_id = "local_ip_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_association": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .local_ip_id("local_ip_id") + .port_association(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/local_ips/{local_ip_id}/port_associations/{id}", + id = "id", + local_ip_id = "local_ip_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port_association": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .local_ip_id("local_ip_id") + .port_association(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/local_ip/set.rs b/sdk/network/src/v2/local_ip/set.rs new file mode 100644 index 000000000..e121cdaf9 --- /dev/null +++ b/sdk/network/src/v2/local_ip/set.rs @@ -0,0 +1,221 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct LocalIp<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) local_ip: LocalIp<'a>, + + /// id parameter for /v2.0/local-ips/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Local_Ip. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("local-ips/{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("local_ip", serde_json::to_value(&self.local_ip)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("local_ip".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .local_ip(LocalIpBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .local_ip(LocalIpBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "local_ip" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/local-ips/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ip": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .local_ip(LocalIpBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/local-ips/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "local_ip": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .local_ip(LocalIpBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/log.rs b/sdk/network/src/v2/log.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/log.rs rename to sdk/network/src/v2/log.rs diff --git a/openstack_sdk/src/api/network/v2/log/log.rs b/sdk/network/src/v2/log/log.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/log/log.rs rename to sdk/network/src/v2/log/log.rs diff --git a/sdk/network/src/v2/log/log/create.rs b/sdk/network/src/v2/log/log/create.rs new file mode 100644 index 000000000..0af148534 --- /dev/null +++ b/sdk/network/src/v2/log/log/create.rs @@ -0,0 +1,280 @@ +// 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`. + +//! Creates a log resource. +//! +//! Creates a log resource by using the configuration that you define in the +//! request object. A response object is returned. The object contains a unique +//! ID. +//! +//! If the caller is not an administrative user, this call returns the HTTP +//! `Forbidden (403)` response code. +//! +//! Users with an administrative role can create policies on behalf of other +//! projects by specifying a project ID that is different than their own. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Event { + #[serde(rename = "ACCEPT")] + Accept, + #[serde(rename = "ALL")] + All, + #[serde(rename = "DROP")] + Drop, +} + +/// A `log` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Log<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Indicates whether this log object is enabled or disabled. Default is + /// true. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// Type of security events to log. `ACCEPT`, `DROP`, or `ALL`. Default is + /// `ALL`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) event: Option, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The ID of resource log (e.g security group ID). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) resource_id: Option>>, + + /// The resource log type such as ‘security_group’. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) resource_type: Option>, + + /// The ID of resource target log such as port ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) target_id: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `log` object. + #[builder(setter(into))] + pub(crate) log: Log<'a>, + + #[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 Log. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "log/logs".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("log", serde_json::to_value(&self.log)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("log".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .log(LogBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .log(LogBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "log" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/log/logs".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "log": {} })); + }); + + let endpoint = Request::builder() + .log(LogBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/log/logs".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "log": {} })); + }); + + let endpoint = Request::builder() + .log(LogBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/log/delete.rs b/sdk/network/src/v2/log/log/delete.rs new file mode 100644 index 000000000..67908a4ba --- /dev/null +++ b/sdk/network/src/v2/log/log/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a log resource. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/log/logs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Log. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("log/logs/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/log/logs/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/log/logs/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/log/find.rs b/sdk/network/src/v2/log/log/find.rs new file mode 100644 index 000000000..d44b03799 --- /dev/null +++ b/sdk/network/src/v2/log/log/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::log::log::{get as Get, list as List}; + +/// Find for log/log 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/log/log/get.rs b/sdk/network/src/v2/log/log/get.rs new file mode 100644 index 000000000..cb8f9ec39 --- /dev/null +++ b/sdk/network/src/v2/log/log/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details log resource. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/log/logs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Log. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("log/logs/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("log".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "log" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/log/logs/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "log": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/log/logs/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "log": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/log/list.rs b/sdk/network/src/v2/log/log/list.rs new file mode 100644 index 000000000..c7e0d21ff --- /dev/null +++ b/sdk/network/src/v2/log/log/list.rs @@ -0,0 +1,316 @@ +// 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`. + +//! Lists all log resources associated with your project. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! The list might be empty. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + description: Option>, + + /// enabled query parameter for /v2.0/log/logs API + #[builder(default)] + enabled: Option, + + /// event query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + event: Option>, + + /// id query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// project_id query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + project_id: Option>, + + /// resource_id query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + resource_id: Option>, + + /// resource_type query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + resource_type: Option>, + + /// revision_number query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + revision_number: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// target_id query parameter for /v2.0/log/logs API + #[builder(default, setter(into))] + target_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Log. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "log/logs".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("description", self.description.as_ref()); + params.push_opt("enabled", self.enabled); + params.push_opt("event", self.event.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("resource_id", self.resource_id.as_ref()); + params.push_opt("resource_type", self.resource_type.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("target_id", self.target_id.as_ref()); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("logs".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "logs" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/log/logs".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "logs": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/log/logs".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "logs": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/log/set.rs b/sdk/network/src/v2/log/log/set.rs new file mode 100644 index 000000000..4bdf0b8a3 --- /dev/null +++ b/sdk/network/src/v2/log/log/set.rs @@ -0,0 +1,237 @@ +// 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`. + +//! Updates a log resource. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `log` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Log<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Indicates whether this log object is enabled or disabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `log` object. + #[builder(setter(into))] + pub(crate) log: Log<'a>, + + /// id parameter for /v2.0/log/logs/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Log. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("log/logs/{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("log", serde_json::to_value(&self.log)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("log".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .log(LogBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .log(LogBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "log" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/log/logs/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "log": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .log(LogBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/log/logs/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "log": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .log(LogBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/log/loggable_resource.rs b/sdk/network/src/v2/log/loggable_resource.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/log/loggable_resource.rs rename to sdk/network/src/v2/log/loggable_resource.rs diff --git a/sdk/network/src/v2/log/loggable_resource/create.rs b/sdk/network/src/v2/log/loggable_resource/create.rs new file mode 100644 index 000000000..f80e94f22 --- /dev/null +++ b/sdk/network/src/v2/log/loggable_resource/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_loggable_resource"))] + pub(crate) loggable_resource: BTreeMap, Value>, + + #[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 loggable_resource(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.loggable_resource + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Loggable_Resource. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "log/loggable-resources".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "loggable_resource", + serde_json::to_value(&self.loggable_resource)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("loggable_resource".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .loggable_resource(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .loggable_resource(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "loggable_resource" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/log/loggable-resources".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resource": {} })); + }); + + let endpoint = Request::builder() + .loggable_resource(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/log/loggable-resources".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resource": {} })); + }); + + let endpoint = Request::builder() + .loggable_resource(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/loggable_resource/delete.rs b/sdk/network/src/v2/log/loggable_resource/delete.rs new file mode 100644 index 000000000..810035f76 --- /dev/null +++ b/sdk/network/src/v2/log/loggable_resource/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/log/loggable-resources/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Loggable_Resource. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("log/loggable-resources/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/log/loggable-resources/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/log/loggable-resources/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/loggable_resource/get.rs b/sdk/network/src/v2/log/loggable_resource/get.rs new file mode 100644 index 000000000..356a87480 --- /dev/null +++ b/sdk/network/src/v2/log/loggable_resource/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/log/loggable-resources/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Loggable_Resource. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("log/loggable-resources/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("loggable_resource".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "loggable_resource" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/log/loggable-resources/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resource": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/log/loggable-resources/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resource": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/loggable_resource/list.rs b/sdk/network/src/v2/log/loggable_resource/list.rs new file mode 100644 index 000000000..a6cc9b26c --- /dev/null +++ b/sdk/network/src/v2/log/loggable_resource/list.rs @@ -0,0 +1,264 @@ +// 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`. + +//! Lists all resource log types are supporting. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Loggable_Resource. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "log/loggable-resources".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("loggable_resources".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "loggable_resources" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/log/loggable-resources".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resources": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/log/loggable-resources".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resources": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/log/loggable_resource/set.rs b/sdk/network/src/v2/log/loggable_resource/set.rs new file mode 100644 index 000000000..a458f4114 --- /dev/null +++ b/sdk/network/src/v2/log/loggable_resource/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_loggable_resource"))] + pub(crate) loggable_resource: BTreeMap, Value>, + + /// id parameter for /v2.0/log/loggable-resources/{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<'a> RequestBuilder<'a> { + pub fn loggable_resource(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.loggable_resource + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Loggable_Resource. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("log/loggable-resources/{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( + "loggable_resource", + serde_json::to_value(&self.loggable_resource)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("loggable_resource".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .loggable_resource(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .loggable_resource(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "loggable_resource" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/log/loggable-resources/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resource": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .loggable_resource(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/log/loggable-resources/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "loggable_resource": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .loggable_resource(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/metering.rs b/sdk/network/src/v2/metering.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/metering.rs rename to sdk/network/src/v2/metering.rs diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label.rs b/sdk/network/src/v2/metering/metering_label.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/metering/metering_label.rs rename to sdk/network/src/v2/metering/metering_label.rs diff --git a/sdk/network/src/v2/metering/metering_label/create.rs b/sdk/network/src/v2/metering/metering_label/create.rs new file mode 100644 index 000000000..7b9ce3052 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label/create.rs @@ -0,0 +1,241 @@ +// 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`. + +//! Creates an L3 metering label. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `metering_label` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct MeteringLabel<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Indicates whether this metering label is shared across all projects. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `metering_label` object. + #[builder(setter(into))] + pub(crate) metering_label: MeteringLabel<'a>, + + #[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 Metering_Label. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "metering/metering-labels".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "metering_label", + serde_json::to_value(&self.metering_label)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_label".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metering_label(MeteringLabelBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metering_label(MeteringLabelBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metering_label" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/metering/metering-labels".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label": {} })); + }); + + let endpoint = Request::builder() + .metering_label(MeteringLabelBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/metering/metering-labels".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label": {} })); + }); + + let endpoint = Request::builder() + .metering_label(MeteringLabelBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label/delete.rs b/sdk/network/src/v2/metering/metering_label/delete.rs new file mode 100644 index 000000000..14a4d7d29 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes an L3 metering label. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/metering/metering-labels/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Metering_Label. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("metering/metering-labels/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/metering/metering-labels/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/metering/metering-labels/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label/find.rs b/sdk/network/src/v2/metering/metering_label/find.rs new file mode 100644 index 000000000..e425888c6 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::metering::metering_label::{get as Get, list as List}; + +/// Find for metering/metering_label 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/metering/metering_label/get.rs b/sdk/network/src/v2/metering/metering_label/get.rs new file mode 100644 index 000000000..8c25aeab7 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for a metering label. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/metering/metering-labels/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Metering_Label. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("metering/metering-labels/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_label".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "metering_label" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/metering/metering-labels/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/metering/metering-labels/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label/list.rs b/sdk/network/src/v2/metering/metering_label/list.rs new file mode 100644 index 000000000..71513bddc --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label/list.rs @@ -0,0 +1,291 @@ +// 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`. + +//! Lists all L3 metering labels that belong to the project. +//! +//! The list shows the ID for each metering label. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/metering/metering-labels API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/metering/metering-labels API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/metering/metering-labels API + #[builder(default, setter(into))] + name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// shared query parameter for /v2.0/metering/metering-labels API + #[builder(default)] + shared: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tenant_id query parameter for /v2.0/metering/metering-labels API + #[builder(default, setter(into))] + tenant_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Metering_Label. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "metering/metering-labels".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("shared", self.shared); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_labels".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "metering_labels" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metering/metering-labels".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_labels": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metering/metering-labels".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_labels": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label/set.rs b/sdk/network/src/v2/metering/metering_label/set.rs new file mode 100644 index 000000000..3edd7af48 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_metering_label"))] + pub(crate) metering_label: BTreeMap, Value>, + + /// id parameter for /v2.0/metering/metering-labels/{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<'a> RequestBuilder<'a> { + pub fn metering_label(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.metering_label + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Metering_Label. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("metering/metering-labels/{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( + "metering_label", + serde_json::to_value(&self.metering_label)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_label".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metering_label(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metering_label(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metering_label" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/metering/metering-labels/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .metering_label(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/metering/metering-labels/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .metering_label(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/metering/metering_label_rule.rs b/sdk/network/src/v2/metering/metering_label_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/metering/metering_label_rule.rs rename to sdk/network/src/v2/metering/metering_label_rule.rs diff --git a/sdk/network/src/v2/metering/metering_label_rule/create.rs b/sdk/network/src/v2/metering/metering_label_rule/create.rs new file mode 100644 index 000000000..87012c5f6 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label_rule/create.rs @@ -0,0 +1,263 @@ +// 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`. + +//! Creates an L3 metering label rule. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +/// A `metering_label_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct MeteringLabelRule<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) destination_ip_prefix: Option>, + + /// Ingress or egress, which is the direction in which the metering rule is + /// applied. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + /// Indicates whether to count the traffic of a specific IP address with + /// the `remote_ip_prefix`, `source_ip_prefix`, or `destination_ip_prefix` + /// values. Default is `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) excluded: Option, + + /// The metering label ID associated with this metering rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) metering_label_id: Option>, + + /// (deprecated) The source IP prefix that is matched by this metering + /// rule. By source IP prefix, one should read the internal/private IPs + /// used in OpenStack. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_ip_prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) source_ip_prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `metering_label_rule` object. + #[builder(setter(into))] + pub(crate) metering_label_rule: MeteringLabelRule<'a>, + + #[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 Metering_Label_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "metering/metering-label-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "metering_label_rule", + serde_json::to_value(&self.metering_label_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_label_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metering_label_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/metering/metering-label-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rule": {} })); + }); + + let endpoint = Request::builder() + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/metering/metering-label-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rule": {} })); + }); + + let endpoint = Request::builder() + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label_rule/delete.rs b/sdk/network/src/v2/metering/metering_label_rule/delete.rs new file mode 100644 index 000000000..47cc22216 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label_rule/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes an L3 metering label rule. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/metering/metering-label-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Metering_Label_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("metering/metering-label-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/metering/metering-label-rules/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/metering/metering-label-rules/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label_rule/get.rs b/sdk/network/src/v2/metering/metering_label_rule/get.rs new file mode 100644 index 000000000..36e6e25b3 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label_rule/get.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows details for a metering label rule. +//! +//! The response body shows this information for each metering label rule: +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/metering/metering-label-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Metering_Label_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("metering/metering-label-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_label_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "metering_label_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/metering/metering-label-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rule": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/metering/metering-label-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label_rule/list.rs b/sdk/network/src/v2/metering/metering_label_rule/list.rs new file mode 100644 index 000000000..367fcbf93 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label_rule/list.rs @@ -0,0 +1,316 @@ +// 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`. + +//! Lists a summary of all L3 metering label rules that belong to the project. +//! +//! The list shows the ID for each metering label rule. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The destination IP prefix that the metering rule is associated with; in + /// this context, destination IP prefix represents the destination IP of + /// the network packet. Therefore, for an ingress rule, the destination IP + /// is the internal IP associated with some OpenStack VM. On the other + /// hand, for an egress rule, the destination IP prefix is the IP of some + /// external system that an application running inside some OpenStack + /// virtual machine is trying to access. Moreover, instead of an IP, one + /// can also use a CIDR as the destination IP prefix. + #[builder(default, setter(into))] + destination_ip_prefix: Option>, + + /// direction query parameter for /v2.0/metering/metering-label-rules API + #[builder(default, setter(into))] + direction: Option>, + + /// excluded query parameter for /v2.0/metering/metering-label-rules API + #[builder(default)] + excluded: Option, + + /// id query parameter for /v2.0/metering/metering-label-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// metering_label_id query parameter for + /// /v2.0/metering/metering-label-rules API + #[builder(default, setter(into))] + metering_label_id: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// remote_ip_prefix query parameter for + /// /v2.0/metering/metering-label-rules API + #[builder(default, setter(into))] + remote_ip_prefix: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// The source IP prefix that the metering rule is associated with; in this + /// context, source IP prefix represents the source IP of the network + /// packet. Therefore, for an ingress rule, the source IP is the IP of the + /// system accessing something inside OpenStack. On the other hand, for an + /// egress rule, the source IP is the internal IP associated with some + /// OpenStack VM. Moreover, instead of an IP, one can also use a CIDR as + /// the source IP prefix. + #[builder(default, setter(into))] + source_ip_prefix: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Metering_Label_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "metering/metering-label-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("destination_ip_prefix", self.destination_ip_prefix.as_ref()); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("excluded", self.excluded); + params.push_opt("id", self.id.as_ref()); + params.push_opt("metering_label_id", self.metering_label_id.as_ref()); + params.push_opt("remote_ip_prefix", self.remote_ip_prefix.as_ref()); + params.push_opt("source_ip_prefix", self.source_ip_prefix.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_label_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "metering_label_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metering/metering-label-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rules": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/metering/metering-label-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rules": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/metering/metering_label_rule/set.rs b/sdk/network/src/v2/metering/metering_label_rule/set.rs new file mode 100644 index 000000000..7ff621059 --- /dev/null +++ b/sdk/network/src/v2/metering/metering_label_rule/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct MeteringLabelRule<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) destination_ip_prefix: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) source_ip_prefix: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) metering_label_rule: MeteringLabelRule<'a>, + + /// id parameter for /v2.0/metering/metering-label-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Metering_Label_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("metering/metering-label-rules/{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( + "metering_label_rule", + serde_json::to_value(&self.metering_label_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("metering_label_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "metering_label_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/metering/metering-label-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/metering/metering-label-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "metering_label_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .metering_label_rule(MeteringLabelRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/ndp_proxy.rs b/sdk/network/src/v2/ndp_proxy.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/ndp_proxy.rs rename to sdk/network/src/v2/ndp_proxy.rs diff --git a/sdk/network/src/v2/ndp_proxy/create.rs b/sdk/network/src/v2/ndp_proxy/create.rs new file mode 100644 index 000000000..546b83134 --- /dev/null +++ b/sdk/network/src/v2/ndp_proxy/create.rs @@ -0,0 +1,231 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct NdpProxy<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) router_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) ndp_proxy: NdpProxy<'a>, + + #[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 Ndp_Proxy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "ndp-proxies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("ndp_proxy", serde_json::to_value(&self.ndp_proxy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ndp_proxy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ndp_proxy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/ndp-proxies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxy": {} })); + }); + + let endpoint = Request::builder() + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/ndp-proxies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxy": {} })); + }); + + let endpoint = Request::builder() + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/ndp_proxy/delete.rs b/sdk/network/src/v2/ndp_proxy/delete.rs new file mode 100644 index 000000000..e2fb92d5c --- /dev/null +++ b/sdk/network/src/v2/ndp_proxy/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/ndp-proxies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ndp_Proxy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("ndp-proxies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/ndp-proxies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/ndp-proxies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/ndp_proxy/find.rs b/sdk/network/src/v2/ndp_proxy/find.rs new file mode 100644 index 000000000..b269a3605 --- /dev/null +++ b/sdk/network/src/v2/ndp_proxy/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::ndp_proxy::{get as Get, list as List}; + +/// Find for ndp_proxy 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/ndp_proxy/get.rs b/sdk/network/src/v2/ndp_proxy/get.rs new file mode 100644 index 000000000..92754540d --- /dev/null +++ b/sdk/network/src/v2/ndp_proxy/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/ndp-proxies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ndp_Proxy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("ndp-proxies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ndp_proxy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ndp_proxy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ndp-proxies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxy": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ndp-proxies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/ndp_proxy/list.rs b/sdk/network/src/v2/ndp_proxy/list.rs new file mode 100644 index 000000000..b191a3122 --- /dev/null +++ b/sdk/network/src/v2/ndp_proxy/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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/ndp-proxies API + #[builder(default, setter(into))] + description: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/ndp-proxies API + #[builder(default, setter(into))] + name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// revision_number query parameter for /v2.0/ndp-proxies API + #[builder(default, setter(into))] + revision_number: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Ndp_Proxy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "ndp-proxies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ndp_proxies".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ndp_proxies" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/ndp-proxies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxies": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/ndp-proxies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxies": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/ndp_proxy/set.rs b/sdk/network/src/v2/ndp_proxy/set.rs new file mode 100644 index 000000000..20732caef --- /dev/null +++ b/sdk/network/src/v2/ndp_proxy/set.rs @@ -0,0 +1,221 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct NdpProxy<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) ndp_proxy: NdpProxy<'a>, + + /// id parameter for /v2.0/ndp-proxies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ndp_Proxy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("ndp-proxies/{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("ndp_proxy", serde_json::to_value(&self.ndp_proxy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ndp_proxy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ndp_proxy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/ndp-proxies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/ndp-proxies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ndp_proxy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ndp_proxy(NdpProxyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/network.rs b/sdk/network/src/v2/network.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/network.rs rename to sdk/network/src/v2/network.rs diff --git a/sdk/network/src/v2/network/create.rs b/sdk/network/src/v2/network/create.rs new file mode 100644 index 000000000..bbec4b578 --- /dev/null +++ b/sdk/network/src/v2/network/create.rs @@ -0,0 +1,365 @@ +// 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`. + +//! Creates a network. +//! +//! A request body is optional. An administrative user can specify another +//! project ID, which is the project that owns the network, in the request +//! body. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Segments<'a> { + #[serde( + rename = "provider:network_type", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_network_type: Option>, + + #[serde( + rename = "provider:physical_network", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_physical_network: Option>, + + #[serde( + rename = "provider:segmentation_id", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_segmentation_id: Option, +} + +/// A `network` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Network<'a> { + /// The administrative state of the network, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// The availability zone candidate for the network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone_hints: Option>>, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// A valid DNS domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_domain: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ha: Option, + + /// The network is default or not. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_default: Option, + + /// The maximum transmission unit (MTU) value to address fragmentation. + /// Minimum value is 68 for IPv4, and 1280 for IPv6. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) mtu: Option, + + /// Human-readable name of the network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The port security status of the network. Valid values are enabled + /// (`true`) and disabled (`false`). This value is used as the default + /// value of `port_security_enabled` field of a newly created port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_security_enabled: Option, + + /// The type of physical network that this network should be mapped to. For + /// example, `flat`, `vlan`, `vxlan`, or `gre`. Valid values depend on a + /// networking back-end. + #[serde( + rename = "provider:network_type", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_network_type: Option>, + + /// The physical network where this network should be implemented. The + /// Networking API v2.0 does not provide a way to list available physical + /// networks. For example, the Open vSwitch plug-in configuration file + /// defines a symbolic name that maps to specific bridges on each compute + /// host. + #[serde( + rename = "provider:physical_network", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_physical_network: Option>, + + /// The ID of the isolated segment on the physical network. The + /// `network_type` attribute defines the segmentation model. For example, + /// if the `network_type` value is vlan, this ID is a vlan identifier. If + /// the `network_type` value is gre, this ID is a gre key. + #[serde( + rename = "provider:segmentation_id", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_segmentation_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qinq: Option, + + /// The ID of the QoS policy associated with the network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, + + /// Indicates whether the network has an external routing facility that’s + /// not managed by the networking service. + #[serde(rename = "router:external", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) router_external: Option, + + /// A list of provider `segment` objects. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) segments: Option>>, + + /// Indicates whether this resource is shared across all projects. By + /// default, only administrative users can change this value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// Indicates the VLAN transparency mode of the network, which is VLAN + /// transparent (`true`) or not VLAN transparent (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vlan_transparent: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `network` object. + #[builder(setter(into))] + pub(crate) network: Network<'a>, + + #[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 Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "networks".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("network", serde_json::to_value(&self.network)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .network(NetworkBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .network(NetworkBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "network" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/networks".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network": {} })); + }); + + let endpoint = Request::builder() + .network(NetworkBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/networks".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network": {} })); + }); + + let endpoint = Request::builder() + .network(NetworkBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/delete.rs b/sdk/network/src/v2/network/delete.rs new file mode 100644 index 000000000..a8a861c59 --- /dev/null +++ b/sdk/network/src/v2/network/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a network and its associated resources. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// network_id parameter for /v2.0/networks/{network_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<'a> RequestBuilder<'a> { + /// Add a single header to the Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("networks/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/networks/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/networks/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/network/dhcp_agent.rs b/sdk/network/src/v2/network/dhcp_agent.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/network/dhcp_agent.rs rename to sdk/network/src/v2/network/dhcp_agent.rs diff --git a/sdk/network/src/v2/network/dhcp_agent/create.rs b/sdk/network/src/v2/network/dhcp_agent/create.rs new file mode 100644 index 000000000..13f33a31c --- /dev/null +++ b/sdk/network/src/v2/network/dhcp_agent/create.rs @@ -0,0 +1,216 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} + /// API + #[builder(default, setter(into))] + network_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Dhcp_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "networks/{network_id}/dhcp-agents", + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/networks/{network_id}/dhcp-agents", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().network_id("network_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/networks/{network_id}/dhcp-agents", + network_id = "network_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() + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/dhcp_agent/delete.rs b/sdk/network/src/v2/network/dhcp_agent/delete.rs new file mode 100644 index 000000000..eb211de5c --- /dev/null +++ b/sdk/network/src/v2/network/dhcp_agent/delete.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} + /// API + #[builder(default, setter(into))] + network_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 Dhcp_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "networks/{network_id}/dhcp-agents/{id}", + id = self.id.as_ref(), + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/networks/{network_id}/dhcp-agents/{id}", + id = "id", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_id("network_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/networks/{network_id}/dhcp-agents/{id}", + id = "id", + network_id = "network_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") + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/dhcp_agent/get.rs b/sdk/network/src/v2/network/dhcp_agent/get.rs new file mode 100644 index 000000000..bd24487ee --- /dev/null +++ b/sdk/network/src/v2/network/dhcp_agent/get.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} + /// API + #[builder(default, setter(into))] + network_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 Dhcp_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "networks/{network_id}/dhcp-agents/{id}", + id = self.id.as_ref(), + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/networks/{network_id}/dhcp-agents/{id}", + id = "id", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_id("network_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/networks/{network_id}/dhcp-agents/{id}", + id = "id", + network_id = "network_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") + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/dhcp_agent/list.rs b/sdk/network/src/v2/network/dhcp_agent/list.rs new file mode 100644 index 000000000..bfc58c897 --- /dev/null +++ b/sdk/network/src/v2/network/dhcp_agent/list.rs @@ -0,0 +1,276 @@ +// 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`. + +//! Lists DHCP agents hosting a network. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} + /// API + #[builder(default, setter(into))] + network_id: Cow<'a, str>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Dhcp_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "networks/{network_id}/dhcp-agents", + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/networks/{network_id}/dhcp-agents", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().network_id("network_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/networks/{network_id}/dhcp-agents", + network_id = "network_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() + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/dhcp_agent/set.rs b/sdk/network/src/v2/network/dhcp_agent/set.rs new file mode 100644 index 000000000..e96cd3b56 --- /dev/null +++ b/sdk/network/src/v2/network/dhcp_agent/set.rs @@ -0,0 +1,228 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_id parameter for /v2.0/networks/{network_id}/dhcp-agents/{id} + /// API + #[builder(default, setter(into))] + network_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 Dhcp_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "networks/{network_id}/dhcp-agents/{id}", + id = self.id.as_ref(), + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/networks/{network_id}/dhcp-agents/{id}", + id = "id", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_id("network_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/networks/{network_id}/dhcp-agents/{id}", + id = "id", + network_id = "network_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") + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/find.rs b/sdk/network/src/v2/network/find.rs new file mode 100644 index 000000000..6431cb69e --- /dev/null +++ b/sdk/network/src/v2/network/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::network::{get as Get, list as List}; + +/// Find for network 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/network/get.rs b/sdk/network/src/v2/network/get.rs new file mode 100644 index 000000000..91c74c0d5 --- /dev/null +++ b/sdk/network/src/v2/network/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for a network. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// network_id parameter for /v2.0/networks/{network_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<'a> RequestBuilder<'a> { + /// Add a single header to the Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("networks/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "network" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/networks/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/networks/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/list.rs b/sdk/network/src/v2/network/list.rs new file mode 100644 index 000000000..06ae21d93 --- /dev/null +++ b/sdk/network/src/v2/network/list.rs @@ -0,0 +1,429 @@ +// 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`. + +//! Lists networks to which the project has access. +//! +//! Default policy settings return only networks that the project who submits +//! the request owns, unless an administrative user submits the request. In +//! addition, networks shared with the project who submits the request are also +//! returned. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! You can also use the `tags`, `tags-any`, `not-tags`, `not-tags-any` query +//! parameter to filter the response with tags. For information, see +//! [REST API Impact](http://specs.openstack.org/openstack/neutron-specs/specs/mitaka/add-tags-to-core-resources.html#rest-api-impact). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// admin_state_up query parameter for /v2.0/networks API + #[builder(default)] + admin_state_up: Option, + + /// description query parameter for /v2.0/networks API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/networks API + #[builder(default, setter(into))] + id: Option>, + + /// is_default query parameter for /v2.0/networks API + #[builder(default)] + is_default: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// mtu query parameter for /v2.0/networks API + #[builder(default)] + mtu: Option, + + /// name query parameter for /v2.0/networks API + #[builder(default, setter(into))] + name: Option>, + + /// not-tags query parameter for /v2.0/networks API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/networks API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// provider:network_type query parameter for /v2.0/networks API + #[builder(default, setter(into))] + provider_network_type: Option>, + + /// provider:physical_network query parameter for /v2.0/networks API + #[builder(default, setter(into))] + provider_physical_network: Option>, + + /// provider:segmentation_id query parameter for /v2.0/networks API + #[builder(default)] + provider_segmentation_id: Option, + + /// qinq query parameter for /v2.0/networks API + #[builder(default)] + qinq: Option, + + /// revision_number query parameter for /v2.0/networks API + #[builder(default, setter(into))] + revision_number: Option>, + + /// router:external query parameter for /v2.0/networks API + #[builder(default)] + router_external: Option, + + /// shared query parameter for /v2.0/networks API + #[builder(default)] + shared: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// status query parameter for /v2.0/networks API + #[builder(default, setter(into))] + status: Option>, + + /// tags query parameter for /v2.0/networks API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/networks API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/networks API + #[builder(default, setter(into))] + tenant_id: Option>, + + /// vlan_transparent query parameter for /v2.0/networks API + #[builder(default)] + vlan_transparent: 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> { + /// not-tags query parameter for /v2.0/networks API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/networks API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/networks API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/networks API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "networks".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("is_default", self.is_default); + params.push_opt("mtu", self.mtu); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("provider:network_type", self.provider_network_type.as_ref()); + params.push_opt( + "provider:physical_network", + self.provider_physical_network.as_ref(), + ); + params.push_opt("provider:segmentation_id", self.provider_segmentation_id); + params.push_opt("qinq", self.qinq); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("router:external", self.router_external); + params.push_opt("shared", self.shared); + params.push_opt("status", self.status.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + params.push_opt("vlan_transparent", self.vlan_transparent); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("networks".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "networks" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/networks".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "networks": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/networks".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "networks": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/set.rs b/sdk/network/src/v2/network/set.rs new file mode 100644 index 000000000..e2930ec03 --- /dev/null +++ b/sdk/network/src/v2/network/set.rs @@ -0,0 +1,338 @@ +// 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`. + +//! Updates a network. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Segments<'a> { + #[serde( + rename = "provider:network_type", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_network_type: Option>, + + #[serde( + rename = "provider:physical_network", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_physical_network: Option>, + + #[serde( + rename = "provider:segmentation_id", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_segmentation_id: Option, +} + +/// A `network` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Network<'a> { + /// The administrative state of the network, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// A valid DNS domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_domain: Option>, + + /// The network is default or not. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_default: Option, + + /// The maximum transmission unit (MTU) value to address fragmentation. + /// Minimum value is 68 for IPv4, and 1280 for IPv6. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) mtu: Option, + + /// Human-readable name of the network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The port security status of the network. Valid values are enabled + /// (`true`) and disabled (`false`). This value is used as the default + /// value of `port_security_enabled` field of a newly created port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_security_enabled: Option, + + /// The type of physical network that this network is mapped to. For + /// example, `flat`, `vlan`, `vxlan`, or `gre`. Valid values depend on a + /// networking back-end. + #[serde( + rename = "provider:network_type", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_network_type: Option>, + + /// The physical network where this network/segment is implemented. + #[serde( + rename = "provider:physical_network", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_physical_network: Option>, + + /// The ID of the isolated segment on the physical network. The + /// `network_type` attribute defines the segmentation model. For example, + /// if the `network_type` value is vlan, this ID is a vlan identifier. If + /// the `network_type` value is gre, this ID is a gre key. `Note` that only + /// the segmentation-id of VLAN type networks can be changed! + #[serde( + rename = "provider:segmentation_id", + skip_serializing_if = "Option::is_none" + )] + #[builder(default, setter(into))] + pub(crate) provider_segmentation_id: Option>, + + /// The ID of the QoS policy associated with the network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, + + /// Indicates whether the network has an external routing facility that’s + /// not managed by the networking service. + #[serde(rename = "router:external", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) router_external: Option, + + /// A list of provider `segment` objects. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) segments: Option>>, + + /// Indicates whether this resource is shared across all projects. By + /// default, only administrative users can change this value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `network` object. + #[builder(setter(into))] + pub(crate) network: Network<'a>, + + /// network_id parameter for /v2.0/networks/{network_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<'a> RequestBuilder<'a> { + /// Add a single header to the Network. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("networks/{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("network", serde_json::to_value(&self.network)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .network(NetworkBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .network(NetworkBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "network" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/networks/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network(NetworkBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/networks/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network(NetworkBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/network/tag.rs b/sdk/network/src/v2/network/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/network/tag.rs rename to sdk/network/src/v2/network/tag.rs diff --git a/sdk/network/src/v2/network/tag/delete.rs b/sdk/network/src/v2/network/tag/delete.rs new file mode 100644 index 000000000..7d5716ab1 --- /dev/null +++ b/sdk/network/src/v2/network/tag/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + network_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "networks/{network_id}/tags/{id}", + id = self.id.as_ref(), + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/networks/{network_id}/tags/{id}", + id = "id", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_id("network_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/networks/{network_id}/tags/{id}", + id = "id", + network_id = "network_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") + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/tag/delete_all.rs b/sdk/network/src/v2/network/tag/delete_all.rs new file mode 100644 index 000000000..0037c20ae --- /dev/null +++ b/sdk/network/src/v2/network/tag/delete_all.rs @@ -0,0 +1,188 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + network_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "networks/{network_id}/tags", + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/networks/{network_id}/tags", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().network_id("network_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/networks/{network_id}/tags", + network_id = "network_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() + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/tag/get.rs b/sdk/network/src/v2/network/tag/get.rs new file mode 100644 index 000000000..d1c308721 --- /dev/null +++ b/sdk/network/src/v2/network/tag/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + network_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "networks/{network_id}/tags/{id}", + id = self.id.as_ref(), + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/networks/{network_id}/tags/{id}", + id = "id", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_id("network_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/networks/{network_id}/tags/{id}", + id = "id", + network_id = "network_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") + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/tag/list.rs b/sdk/network/src/v2/network/tag/list.rs new file mode 100644 index 000000000..500f2bacc --- /dev/null +++ b/sdk/network/src/v2/network/tag/list.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + network_id: Cow<'a, str>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "networks/{network_id}/tags", + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/networks/{network_id}/tags", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().network_id("network_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/networks/{network_id}/tags", + network_id = "network_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/tag/replace.rs b/sdk/network/src/v2/network/tag/replace.rs new file mode 100644 index 000000000..8ed5876f7 --- /dev/null +++ b/sdk/network/src/v2/network/tag/replace.rs @@ -0,0 +1,216 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + network_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "networks/{network_id}/tags", + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/networks/{network_id}/tags", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .network_id("network_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/networks/{network_id}/tags", + network_id = "network_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .network_id("network_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network/tag/set.rs b/sdk/network/src/v2/network/tag/set.rs new file mode 100644 index 000000000..ed95a1735 --- /dev/null +++ b/sdk/network/src/v2/network/tag/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_id parameter for /v2.0/networks/{network_id}/tags/{id} API + #[builder(default, setter(into))] + network_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "networks/{network_id}/tags/{id}", + id = self.id.as_ref(), + network_id = self.network_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/networks/{network_id}/tags/{id}", + id = "id", + network_id = "network_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_id("network_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/networks/{network_id}/tags/{id}", + id = "id", + network_id = "network_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") + .network_id("network_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/network_ip_availability.rs b/sdk/network/src/v2/network_ip_availability.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/network_ip_availability.rs rename to sdk/network/src/v2/network_ip_availability.rs diff --git a/sdk/network/src/v2/network_ip_availability/create.rs b/sdk/network/src/v2/network_ip_availability/create.rs new file mode 100644 index 000000000..d57a56e1b --- /dev/null +++ b/sdk/network/src/v2/network_ip_availability/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_network_ip_availability"))] + pub(crate) network_ip_availability: BTreeMap, Value>, + + #[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 network_ip_availability(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.network_ip_availability + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Network_Ip_Availability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "network-ip-availabilities".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "network_ip_availability", + serde_json::to_value(&self.network_ip_availability)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_ip_availability".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .network_ip_availability(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .network_ip_availability(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "network_ip_availability" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/network-ip-availabilities".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availability": {} })); + }); + + let endpoint = Request::builder() + .network_ip_availability(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/network-ip-availabilities".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availability": {} })); + }); + + let endpoint = Request::builder() + .network_ip_availability(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_ip_availability/delete.rs b/sdk/network/src/v2/network_ip_availability/delete.rs new file mode 100644 index 000000000..cc0f9f0fb --- /dev/null +++ b/sdk/network/src/v2/network_ip_availability/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/network-ip-availabilities/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Network_Ip_Availability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("network-ip-availabilities/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/network-ip-availabilities/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/network-ip-availabilities/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_ip_availability/get.rs b/sdk/network/src/v2/network_ip_availability/get.rs new file mode 100644 index 000000000..1a8dd84b2 --- /dev/null +++ b/sdk/network/src/v2/network_ip_availability/get.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Shows network IP availability details for a network. +//! +//! By default policy configuration, only administrative users can retrieve IP +//! availability. Otherwise, `Not Found (404)` will be returned. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/network-ip-availabilities/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Network_Ip_Availability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("network-ip-availabilities/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_ip_availability".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "network_ip_availability" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/network-ip-availabilities/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availability": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/network-ip-availabilities/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availability": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_ip_availability/list.rs b/sdk/network/src/v2/network_ip_availability/list.rs new file mode 100644 index 000000000..254f1e7a0 --- /dev/null +++ b/sdk/network/src/v2/network_ip_availability/list.rs @@ -0,0 +1,287 @@ +// 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`. + +//! Lists network IP availability of all networks. +//! +//! By default policy configuration, only administrative users can retrieve IP +//! availabilities. Otherwise, an empty list will be returned. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// ip_version query parameter for /v2.0/network-ip-availabilities API + #[builder(default, setter(into))] + ip_version: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// network_id query parameter for /v2.0/network-ip-availabilities API + #[builder(default, setter(into))] + network_id: Option>, + + /// network_name query parameter for /v2.0/network-ip-availabilities API + #[builder(default, setter(into))] + network_name: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tenant_id query parameter for /v2.0/network-ip-availabilities API + #[builder(default, setter(into))] + tenant_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Network_Ip_Availability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "network-ip-availabilities".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("ip_version", self.ip_version.as_ref()); + params.push_opt("network_id", self.network_id.as_ref()); + params.push_opt("network_name", self.network_name.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_ip_availabilities".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "network_ip_availabilities" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/network-ip-availabilities".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availabilities": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/network-ip-availabilities".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availabilities": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_ip_availability/set.rs b/sdk/network/src/v2/network_ip_availability/set.rs new file mode 100644 index 000000000..96aa313ab --- /dev/null +++ b/sdk/network/src/v2/network_ip_availability/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_network_ip_availability"))] + pub(crate) network_ip_availability: BTreeMap, Value>, + + /// id parameter for /v2.0/network-ip-availabilities/{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<'a> RequestBuilder<'a> { + pub fn network_ip_availability(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.network_ip_availability + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Network_Ip_Availability. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("network-ip-availabilities/{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( + "network_ip_availability", + serde_json::to_value(&self.network_ip_availability)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_ip_availability".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .network_ip_availability(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .network_ip_availability(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "network_ip_availability" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/network-ip-availabilities/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availability": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_ip_availability(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/network-ip-availabilities/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_ip_availability": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_ip_availability(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range.rs b/sdk/network/src/v2/network_segment_range.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/network_segment_range.rs rename to sdk/network/src/v2/network_segment_range.rs diff --git a/sdk/network/src/v2/network_segment_range/create.rs b/sdk/network/src/v2/network_segment_range/create.rs new file mode 100644 index 000000000..1e5154943 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/create.rs @@ -0,0 +1,254 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum NetworkType { + #[serde(rename = "geneve")] + Geneve, + #[serde(rename = "gre")] + Gre, + #[serde(rename = "vlan")] + Vlan, + #[serde(rename = "vxlan")] + Vxlan, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct NetworkSegmentRange<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) network_type: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) physical_network: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) network_segment_range: NetworkSegmentRange<'a>, + + #[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 Network_Segment_Range. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "network-segment-ranges".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "network_segment_range", + serde_json::to_value(&self.network_segment_range)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_segment_range".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "network_segment_range" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/network-segment-ranges".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_range": {} })); + }); + + let endpoint = Request::builder() + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/network-segment-ranges".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_range": {} })); + }); + + let endpoint = Request::builder() + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/delete.rs b/sdk/network/src/v2/network_segment_range/delete.rs new file mode 100644 index 000000000..15bce2b22 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/network-segment-ranges/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Network_Segment_Range. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("network-segment-ranges/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/network-segment-ranges/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/network-segment-ranges/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/find.rs b/sdk/network/src/v2/network_segment_range/find.rs new file mode 100644 index 000000000..3fa587494 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::network_segment_range::{get as Get, list as List}; + +/// Find for network_segment_range 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/network_segment_range/get.rs b/sdk/network/src/v2/network_segment_range/get.rs new file mode 100644 index 000000000..feaae4be8 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/network-segment-ranges/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Network_Segment_Range. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("network-segment-ranges/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_segment_range".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "network_segment_range" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/network-segment-ranges/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_range": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/network-segment-ranges/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_range": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/list.rs b/sdk/network/src/v2/network_segment_range/list.rs new file mode 100644 index 000000000..caeee56c8 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/list.rs @@ -0,0 +1,353 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/network-segment-ranges API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/network-segment-ranges API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/network-segment-ranges API + #[builder(default, setter(into))] + name: Option>, + + /// network_type query parameter for /v2.0/network-segment-ranges API + #[builder(default, setter(into))] + network_type: Option>, + + /// not-tags query parameter for /v2.0/network-segment-ranges API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/network-segment-ranges API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// physical_network query parameter for /v2.0/network-segment-ranges API + #[builder(default, setter(into))] + physical_network: Option>, + + /// project_id query parameter for /v2.0/network-segment-ranges API + #[builder(default, setter(into))] + project_id: Option>, + + /// revision_number query parameter for /v2.0/network-segment-ranges API + #[builder(default, setter(into))] + revision_number: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tags query parameter for /v2.0/network-segment-ranges API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/network-segment-ranges API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: 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> { + /// not-tags query parameter for /v2.0/network-segment-ranges API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/network-segment-ranges API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/network-segment-ranges API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/network-segment-ranges API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Network_Segment_Range. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "network-segment-ranges".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("network_type", self.network_type.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("physical_network", self.physical_network.as_ref()); + params.push_opt("project_id", self.project_id.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_segment_ranges".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "network_segment_ranges" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/network-segment-ranges".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_ranges": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/network-segment-ranges".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_ranges": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/set.rs b/sdk/network/src/v2/network_segment_range/set.rs new file mode 100644 index 000000000..f7b3ac14d --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/set.rs @@ -0,0 +1,232 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct NetworkSegmentRange<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) maximum: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) minimum: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) network_segment_range: NetworkSegmentRange<'a>, + + /// id parameter for /v2.0/network-segment-ranges/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Network_Segment_Range. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("network-segment-ranges/{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( + "network_segment_range", + serde_json::to_value(&self.network_segment_range)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("network_segment_range".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "network_segment_range" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/network-segment-ranges/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_range": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/network-segment-ranges/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "network_segment_range": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_segment_range(NetworkSegmentRangeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/network_segment_range/tag.rs b/sdk/network/src/v2/network_segment_range/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/network_segment_range/tag.rs rename to sdk/network/src/v2/network_segment_range/tag.rs diff --git a/sdk/network/src/v2/network_segment_range/tag/delete.rs b/sdk/network/src/v2/network_segment_range/tag/delete.rs new file mode 100644 index 000000000..99a0241cf --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/tag/delete.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_segment_range_id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + network_segment_range_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = self.id.as_ref(), + network_segment_range_id = self.network_segment_range_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = "id", + network_segment_range_id = "network_segment_range_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_segment_range_id("network_segment_range_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = "id", + network_segment_range_id = "network_segment_range_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") + .network_segment_range_id("network_segment_range_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/tag/delete_all.rs b/sdk/network/src/v2/network_segment_range/tag/delete_all.rs new file mode 100644 index 000000000..2866df9b0 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/tag/delete_all.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// network_segment_range_id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + network_segment_range_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = self.network_segment_range_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = "network_segment_range_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .network_segment_range_id("network_segment_range_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = "network_segment_range_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() + .network_segment_range_id("network_segment_range_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/tag/get.rs b/sdk/network/src/v2/network_segment_range/tag/get.rs new file mode 100644 index 000000000..632e8cbe3 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/tag/get.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_segment_range_id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + network_segment_range_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = self.id.as_ref(), + network_segment_range_id = self.network_segment_range_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = "id", + network_segment_range_id = "network_segment_range_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_segment_range_id("network_segment_range_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = "id", + network_segment_range_id = "network_segment_range_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") + .network_segment_range_id("network_segment_range_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/tag/list.rs b/sdk/network/src/v2/network_segment_range/tag/list.rs new file mode 100644 index 000000000..168a6de98 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/tag/list.rs @@ -0,0 +1,263 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// network_segment_range_id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + network_segment_range_id: Cow<'a, str>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = self.network_segment_range_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = "network_segment_range_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .network_segment_range_id("network_segment_range_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = "network_segment_range_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .network_segment_range_id("network_segment_range_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/tag/replace.rs b/sdk/network/src/v2/network_segment_range/tag/replace.rs new file mode 100644 index 000000000..972b86b27 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/tag/replace.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// network_segment_range_id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + network_segment_range_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = self.network_segment_range_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = "network_segment_range_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .network_segment_range_id("network_segment_range_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags", + network_segment_range_id = "network_segment_range_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .network_segment_range_id("network_segment_range_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/network_segment_range/tag/set.rs b/sdk/network/src/v2/network_segment_range/tag/set.rs new file mode 100644 index 000000000..78095c326 --- /dev/null +++ b/sdk/network/src/v2/network_segment_range/tag/set.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// network_segment_range_id parameter for + /// /v2.0/network_segment_ranges/{network_segment_range_id}/tags/{id} API + #[builder(default, setter(into))] + network_segment_range_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = self.id.as_ref(), + network_segment_range_id = self.network_segment_range_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = "id", + network_segment_range_id = "network_segment_range_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .network_segment_range_id("network_segment_range_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/network_segment_ranges/{network_segment_range_id}/tags/{id}", + id = "id", + network_segment_range_id = "network_segment_range_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") + .network_segment_range_id("network_segment_range_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/policy.rs b/sdk/network/src/v2/policy.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/policy.rs rename to sdk/network/src/v2/policy.rs diff --git a/openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule.rs b/sdk/network/src/v2/policy/packet_rate_limit_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/policy/packet_rate_limit_rule.rs rename to sdk/network/src/v2/policy/packet_rate_limit_rule.rs diff --git a/sdk/network/src/v2/policy/packet_rate_limit_rule/create.rs b/sdk/network/src/v2/policy/packet_rate_limit_rule/create.rs new file mode 100644 index 000000000..7fc8d3505 --- /dev/null +++ b/sdk/network/src/v2/policy/packet_rate_limit_rule/create.rs @@ -0,0 +1,246 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PacketRateLimitRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_burst_kpps: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_kpps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) packet_rate_limit_rule: PacketRateLimitRule, + + /// policy_id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Packet_Rate_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "policies/{policy_id}/packet_rate_limit_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "packet_rate_limit_rule", + serde_json::to_value(&self.packet_rate_limit_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("packet_rate_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "packet_rate_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/policies/{policy_id}/packet_rate_limit_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/policies/{policy_id}/packet_rate_limit_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/packet_rate_limit_rule/delete.rs b/sdk/network/src/v2/policy/packet_rate_limit_rule/delete.rs new file mode 100644 index 000000000..61108596e --- /dev/null +++ b/sdk/network/src/v2/policy/packet_rate_limit_rule/delete.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Packet_Rate_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/packet_rate_limit_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/policies/{policy_id}/packet_rate_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/policies/{policy_id}/packet_rate_limit_rules/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/packet_rate_limit_rule/get.rs b/sdk/network/src/v2/policy/packet_rate_limit_rule/get.rs new file mode 100644 index 000000000..fbb0edd33 --- /dev/null +++ b/sdk/network/src/v2/policy/packet_rate_limit_rule/get.rs @@ -0,0 +1,205 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Packet_Rate_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/packet_rate_limit_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("packet_rate_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "packet_rate_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/packet_rate_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/packet_rate_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/packet_rate_limit_rule/list.rs b/sdk/network/src/v2/policy/packet_rate_limit_rule/list.rs new file mode 100644 index 000000000..cf13d310a --- /dev/null +++ b/sdk/network/src/v2/policy/packet_rate_limit_rule/list.rs @@ -0,0 +1,284 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// direction query parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API + #[builder(default, setter(into))] + direction: Option>, + + /// id query parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// max_burst_kpps query parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API + #[builder(default)] + max_burst_kpps: Option, + + /// max_kpps query parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules API + #[builder(default)] + max_kpps: Option, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// policy_id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Packet_Rate_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/packet_rate_limit_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("max_burst_kpps", self.max_burst_kpps); + params.push_opt("max_kpps", self.max_kpps); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("packet_rate_limit_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "packet_rate_limit_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/packet_rate_limit_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rules": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/packet_rate_limit_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rules": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/packet_rate_limit_rule/set.rs b/sdk/network/src/v2/policy/packet_rate_limit_rule/set.rs new file mode 100644 index 000000000..3ddc0907c --- /dev/null +++ b/sdk/network/src/v2/policy/packet_rate_limit_rule/set.rs @@ -0,0 +1,256 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct PacketRateLimitRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_burst_kpps: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_kpps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) packet_rate_limit_rule: PacketRateLimitRule, + + /// id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/policies/{policy_id}/packet_rate_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Packet_Rate_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/packet_rate_limit_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "packet_rate_limit_rule", + serde_json::to_value(&self.packet_rate_limit_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("packet_rate_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "packet_rate_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/policies/{policy_id}/packet_rate_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/policies/{policy_id}/packet_rate_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "packet_rate_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .packet_rate_limit_rule(PacketRateLimitRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/policy/tag.rs b/sdk/network/src/v2/policy/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/policy/tag.rs rename to sdk/network/src/v2/policy/tag.rs diff --git a/sdk/network/src/v2/policy/tag/delete.rs b/sdk/network/src/v2/policy/tag/delete.rs new file mode 100644 index 000000000..e9d3dc5cd --- /dev/null +++ b/sdk/network/src/v2/policy/tag/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + policy_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/tags/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/policies/{policy_id}/tags/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/policies/{policy_id}/tags/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/tag/delete_all.rs b/sdk/network/src/v2/policy/tag/delete_all.rs new file mode 100644 index 000000000..ce99c7fb2 --- /dev/null +++ b/sdk/network/src/v2/policy/tag/delete_all.rs @@ -0,0 +1,188 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + policy_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/tags", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/policies/{policy_id}/tags", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/policies/{policy_id}/tags", + policy_id = "policy_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() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/tag/get.rs b/sdk/network/src/v2/policy/tag/get.rs new file mode 100644 index 000000000..bd97c84d7 --- /dev/null +++ b/sdk/network/src/v2/policy/tag/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + policy_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/tags/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/tags/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/tags/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/tag/list.rs b/sdk/network/src/v2/policy/tag/list.rs new file mode 100644 index 000000000..959d163fe --- /dev/null +++ b/sdk/network/src/v2/policy/tag/list.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "policies/{policy_id}/tags", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/policies/{policy_id}/tags", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/policies/{policy_id}/tags", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/tag/replace.rs b/sdk/network/src/v2/policy/tag/replace.rs new file mode 100644 index 000000000..8d3f976e9 --- /dev/null +++ b/sdk/network/src/v2/policy/tag/replace.rs @@ -0,0 +1,216 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + policy_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/tags", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/policies/{policy_id}/tags", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/policies/{policy_id}/tags", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/policy/tag/set.rs b/sdk/network/src/v2/policy/tag/set.rs new file mode 100644 index 000000000..0756ac746 --- /dev/null +++ b/sdk/network/src/v2/policy/tag/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for /v2.0/policies/{policy_id}/tags/{id} API + #[builder(default, setter(into))] + policy_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "policies/{policy_id}/tags/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/policies/{policy_id}/tags/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/policies/{policy_id}/tags/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/port.rs b/sdk/network/src/v2/port.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/port.rs rename to sdk/network/src/v2/port.rs diff --git a/openstack_sdk/src/api/network/v2/port/add_allowed_address_pairs.rs b/sdk/network/src/v2/port/add_allowed_address_pairs.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/port/add_allowed_address_pairs.rs rename to sdk/network/src/v2/port/add_allowed_address_pairs.rs index 170669d36..50e77fe02 100644 --- a/openstack_sdk/src/api/network/v2/port/add_allowed_address_pairs.rs +++ b/sdk/network/src/v2/port/add_allowed_address_pairs.rs @@ -148,7 +148,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/port/binding.rs b/sdk/network/src/v2/port/binding.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/port/binding.rs rename to sdk/network/src/v2/port/binding.rs diff --git a/openstack_sdk/src/api/network/v2/port/binding/activate.rs b/sdk/network/src/v2/port/binding/activate.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/port/binding/activate.rs rename to sdk/network/src/v2/port/binding/activate.rs index 68c58b32f..4abcd453c 100644 --- a/openstack_sdk/src/api/network/v2/port/binding/activate.rs +++ b/sdk/network/src/v2/port/binding/activate.rs @@ -134,7 +134,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/network/src/v2/port/binding/create.rs b/sdk/network/src/v2/port/binding/create.rs new file mode 100644 index 000000000..017d05d50 --- /dev/null +++ b/sdk/network/src/v2/port/binding/create.rs @@ -0,0 +1,273 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum VnicType { + #[serde(rename = "accelerator-direct")] + AcceleratorDirect, + #[serde(rename = "accelerator-direct-physical")] + AcceleratorDirectPhysical, + #[serde(rename = "baremetal")] + Baremetal, + #[serde(rename = "direct")] + Direct, + #[serde(rename = "direct-physical")] + DirectPhysical, + #[serde(rename = "macvtap")] + Macvtap, + #[serde(rename = "normal")] + Normal, + #[serde(rename = "remote-managed")] + RemoteManaged, + #[serde(rename = "smart-nic")] + SmartNic, + #[serde(rename = "vdpa")] + Vdpa, + #[serde(rename = "virtio-forwarder")] + VirtioForwarder, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Binding<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_profile"))] + pub(crate) profile: Option, Value>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) vnic_type: Option, +} + +impl<'a> BindingBuilder<'a> { + pub fn profile(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.profile + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) binding: Binding<'a>, + + /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + port_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 Binding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!("ports/{port_id}/bindings", port_id = self.port_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("binding", serde_json::to_value(&self.binding)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("binding".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .binding(BindingBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .binding(BindingBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "binding" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "binding": {} })); + }); + + let endpoint = Request::builder() + .port_id("port_id") + .binding(BindingBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "binding": {} })); + }); + + let endpoint = Request::builder() + .port_id("port_id") + .binding(BindingBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/binding/delete.rs b/sdk/network/src/v2/port/binding/delete.rs new file mode 100644 index 000000000..f12eaaa53 --- /dev/null +++ b/sdk/network/src/v2/port/binding/delete.rs @@ -0,0 +1,204 @@ +// 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`. + +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + port_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 Binding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "ports/{port_id}/bindings/{id}", + id = self.id.as_ref(), + port_id = self.port_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/ports/{port_id}/bindings/{id}", + id = "id", + port_id = "port_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/ports/{port_id}/bindings/{id}", + id = "id", + port_id = "port_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") + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/binding/get.rs b/sdk/network/src/v2/port/binding/get.rs new file mode 100644 index 000000000..f5113bef7 --- /dev/null +++ b/sdk/network/src/v2/port/binding/get.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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + port_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 Binding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "ports/{port_id}/bindings/{id}", + id = self.id.as_ref(), + port_id = self.port_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("binding".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "binding" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/ports/{port_id}/bindings/{id}", + id = "id", + port_id = "port_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "binding": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/ports/{port_id}/bindings/{id}", + id = "id", + port_id = "port_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "binding": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/binding/list.rs b/sdk/network/src/v2/port/binding/list.rs new file mode 100644 index 000000000..48a714019 --- /dev/null +++ b/sdk/network/src/v2/port/binding/list.rs @@ -0,0 +1,277 @@ +// 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 the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// host query parameter for /v2.0/ports/{port_id}/bindings API + #[builder(default, setter(into))] + host: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + port_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// status query parameter for /v2.0/ports/{port_id}/bindings API + #[builder(default, setter(into))] + status: Option>, + + /// vif_type query parameter for /v2.0/ports/{port_id}/bindings API + #[builder(default, setter(into))] + vif_type: Option>, + + /// vnic_type query parameter for /v2.0/ports/{port_id}/bindings API + #[builder(default, setter(into))] + vnic_type: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Binding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("ports/{port_id}/bindings", port_id = self.port_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("host", self.host.as_ref()); + params.push_opt("status", self.status.as_ref()); + params.push_opt("vif_type", self.vif_type.as_ref()); + params.push_opt("vnic_type", self.vnic_type.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("bindings".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "bindings" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bindings": {} })); + }); + + let endpoint = Request::builder().port_id("port_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ports/{port_id}/bindings", port_id = "port_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bindings": {} })); + }); + + let endpoint = Request::builder() + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/binding/set.rs b/sdk/network/src/v2/port/binding/set.rs new file mode 100644 index 000000000..f760f69a2 --- /dev/null +++ b/sdk/network/src/v2/port/binding/set.rs @@ -0,0 +1,287 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum VnicType { + #[serde(rename = "accelerator-direct")] + AcceleratorDirect, + #[serde(rename = "accelerator-direct-physical")] + AcceleratorDirectPhysical, + #[serde(rename = "baremetal")] + Baremetal, + #[serde(rename = "direct")] + Direct, + #[serde(rename = "direct-physical")] + DirectPhysical, + #[serde(rename = "macvtap")] + Macvtap, + #[serde(rename = "normal")] + Normal, + #[serde(rename = "remote-managed")] + RemoteManaged, + #[serde(rename = "smart-nic")] + SmartNic, + #[serde(rename = "vdpa")] + Vdpa, + #[serde(rename = "virtio-forwarder")] + VirtioForwarder, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Binding<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_profile"))] + pub(crate) profile: Option, Value>>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) vnic_type: Option, +} + +impl<'a> BindingBuilder<'a> { + pub fn profile(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.profile + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) binding: Binding<'a>, + + /// id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API + #[builder(default, setter(into))] + port_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 Binding. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "ports/{port_id}/bindings/{id}", + id = self.id.as_ref(), + port_id = self.port_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("binding", serde_json::to_value(&self.binding)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("binding".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .binding(BindingBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .binding(BindingBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "binding" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/ports/{port_id}/bindings/{id}", + id = "id", + port_id = "port_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "binding": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .binding(BindingBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/ports/{port_id}/bindings/{id}", + id = "id", + port_id = "port_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "binding": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .binding(BindingBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/create.rs b/sdk/network/src/v2/port/create.rs new file mode 100644 index 000000000..3fa64b70b --- /dev/null +++ b/sdk/network/src/v2/port/create.rs @@ -0,0 +1,518 @@ +// 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`. + +//! Creates a port on a network. +//! +//! To define the network in which to create the port, specify the `network_id` +//! attribute in the request body. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllowedAddressPairs<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_address: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum BindingVnicType { + #[serde(rename = "accelerator-direct")] + AcceleratorDirect, + #[serde(rename = "accelerator-direct-physical")] + AcceleratorDirectPhysical, + #[serde(rename = "baremetal")] + Baremetal, + #[serde(rename = "direct")] + Direct, + #[serde(rename = "direct-physical")] + DirectPhysical, + #[serde(rename = "macvtap")] + Macvtap, + #[serde(rename = "normal")] + Normal, + #[serde(rename = "remote-managed")] + RemoteManaged, + #[serde(rename = "smart-nic")] + SmartNic, + #[serde(rename = "vdpa")] + Vdpa, + #[serde(rename = "virtio-forwarder")] + VirtioForwarder, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct FixedIps<'a> { + /// IP Address + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>, + + /// The subnet ID from which the IP address is assigned + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum NumaAffinityPolicy { + #[serde(rename = "legacy")] + Legacy, + #[serde(rename = "preferred")] + Preferred, + #[serde(rename = "required")] + Required, + #[serde(rename = "socket")] + Socket, +} + +/// A `port` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Port<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A set of zero or more allowed address pair objects each where address + /// pair object contains an `ip_address` and `mac_address`. While the + /// `ip_address` is required, the `mac_address` will be taken from the port + /// if not specified. The value of `ip_address` can be an IP Address or a + /// CIDR (if supported by the underlying extension plugin). A server + /// connected to the port can send a packet with source address which + /// matches one of the specified allowed address pairs. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allowed_address_pairs: Option>>, + + /// The ID of the host where the port resides. The default is an empty + /// string. + #[serde(rename = "binding:host_id", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) binding_host_id: Option>, + + /// A dictionary that enables the application running on the specific host + /// to pass and receive vif port information specific to the networking + /// back-end. This field is only meant for machine-machine communication + /// for compute services like Nova, Ironic or Zun to pass information to a + /// Neutron back-end. It should not be used by multiple services + /// concurrently or by cloud end users. The existing counterexamples + /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and + /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. + /// The networking API does not define a specific format of this field. The + /// default is an empty dictionary. If you update it with null then it is + /// treated like {} in the response. Since the port-mac-address-override + /// extension the `device_mac_address` field of the binding:profile can be + /// used to provide the MAC address of the physical device a + /// direct-physical port is being bound to. If provided, then the + /// `mac_address` field of the port resource will be updated to the MAC + /// from the active binding. + #[serde(rename = "binding:profile", skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_binding_profile"))] + pub(crate) binding_profile: Option, Value>>>, + + /// The type of vNIC which this port should be attached to. This is used to + /// determine which mechanism driver(s) to be used to bind the port. The + /// valid values are `normal`, `macvtap`, `direct`, `baremetal`, + /// `direct-physical`, `virtio-forwarder`, `smart-nic` and + /// `remote-managed`. What type of vNIC is actually available depends on + /// deployments. The default is `normal`. + #[serde(rename = "binding:vnic_type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) binding_vnic_type: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The ID of the device that uses this port. For example, a server + /// instance or a logical router. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_id: Option>, + + /// The entity type that uses this port. For example, `compute:nova` + /// (server instance), `network:dhcp` (DHCP agent) or + /// `network:router_interface` (router interface). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_owner: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_profile: Option>>, + + /// A valid DNS domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_domain: Option>, + + /// A valid DNS name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_name: Option>, + + /// A set of zero or more extra DHCP option pairs. An option pair consists + /// of an option value and name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) extra_dhcp_opts: Option, Value>>>, + + /// The IP addresses for the port. If you would like to assign multiple IP + /// addresses for the port, specify multiple entries in this field. Each + /// entry consists of IP address (`ip_address`) and the subnet ID from + /// which the IP address is assigned (`subnet_id`). + /// + /// - If you specify both a subnet ID and an IP address, OpenStack + /// Networking tries to allocate the IP address on that subnet to the + /// port. + /// - If you specify only a subnet ID, OpenStack Networking allocates an + /// available IP from that subnet to the port. + /// - If you specify only an IP address, OpenStack Networking tries to + /// allocate the IP address if the address is a valid IP for any of the + /// subnets on the specified network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ips: Option>>, + + /// Admin-only. A dict, at the top level keyed by mechanism driver aliases + /// (as defined in setup.cfg). To following values can be used to control + /// Open vSwitch’s Userspace Tx packet steering feature: + /// + /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` + /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` + /// + /// If omitted the default is defined by Open vSwitch. The field cannot be + /// longer than 4095 characters. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_hints"))] + pub(crate) hints: Option, Value>>>, + + /// The MAC address of the port. If unspecified, a MAC address is + /// automatically generated. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) mac_address: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the attached network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) network_id: Option>, + + /// The port NUMA affinity policy requested during the virtual machine + /// scheduling. Values: `None`, `required`, `preferred` or `legacy`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) numa_affinity_policy: Option, + + /// The port security status. A valid value is enabled (`true`) or disabled + /// (`false`). If port security is enabled for the port, security group + /// rules and anti-spoofing rules are applied to the traffic on the port. + /// If disabled, no such rules are applied. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_security_enabled: Option, + + /// The uplink status propagation of the port. Valid values are enabled + /// (`true`) and disabled (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) propagate_uplink_status: Option, + + /// QoS policy associated with the port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, + + /// The IDs of security groups applied to the port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_groups: Option>>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tags: Option>>, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +impl<'a> PortBuilder<'a> { + /// A dictionary that enables the application running on the specific host + /// to pass and receive vif port information specific to the networking + /// back-end. This field is only meant for machine-machine communication + /// for compute services like Nova, Ironic or Zun to pass information to a + /// Neutron back-end. It should not be used by multiple services + /// concurrently or by cloud end users. The existing counterexamples + /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and + /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. + /// The networking API does not define a specific format of this field. The + /// default is an empty dictionary. If you update it with null then it is + /// treated like {} in the response. Since the port-mac-address-override + /// extension the `device_mac_address` field of the binding:profile can be + /// used to provide the MAC address of the physical device a + /// direct-physical port is being bound to. If provided, then the + /// `mac_address` field of the port resource will be updated to the MAC + /// from the active binding. + pub fn binding_profile(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.binding_profile + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Admin-only. A dict, at the top level keyed by mechanism driver aliases + /// (as defined in setup.cfg). To following values can be used to control + /// Open vSwitch’s Userspace Tx packet steering feature: + /// + /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` + /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` + /// + /// If omitted the default is defined by Open vSwitch. The field cannot be + /// longer than 4095 characters. + pub fn hints(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.hints + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `port` object. + #[builder(setter(into))] + pub(crate) port: Port<'a>, + + #[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 Port. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "ports".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("port", serde_json::to_value(&self.port)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .port(PortBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .port(PortBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "port" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/ports".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port": {} })); + }); + + let endpoint = Request::builder() + .port(PortBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/ports".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port": {} })); + }); + + let endpoint = Request::builder() + .port(PortBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/delete.rs b/sdk/network/src/v2/port/delete.rs new file mode 100644 index 000000000..af88d6fd7 --- /dev/null +++ b/sdk/network/src/v2/port/delete.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Deletes a port. +//! +//! Any IP addresses that are associated with the port are returned to the +//! respective subnets allocation pools. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// port_id parameter for /v2.0/ports/{port_id}/add_allowed_address_pairs + /// 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<'a> RequestBuilder<'a> { + /// Add a single header to the Port. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("ports/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/ports/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/ports/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/find.rs b/sdk/network/src/v2/port/find.rs new file mode 100644 index 000000000..b769ad3f5 --- /dev/null +++ b/sdk/network/src/v2/port/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::port::{get as Get, list as List}; + +/// Find for port 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/port/get.rs b/sdk/network/src/v2/port/get.rs new file mode 100644 index 000000000..6ac7332cf --- /dev/null +++ b/sdk/network/src/v2/port/get.rs @@ -0,0 +1,192 @@ +// 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`. + +//! Shows details for a port. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// port_id parameter for /v2.0/ports/{port_id}/add_allowed_address_pairs + /// 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<'a> RequestBuilder<'a> { + /// Add a single header to the Port. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("ports/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "port" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ports/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ports/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/list.rs b/sdk/network/src/v2/port/list.rs new file mode 100644 index 000000000..9941c02ff --- /dev/null +++ b/sdk/network/src/v2/port/list.rs @@ -0,0 +1,450 @@ +// 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`. + +//! Lists ports to which the user has access. +//! +//! Default policy settings return only those ports that are owned by the +//! project of the user who submits the request, unless the request is +//! submitted by a user with administrative rights. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! If the `ip-substring-filtering` extension is enabled, the Neutron API +//! supports IP address substring filtering on the `fixed_ips` attribute. If +//! you specify an IP address substring (`ip_address_substr`) in an entry of +//! the `fixed_ips` attribute, the Neutron API will list all ports that have an +//! IP address matching the substring. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// admin_state_up query parameter for /v2.0/ports API + #[builder(default)] + admin_state_up: Option, + + /// binding:host_id query parameter for /v2.0/ports API + #[builder(default, setter(into))] + binding_host_id: Option>, + + /// description query parameter for /v2.0/ports API + #[builder(default, setter(into))] + description: Option>, + + /// device_id query parameter for /v2.0/ports API + #[builder(default, setter(into))] + device_id: Option>, + + /// device_owner query parameter for /v2.0/ports API + #[builder(default, setter(into))] + device_owner: Option>, + + /// fixed_ips query parameter for /v2.0/ports API + #[builder(default, private, setter(name = "_fixed_ips"))] + fixed_ips: Option>>, + + /// id query parameter for /v2.0/ports API + #[builder(default, setter(into))] + id: Option>, + + /// ip_allocation query parameter for /v2.0/ports API + #[builder(default, setter(into))] + ip_allocation: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// mac_address query parameter for /v2.0/ports API + #[builder(default, setter(into))] + mac_address: Option>, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/ports API + #[builder(default, setter(into))] + name: Option>, + + /// network_id query parameter for /v2.0/ports API + #[builder(default, setter(into))] + network_id: Option>, + + /// not-tags query parameter for /v2.0/ports API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/ports API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// revision_number query parameter for /v2.0/ports API + #[builder(default, setter(into))] + revision_number: Option>, + + /// security_groups query parameter for /v2.0/ports API + #[builder(default, private, setter(name = "_security_groups"))] + security_groups: Option>>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// status query parameter for /v2.0/ports API + #[builder(default, setter(into))] + status: Option>, + + /// tags query parameter for /v2.0/ports API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/ports API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/ports API + #[builder(default, setter(into))] + tenant_id: 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> { + /// fixed_ips query parameter for /v2.0/ports API + pub fn fixed_ips(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.fixed_ips + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags query parameter for /v2.0/ports API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/ports API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// security_groups query parameter for /v2.0/ports API + pub fn security_groups(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.security_groups + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/ports API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/ports API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Port. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "ports".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("binding:host_id", self.binding_host_id.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("device_id", self.device_id.as_ref()); + params.push_opt("device_owner", self.device_owner.as_ref()); + params.push_opt("fixed_ips", self.fixed_ips.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("ip_allocation", self.ip_allocation.as_ref()); + params.push_opt("mac_address", self.mac_address.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("network_id", self.network_id.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + if let Some(val) = &self.security_groups { + params.extend(val.iter().map(|value| ("security_groups", value))); + } + params.push_opt("status", self.status.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ports".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ports" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/ports".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ports": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/ports".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ports": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/set.rs b/sdk/network/src/v2/port/set.rs new file mode 100644 index 000000000..763ed5a1d --- /dev/null +++ b/sdk/network/src/v2/port/set.rs @@ -0,0 +1,534 @@ +// 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`. + +//! Updates a port. +//! +//! You can update information for a port, such as its symbolic name and +//! associated IPs. When you update IPs for a port, any previously associated +//! IPs are removed, returned to the respective subnet allocation pools, and +//! replaced by the IPs in the request body. Therefore, this operation replaces +//! the `fixed_ip` attribute when you specify it in the request body. If the +//! updated IP addresses are not valid or are already in use, the operation +//! fails and the existing IP addresses are not removed from the port. +//! +//! When you update security groups for a port and the operation succeeds, any +//! associated security groups are removed and replaced by the security groups +//! in the request body. Therefore, this operation replaces the +//! `security_groups` attribute when you specify it in the request body. If the +//! security groups are not valid, the operation fails and the existing +//! security groups are not removed from the port. +//! +//! When you update `binding:profile` of a port with null it is treated as {} +//! in the response. +//! +//! The `binding:vnic_type` attribute can be updated on unbound ports only. If +//! the port is already bound, the update operation of the attribute returns +//! the `Conflict (409)` response code. +//! +//! Only admins and users with a specific role can update the data plane status +//! (default role: `data_plane_integrator`). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 409, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllowedAddressPairs<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_address: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum BindingVnicType { + #[serde(rename = "accelerator-direct")] + AcceleratorDirect, + #[serde(rename = "accelerator-direct-physical")] + AcceleratorDirectPhysical, + #[serde(rename = "baremetal")] + Baremetal, + #[serde(rename = "direct")] + Direct, + #[serde(rename = "direct-physical")] + DirectPhysical, + #[serde(rename = "macvtap")] + Macvtap, + #[serde(rename = "normal")] + Normal, + #[serde(rename = "remote-managed")] + RemoteManaged, + #[serde(rename = "smart-nic")] + SmartNic, + #[serde(rename = "vdpa")] + Vdpa, + #[serde(rename = "virtio-forwarder")] + VirtioForwarder, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum DataPlaneStatus { + #[serde(rename = "ACTIVE")] + Active, + #[serde(rename = "DOWN")] + Down, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct FixedIps<'a> { + /// IP Address + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>, + + /// The subnet ID from which the IP address is assigned + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum NumaAffinityPolicy { + #[serde(rename = "legacy")] + Legacy, + #[serde(rename = "preferred")] + Preferred, + #[serde(rename = "required")] + Required, + #[serde(rename = "socket")] + Socket, +} + +/// A `port` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Port<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A set of zero or more allowed address pair objects each where address + /// pair object contains an `ip_address` and `mac_address`. While the + /// `ip_address` is required, the `mac_address` will be taken from the port + /// if not specified. The value of `ip_address` can be an IP Address or a + /// CIDR (if supported by the underlying extension plugin). A server + /// connected to the port can send a packet with source address which + /// matches one of the specified allowed address pairs. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allowed_address_pairs: Option>>, + + /// The ID of the host where the port resides. The default is an empty + /// string. + #[serde(rename = "binding:host_id", skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) binding_host_id: Option>, + + /// A dictionary that enables the application running on the specific host + /// to pass and receive vif port information specific to the networking + /// back-end. This field is only meant for machine-machine communication + /// for compute services like Nova, Ironic or Zun to pass information to a + /// Neutron back-end. It should not be used by multiple services + /// concurrently or by cloud end users. The existing counterexamples + /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and + /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. + /// The networking API does not define a specific format of this field. The + /// default is an empty dictionary. If you update it with null then it is + /// treated like {} in the response. Since the port-mac-address-override + /// extension the `device_mac_address` field of the binding:profile can be + /// used to provide the MAC address of the physical device a + /// direct-physical port is being bound to. If provided, then the + /// `mac_address` field of the port resource will be updated to the MAC + /// from the active binding. + #[serde(rename = "binding:profile", skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_binding_profile"))] + pub(crate) binding_profile: Option, Value>>>, + + /// The type of vNIC which this port should be attached to. This is used to + /// determine which mechanism driver(s) to be used to bind the port. The + /// valid values are `normal`, `macvtap`, `direct`, `baremetal`, + /// `direct-physical`, `virtio-forwarder`, `smart-nic` and + /// `remote-managed`. What type of vNIC is actually available depends on + /// deployments. The default is `normal`. + #[serde(rename = "binding:vnic_type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) binding_vnic_type: Option, + + /// Status of the underlying data plane of a port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) data_plane_status: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The ID of the device that uses this port. For example, a server + /// instance or a logical router. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_id: Option>, + + /// The entity type that uses this port. For example, `compute:nova` + /// (server instance), `network:dhcp` (DHCP agent) or + /// `network:router_interface` (router interface). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) device_owner: Option>, + + /// A valid DNS domain. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_domain: Option>, + + /// A valid DNS name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_name: Option>, + + /// A set of zero or more extra DHCP option pairs. An option pair consists + /// of an option value and name. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) extra_dhcp_opts: Option, Value>>>, + + /// The IP addresses for the port. If you would like to assign multiple IP + /// addresses for the port, specify multiple entries in this field. Each + /// entry consists of IP address (`ip_address`) and the subnet ID from + /// which the IP address is assigned (`subnet_id`). + /// + /// - If you specify both a subnet ID and an IP address, OpenStack + /// Networking tries to allocate the IP address on that subnet to the + /// port. + /// - If you specify only a subnet ID, OpenStack Networking allocates an + /// available IP from that subnet to the port. + /// - If you specify only an IP address, OpenStack Networking tries to + /// allocate the IP address if the address is a valid IP for any of the + /// subnets on the specified network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) fixed_ips: Option>>, + + /// Admin-only. A dict, at the top level keyed by mechanism driver aliases + /// (as defined in setup.cfg). To following values can be used to control + /// Open vSwitch’s Userspace Tx packet steering feature: + /// + /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` + /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` + /// + /// If omitted the default is defined by Open vSwitch. The field cannot be + /// longer than 4095 characters. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_hints"))] + pub(crate) hints: Option, Value>>>, + + /// The MAC address of the port. By default, only administrative users and + /// users with advsvc role can change this value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) mac_address: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The port NUMA affinity policy requested during the virtual machine + /// scheduling. Values: `None`, `required`, `preferred` or `legacy`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) numa_affinity_policy: Option, + + /// The port security status. A valid value is enabled (`true`) or disabled + /// (`false`). If port security is enabled for the port, security group + /// rules and anti-spoofing rules are applied to the traffic on the port. + /// If disabled, no such rules are applied. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_security_enabled: Option, + + /// QoS policy associated with the port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, + + /// The IDs of security groups applied to the port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_groups: Option>>, +} + +impl<'a> PortBuilder<'a> { + /// A dictionary that enables the application running on the specific host + /// to pass and receive vif port information specific to the networking + /// back-end. This field is only meant for machine-machine communication + /// for compute services like Nova, Ironic or Zun to pass information to a + /// Neutron back-end. It should not be used by multiple services + /// concurrently or by cloud end users. The existing counterexamples + /// (`capabilities: [switchdev]` for Open vSwitch hardware offload and + /// `trusted=true` for Trusted Virtual Functions) are due to be cleaned up. + /// The networking API does not define a specific format of this field. The + /// default is an empty dictionary. If you update it with null then it is + /// treated like {} in the response. Since the port-mac-address-override + /// extension the `device_mac_address` field of the binding:profile can be + /// used to provide the MAC address of the physical device a + /// direct-physical port is being bound to. If provided, then the + /// `mac_address` field of the port resource will be updated to the MAC + /// from the active binding. + pub fn binding_profile(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.binding_profile + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Admin-only. A dict, at the top level keyed by mechanism driver aliases + /// (as defined in setup.cfg). To following values can be used to control + /// Open vSwitch’s Userspace Tx packet steering feature: + /// + /// - `{"openvswitch": {"other_config": {"tx-steering": "hash"}}}` + /// - `{"openvswitch": {"other_config": {"tx-steering": "thread"}}}` + /// + /// If omitted the default is defined by Open vSwitch. The field cannot be + /// longer than 4095 characters. + pub fn hints(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.hints + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `port` object. + #[builder(setter(into))] + pub(crate) port: Port<'a>, + + /// port_id parameter for /v2.0/ports/{port_id}/add_allowed_address_pairs + /// 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<'a> RequestBuilder<'a> { + /// Add a single header to the Port. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("ports/{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("port", serde_json::to_value(&self.port)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("port".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .port(PortBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .port(PortBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "port" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/ports/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port(PortBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/ports/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "port": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port(PortBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/port/tag.rs b/sdk/network/src/v2/port/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/port/tag.rs rename to sdk/network/src/v2/port/tag.rs diff --git a/sdk/network/src/v2/port/tag/delete.rs b/sdk/network/src/v2/port/tag/delete.rs new file mode 100644 index 000000000..50eb3239d --- /dev/null +++ b/sdk/network/src/v2/port/tag/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + port_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "ports/{port_id}/tags/{id}", + id = self.id.as_ref(), + port_id = self.port_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/ports/{port_id}/tags/{id}", + id = "id", + port_id = "port_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/ports/{port_id}/tags/{id}", + id = "id", + port_id = "port_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") + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/tag/delete_all.rs b/sdk/network/src/v2/port/tag/delete_all.rs new file mode 100644 index 000000000..914e1395d --- /dev/null +++ b/sdk/network/src/v2/port/tag/delete_all.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + port_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("ports/{port_id}/tags", port_id = self.port_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/ports/{port_id}/tags", port_id = "port_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().port_id("port_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/ports/{port_id}/tags", port_id = "port_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() + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/tag/get.rs b/sdk/network/src/v2/port/tag/get.rs new file mode 100644 index 000000000..0d088f3d1 --- /dev/null +++ b/sdk/network/src/v2/port/tag/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + port_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "ports/{port_id}/tags/{id}", + id = self.id.as_ref(), + port_id = self.port_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/ports/{port_id}/tags/{id}", + id = "id", + port_id = "port_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/ports/{port_id}/tags/{id}", + id = "id", + port_id = "port_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") + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/tag/list.rs b/sdk/network/src/v2/port/tag/list.rs new file mode 100644 index 000000000..a345d50fd --- /dev/null +++ b/sdk/network/src/v2/port/tag/list.rs @@ -0,0 +1,250 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + port_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("ports/{port_id}/tags", port_id = self.port_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ports/{port_id}/tags", port_id = "port_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().port_id("port_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/ports/{port_id}/tags", port_id = "port_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/tag/replace.rs b/sdk/network/src/v2/port/tag/replace.rs new file mode 100644 index 000000000..05219d7d0 --- /dev/null +++ b/sdk/network/src/v2/port/tag/replace.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + port_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("ports/{port_id}/tags", port_id = self.port_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/ports/{port_id}/tags", port_id = "port_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .port_id("port_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/ports/{port_id}/tags", port_id = "port_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .port_id("port_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/port/tag/set.rs b/sdk/network/src/v2/port/tag/set.rs new file mode 100644 index 000000000..5a3b00492 --- /dev/null +++ b/sdk/network/src/v2/port/tag/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// port_id parameter for /v2.0/ports/{port_id}/tags/{id} API + #[builder(default, setter(into))] + port_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "ports/{port_id}/tags/{id}", + id = self.id.as_ref(), + port_id = self.port_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/ports/{port_id}/tags/{id}", + id = "id", + port_id = "port_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .port_id("port_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/ports/{port_id}/tags/{id}", + id = "id", + port_id = "port_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") + .port_id("port_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos.rs b/sdk/network/src/v2/qos.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos.rs rename to sdk/network/src/v2/qos.rs diff --git a/openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule.rs b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/alias_bandwidth_limit_rule.rs rename to sdk/network/src/v2/qos/alias_bandwidth_limit_rule.rs diff --git a/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/create.rs b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/create.rs new file mode 100644 index 000000000..bbadacb85 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_alias_bandwidth_limit_rule"))] + pub(crate) alias_bandwidth_limit_rule: BTreeMap, Value>, + + #[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 alias_bandwidth_limit_rule(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.alias_bandwidth_limit_rule + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Alias_Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-bandwidth-limit-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "alias_bandwidth_limit_rule", + serde_json::to_value(&self.alias_bandwidth_limit_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_bandwidth_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_bandwidth_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-bandwidth-limit-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-bandwidth-limit-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_bandwidth_limit_rule(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/delete.rs b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/delete.rs new file mode 100644 index 000000000..6e8bca417 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/delete.rs @@ -0,0 +1,183 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-bandwidth-limit-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/alias-bandwidth-limit-rules/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/alias-bandwidth-limit-rules/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/alias-bandwidth-limit-rules/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/get.rs b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/get.rs new file mode 100644 index 000000000..905e80f99 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/get.rs @@ -0,0 +1,186 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-bandwidth-limit-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/alias-bandwidth-limit-rules/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_bandwidth_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_bandwidth_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rule": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/list.rs b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/list.rs new file mode 100644 index 000000000..b1a3b39de --- /dev/null +++ b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/list.rs @@ -0,0 +1,266 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// direction query parameter for /v2.0/qos/alias-bandwidth-limit-rules API + #[builder(default, setter(into))] + direction: Option>, + + /// id query parameter for /v2.0/qos/alias-bandwidth-limit-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// max_burst_kbps query parameter for + /// /v2.0/qos/alias-bandwidth-limit-rules API + #[builder(default)] + max_burst_kbps: Option, + + /// max_kbps query parameter for /v2.0/qos/alias-bandwidth-limit-rules API + #[builder(default)] + max_kbps: Option, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Alias_Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-bandwidth-limit-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("max_burst_kbps", self.max_burst_kbps); + params.push_opt("max_kbps", self.max_kbps); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_bandwidth_limit_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_bandwidth_limit_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-bandwidth-limit-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rules": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-bandwidth-limit-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rules": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/set.rs b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/set.rs new file mode 100644 index 000000000..44ff5698f --- /dev/null +++ b/sdk/network/src/v2/qos/alias_bandwidth_limit_rule/set.rs @@ -0,0 +1,244 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AliasBandwidthLimitRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_burst_kbps: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_kbps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) alias_bandwidth_limit_rule: AliasBandwidthLimitRule, + + /// id parameter for /v2.0/qos/alias-bandwidth-limit-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "qos/alias-bandwidth-limit-rules/{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( + "alias_bandwidth_limit_rule", + serde_json::to_value(&self.alias_bandwidth_limit_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_bandwidth_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_bandwidth_limit_rule( + AliasBandwidthLimitRuleBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_bandwidth_limit_rule( + AliasBandwidthLimitRuleBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_bandwidth_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_bandwidth_limit_rule(AliasBandwidthLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/alias-bandwidth-limit-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_bandwidth_limit_rule(AliasBandwidthLimitRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule.rs b/sdk/network/src/v2/qos/alias_dscp_marking_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/alias_dscp_marking_rule.rs rename to sdk/network/src/v2/qos/alias_dscp_marking_rule.rs diff --git a/sdk/network/src/v2/qos/alias_dscp_marking_rule/create.rs b/sdk/network/src/v2/qos/alias_dscp_marking_rule/create.rs new file mode 100644 index 000000000..8b1ca2cdc --- /dev/null +++ b/sdk/network/src/v2/qos/alias_dscp_marking_rule/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_alias_dscp_marking_rule"))] + pub(crate) alias_dscp_marking_rule: BTreeMap, Value>, + + #[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 alias_dscp_marking_rule(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.alias_dscp_marking_rule + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Alias_Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-dscp-marking-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "alias_dscp_marking_rule", + serde_json::to_value(&self.alias_dscp_marking_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_dscp_marking_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_dscp_marking_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-dscp-marking-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-dscp-marking-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_dscp_marking_rule(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_dscp_marking_rule/delete.rs b/sdk/network/src/v2/qos/alias_dscp_marking_rule/delete.rs new file mode 100644 index 000000000..9427df631 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_dscp_marking_rule/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-dscp-marking-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos/alias-dscp-marking-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/alias-dscp-marking-rules/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/alias-dscp-marking-rules/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_dscp_marking_rule/get.rs b/sdk/network/src/v2/qos/alias_dscp_marking_rule/get.rs new file mode 100644 index 000000000..eb3d4008c --- /dev/null +++ b/sdk/network/src/v2/qos/alias_dscp_marking_rule/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-dscp-marking-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos/alias-dscp-marking-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_dscp_marking_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_dscp_marking_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rule": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_dscp_marking_rule/list.rs b/sdk/network/src/v2/qos/alias_dscp_marking_rule/list.rs new file mode 100644 index 000000000..b4e49381f --- /dev/null +++ b/sdk/network/src/v2/qos/alias_dscp_marking_rule/list.rs @@ -0,0 +1,255 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// dscp_mark query parameter for /v2.0/qos/alias-dscp-marking-rules API + #[builder(default)] + dscp_mark: Option, + + /// id query parameter for /v2.0/qos/alias-dscp-marking-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Alias_Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-dscp-marking-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("dscp_mark", self.dscp_mark); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_dscp_marking_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_dscp_marking_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-dscp-marking-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rules": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-dscp-marking-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rules": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_dscp_marking_rule/set.rs b/sdk/network/src/v2/qos/alias_dscp_marking_rule/set.rs new file mode 100644 index 000000000..fef40d747 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_dscp_marking_rule/set.rs @@ -0,0 +1,220 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AliasDscpMarkingRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dscp_mark: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) alias_dscp_marking_rule: AliasDscpMarkingRule, + + /// id parameter for /v2.0/qos/alias-dscp-marking-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("qos/alias-dscp-marking-rules/{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( + "alias_dscp_marking_rule", + serde_json::to_value(&self.alias_dscp_marking_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_dscp_marking_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_dscp_marking_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/alias-dscp-marking-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_dscp_marking_rule(AliasDscpMarkingRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule.rs b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/alias_minimum_bandwidth_rule.rs rename to sdk/network/src/v2/qos/alias_minimum_bandwidth_rule.rs diff --git a/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/create.rs b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/create.rs new file mode 100644 index 000000000..1a070ccb4 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_alias_minimum_bandwidth_rule"))] + pub(crate) alias_minimum_bandwidth_rule: BTreeMap, Value>, + + #[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 alias_minimum_bandwidth_rule(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.alias_minimum_bandwidth_rule + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Alias_Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-minimum-bandwidth-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "alias_minimum_bandwidth_rule", + serde_json::to_value(&self.alias_minimum_bandwidth_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_bandwidth_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_minimum_bandwidth_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-minimum-bandwidth-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-minimum-bandwidth-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_minimum_bandwidth_rule(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/delete.rs b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/delete.rs new file mode 100644 index 000000000..fdddbb8b9 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/delete.rs @@ -0,0 +1,188 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-minimum-bandwidth-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/alias-minimum-bandwidth-rules/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/qos/alias-minimum-bandwidth-rules/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/qos/alias-minimum-bandwidth-rules/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/get.rs b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/get.rs new file mode 100644 index 000000000..ec53d5a0e --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/get.rs @@ -0,0 +1,191 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-minimum-bandwidth-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/alias-minimum-bandwidth-rules/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_bandwidth_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_minimum_bandwidth_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/alias-minimum-bandwidth-rules/{id}", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/alias-minimum-bandwidth-rules/{id}", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/list.rs b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/list.rs new file mode 100644 index 000000000..5a5455efa --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/list.rs @@ -0,0 +1,262 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// direction query parameter for /v2.0/qos/alias-minimum-bandwidth-rules + /// API + #[builder(default, setter(into))] + direction: Option>, + + /// id query parameter for /v2.0/qos/alias-minimum-bandwidth-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// min_kbps query parameter for /v2.0/qos/alias-minimum-bandwidth-rules + /// API + #[builder(default)] + min_kbps: Option, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Alias_Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-minimum-bandwidth-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("min_kbps", self.min_kbps); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_bandwidth_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_minimum_bandwidth_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-minimum-bandwidth-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rules": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-minimum-bandwidth-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rules": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/set.rs b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/set.rs new file mode 100644 index 000000000..b1555996b --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_bandwidth_rule/set.rs @@ -0,0 +1,249 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AliasMinimumBandwidthRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_kbps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) alias_minimum_bandwidth_rule: AliasMinimumBandwidthRule, + + /// id parameter for /v2.0/qos/alias-minimum-bandwidth-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "qos/alias-minimum-bandwidth-rules/{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( + "alias_minimum_bandwidth_rule", + serde_json::to_value(&self.alias_minimum_bandwidth_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_bandwidth_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_minimum_bandwidth_rule( + AliasMinimumBandwidthRuleBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_minimum_bandwidth_rule( + AliasMinimumBandwidthRuleBuilder::default().build().unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_minimum_bandwidth_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/qos/alias-minimum-bandwidth-rules/{id}", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_minimum_bandwidth_rule( + AliasMinimumBandwidthRuleBuilder::default().build().unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/qos/alias-minimum-bandwidth-rules/{id}", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_minimum_bandwidth_rule( + AliasMinimumBandwidthRuleBuilder::default().build().unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule.rs b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/alias_minimum_packet_rate_rule.rs rename to sdk/network/src/v2/qos/alias_minimum_packet_rate_rule.rs diff --git a/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/create.rs b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/create.rs new file mode 100644 index 000000000..35f73546b --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_alias_minimum_packet_rate_rule"))] + pub(crate) alias_minimum_packet_rate_rule: BTreeMap, Value>, + + #[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 alias_minimum_packet_rate_rule(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.alias_minimum_packet_rate_rule + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-minimum-packet-rate-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "alias_minimum_packet_rate_rule", + serde_json::to_value(&self.alias_minimum_packet_rate_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_packet_rate_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_minimum_packet_rate_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-minimum-packet-rate-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/alias-minimum-packet-rate-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .alias_minimum_packet_rate_rule(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/delete.rs b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/delete.rs new file mode 100644 index 000000000..c5ddba6e3 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/delete.rs @@ -0,0 +1,188 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-minimum-packet-rate-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/alias-minimum-packet-rate-rules/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/qos/alias-minimum-packet-rate-rules/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/qos/alias-minimum-packet-rate-rules/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/get.rs b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/get.rs new file mode 100644 index 000000000..3c09d588f --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/get.rs @@ -0,0 +1,191 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/alias-minimum-packet-rate-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/alias-minimum-packet-rate-rules/{id}", + id = self.id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_packet_rate_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_minimum_packet_rate_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/alias-minimum-packet-rate-rules/{id}", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/alias-minimum-packet-rate-rules/{id}", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/list.rs b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/list.rs new file mode 100644 index 000000000..bc4cd091d --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/list.rs @@ -0,0 +1,262 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// direction query parameter for /v2.0/qos/alias-minimum-packet-rate-rules + /// API + #[builder(default, setter(into))] + direction: Option>, + + /// id query parameter for /v2.0/qos/alias-minimum-packet-rate-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// min_kpps query parameter for /v2.0/qos/alias-minimum-packet-rate-rules + /// API + #[builder(default)] + min_kpps: Option, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/alias-minimum-packet-rate-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("min_kpps", self.min_kpps); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_packet_rate_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "alias_minimum_packet_rate_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-minimum-packet-rate-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rules": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/alias-minimum-packet-rate-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rules": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/set.rs b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/set.rs new file mode 100644 index 000000000..9873542f2 --- /dev/null +++ b/sdk/network/src/v2/qos/alias_minimum_packet_rate_rule/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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "any")] + Any, + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AliasMinimumPacketRateRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_kpps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) alias_minimum_packet_rate_rule: AliasMinimumPacketRateRule, + + /// id parameter for /v2.0/qos/alias-minimum-packet-rate-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Alias_Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "qos/alias-minimum-packet-rate-rules/{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( + "alias_minimum_packet_rate_rule", + serde_json::to_value(&self.alias_minimum_packet_rate_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("alias_minimum_packet_rate_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .alias_minimum_packet_rate_rule( + AliasMinimumPacketRateRuleBuilder::default() + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .alias_minimum_packet_rate_rule( + AliasMinimumPacketRateRuleBuilder::default() + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "alias_minimum_packet_rate_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/qos/alias-minimum-packet-rate-rules/{id}", + id = "id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_minimum_packet_rate_rule( + AliasMinimumPacketRateRuleBuilder::default() + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/qos/alias-minimum-packet-rate-rules/{id}", + id = "id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "alias_minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .alias_minimum_packet_rate_rule( + AliasMinimumPacketRateRuleBuilder::default() + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/policy.rs b/sdk/network/src/v2/qos/policy.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/policy.rs rename to sdk/network/src/v2/qos/policy.rs diff --git a/openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule.rs b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/policy/bandwidth_limit_rule.rs rename to sdk/network/src/v2/qos/policy/bandwidth_limit_rule.rs diff --git a/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/create.rs b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/create.rs new file mode 100644 index 000000000..f37b2b160 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/create.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`. + +//! Creates a bandwidth limit rule for a QoS policy. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +/// A `bandwidth_limit_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct BandwidthLimitRule { + /// The direction of the traffic to which the QoS rule is applied, as seen + /// from the point of view of the `port`. Valid values are `egress` and + /// `ingress`. Default value is `egress`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + /// The maximum burst size (in kilobits). Default is `0`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_burst_kbps: Option, + + /// The maximum KBPS (kilobits per second) value. If you specify this + /// value, must be greater than 0 otherwise max_kbps will have no value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_kbps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `bandwidth_limit_rule` object. + #[builder(setter(into))] + pub(crate) bandwidth_limit_rule: BandwidthLimitRule, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "qos/policies/{policy_id}/bandwidth_limit_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "bandwidth_limit_rule", + serde_json::to_value(&self.bandwidth_limit_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("bandwidth_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "bandwidth_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/delete.rs b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/delete.rs new file mode 100644 index 000000000..b29ab2331 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/delete.rs @@ -0,0 +1,208 @@ +// 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`. + +//! Deletes a bandwidth limit rule for a QoS policy. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/get.rs b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/get.rs new file mode 100644 index 000000000..52a7657a7 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/get.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`. + +//! Shows details for a bandwidth limit rule for a QoS policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("bandwidth_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "bandwidth_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/list.rs b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/list.rs new file mode 100644 index 000000000..42215ac01 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/list.rs @@ -0,0 +1,299 @@ +// 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`. + +//! Lists all bandwidth limit rules for a QoS policy. +//! +//! The list might be empty. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id query parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// max_burst_kbps query parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules API + #[builder(default)] + max_burst_kbps: Option, + + /// max_kbps query parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules API + #[builder(default)] + max_kbps: Option, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/bandwidth_limit_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("id", self.id.as_ref()); + params.push_opt("max_burst_kbps", self.max_burst_kbps); + params.push_opt("max_kbps", self.max_kbps); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("bandwidth_limit_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "bandwidth_limit_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rules": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rules": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/set.rs b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/set.rs new file mode 100644 index 000000000..7392aed35 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/bandwidth_limit_rule/set.rs @@ -0,0 +1,270 @@ +// 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`. + +//! Updates a bandwidth limit rule for a QoS policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +/// A `bandwidth_limit_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct BandwidthLimitRule { + /// The direction of the traffic to which the QoS rule is applied, as seen + /// from the point of view of the `port`. Valid values are `egress` and + /// `ingress`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + /// The maximum burst size (in kilobits). Default is `0`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_burst_kbps: Option, + + /// The maximum KBPS (kilobits per second) value. If you specify this + /// value, must be greater than 0 otherwise max_kbps will have no value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_kbps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `bandwidth_limit_rule` object. + #[builder(setter(into))] + pub(crate) bandwidth_limit_rule: BandwidthLimitRule, + + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/bandwidth_limit_rules/{id} API + #[builder(default, setter(into))] + policy_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 Bandwidth_Limit_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "bandwidth_limit_rule", + serde_json::to_value(&self.bandwidth_limit_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("bandwidth_limit_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "bandwidth_limit_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/qos/policies/{policy_id}/bandwidth_limit_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "bandwidth_limit_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .bandwidth_limit_rule(BandwidthLimitRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/create.rs b/sdk/network/src/v2/qos/policy/create.rs new file mode 100644 index 000000000..6c1a911cb --- /dev/null +++ b/sdk/network/src/v2/qos/policy/create.rs @@ -0,0 +1,254 @@ +// 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`. + +//! Creates a QoS policy. +//! +//! Creates a QoS policy by using the configuration that you define in the +//! request object. A response object is returned. The object contains a unique +//! ID. +//! +//! By the default policy configuration, if the caller is not an administrative +//! user, this call returns the HTTP `Forbidden (403)` response code. +//! +//! Users with an administrative role can create policies on behalf of other +//! projects by specifying a project ID that is different than their own. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A QoS `policy` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Policy<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// If `true`, the QoS `policy` is the default policy. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_default: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Set to `true` to share this policy with other projects. Default is + /// `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A QoS `policy` object. + #[builder(setter(into))] + pub(crate) policy: Policy<'a>, + + #[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 Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("policy", serde_json::to_value(&self.policy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .policy(PolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .policy(PolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/policies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policy": {} })); + }); + + let endpoint = Request::builder() + .policy(PolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/policies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policy": {} })); + }); + + let endpoint = Request::builder() + .policy(PolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/delete.rs b/sdk/network/src/v2/qos/policy/delete.rs new file mode 100644 index 000000000..102d13a82 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a QoS policy. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/policies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos/policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/policies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/policies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule.rs b/sdk/network/src/v2/qos/policy/dscp_marking_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/policy/dscp_marking_rule.rs rename to sdk/network/src/v2/qos/policy/dscp_marking_rule.rs diff --git a/sdk/network/src/v2/qos/policy/dscp_marking_rule/create.rs b/sdk/network/src/v2/qos/policy/dscp_marking_rule/create.rs new file mode 100644 index 000000000..75312e249 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/dscp_marking_rule/create.rs @@ -0,0 +1,239 @@ +// 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`. + +//! Creates a DSCP marking rule for a QoS policy. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `dscp_marking_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct DscpMarkingRule { + /// The DSCP mark value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dscp_mark: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `dscp_marking_rule` object. + #[builder(setter(into))] + pub(crate) dscp_marking_rule: DscpMarkingRule, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API + #[builder(default, setter(into))] + policy_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 Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "qos/policies/{policy_id}/dscp_marking_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "dscp_marking_rule", + serde_json::to_value(&self.dscp_marking_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("dscp_marking_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "dscp_marking_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/dscp_marking_rule/delete.rs b/sdk/network/src/v2/qos/policy/dscp_marking_rule/delete.rs new file mode 100644 index 000000000..1d4bfbdbc --- /dev/null +++ b/sdk/network/src/v2/qos/policy/dscp_marking_rule/delete.rs @@ -0,0 +1,208 @@ +// 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`. + +//! Deletes a DSCP marking rule for a QoS policy. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API + #[builder(default, setter(into))] + policy_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 Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/dscp_marking_rule/get.rs b/sdk/network/src/v2/qos/policy/dscp_marking_rule/get.rs new file mode 100644 index 000000000..4b7baad99 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/dscp_marking_rule/get.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`. + +//! Shows details for a DSCP marking rule for a QoS policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API + #[builder(default, setter(into))] + policy_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 Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("dscp_marking_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "dscp_marking_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/dscp_marking_rule/list.rs b/sdk/network/src/v2/qos/policy/dscp_marking_rule/list.rs new file mode 100644 index 000000000..2fd665365 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/dscp_marking_rule/list.rs @@ -0,0 +1,293 @@ +// 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`. + +//! Lists all DSCP marking rules for a QoS policy. +//! +//! The list may be empty. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// dscp_mark query parameter for + /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules API + #[builder(default)] + dscp_mark: Option, + + /// id query parameter for + /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/dscp_marking_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("dscp_mark", self.dscp_mark); + params.push_opt("id", self.id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("dscp_marking_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "dscp_marking_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rules": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rules": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/dscp_marking_rule/set.rs b/sdk/network/src/v2/qos/policy/dscp_marking_rule/set.rs new file mode 100644 index 000000000..b397a35fd --- /dev/null +++ b/sdk/network/src/v2/qos/policy/dscp_marking_rule/set.rs @@ -0,0 +1,249 @@ +// 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`. + +//! Updates a DSCP marking rule for a QoS policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `dscp_marking_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct DscpMarkingRule { + /// The DSCP mark value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dscp_mark: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `dscp_marking_rule` object. + #[builder(setter(into))] + pub(crate) dscp_marking_rule: DscpMarkingRule, + + /// id parameter for /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/dscp_marking_rules/{id} API + #[builder(default, setter(into))] + policy_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 Dscp_Marking_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "dscp_marking_rule", + serde_json::to_value(&self.dscp_marking_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("dscp_marking_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "dscp_marking_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/qos/policies/{policy_id}/dscp_marking_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dscp_marking_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .dscp_marking_rule(DscpMarkingRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/find.rs b/sdk/network/src/v2/qos/policy/find.rs new file mode 100644 index 000000000..ed50ee80d --- /dev/null +++ b/sdk/network/src/v2/qos/policy/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::qos::policy::{get as Get, list as List}; + +/// Find for qos/policy 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/qos/policy/get.rs b/sdk/network/src/v2/qos/policy/get.rs new file mode 100644 index 000000000..330117018 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/get.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Shows details for a QoS policy. One policy can contain more than one rule +//! type. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/policies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos/policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/policies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policy": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/policies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/list.rs b/sdk/network/src/v2/qos/policy/list.rs new file mode 100644 index 000000000..146aaa807 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/list.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`. + +//! Lists all QoS policies associated with your project. One policy can contain +//! more than one rule type. +//! +//! The list might be empty. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/qos/policies API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/qos/policies API + #[builder(default, setter(into))] + id: Option>, + + /// is_default query parameter for /v2.0/qos/policies API + #[builder(default)] + is_default: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/qos/policies API + #[builder(default, setter(into))] + name: Option>, + + /// not-tags query parameter for /v2.0/qos/policies API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/qos/policies API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// revision_number query parameter for /v2.0/qos/policies API + #[builder(default, setter(into))] + revision_number: Option>, + + /// shared query parameter for /v2.0/qos/policies API + #[builder(default)] + shared: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tags query parameter for /v2.0/qos/policies API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/qos/policies API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/qos/policies API + #[builder(default, setter(into))] + tenant_id: 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> { + /// not-tags query parameter for /v2.0/qos/policies API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/qos/policies API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/qos/policies API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/qos/policies API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("is_default", self.is_default); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("shared", self.shared); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("policies".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "policies" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/policies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policies": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/policies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policies": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule.rs b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/policy/minimum_bandwidth_rule.rs rename to sdk/network/src/v2/qos/policy/minimum_bandwidth_rule.rs diff --git a/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/create.rs b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/create.rs new file mode 100644 index 000000000..8e4a00ba4 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/create.rs @@ -0,0 +1,255 @@ +// 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`. + +//! Creates a minimum bandwidth rule for a QoS policy. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +/// A `minimum_bandwidth_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct MinimumBandwidthRule { + /// The direction of the traffic to which the QoS rule is applied, as seen + /// from the point of view of the `port`. Valid values are `egress` and + /// `ingress`. Default value is `egress`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + /// The minimum KBPS (kilobits per second) value which should be available + /// for port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_kbps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `minimum_bandwidth_rule` object. + #[builder(setter(into))] + pub(crate) minimum_bandwidth_rule: MinimumBandwidthRule, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "qos/policies/{policy_id}/minimum_bandwidth_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "minimum_bandwidth_rule", + serde_json::to_value(&self.minimum_bandwidth_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_bandwidth_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "minimum_bandwidth_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/delete.rs b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/delete.rs new file mode 100644 index 000000000..a896cdbc4 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/delete.rs @@ -0,0 +1,208 @@ +// 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`. + +//! Deletes a minimum bandwidth rule for a QoS policy. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/get.rs b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/get.rs new file mode 100644 index 000000000..7019f33fe --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/get.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`. + +//! Shows details for a minimum bandwidth rule for a QoS policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_bandwidth_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "minimum_bandwidth_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/list.rs b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/list.rs new file mode 100644 index 000000000..3ebe96ef0 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/list.rs @@ -0,0 +1,299 @@ +// 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`. + +//! Lists all minimum bandwidth rules for a QoS policy. +//! +//! The list might be empty. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// direction query parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules API + #[builder(default, setter(into))] + direction: Option>, + + /// id query parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// min_kbps query parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules API + #[builder(default)] + min_kbps: Option, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/minimum_bandwidth_rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("min_kbps", self.min_kbps); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_bandwidth_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "minimum_bandwidth_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rules": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rules": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/set.rs b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/set.rs new file mode 100644 index 000000000..1e9985880 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_bandwidth_rule/set.rs @@ -0,0 +1,269 @@ +// 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`. + +//! Updates a minimum bandwidth rule for a QoS policy. +//! +//! Note that the rule cannot be updated, and the update is rejected with error +//! code 501, if there is any bound port referring to the rule via the qos +//! policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404, 501 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +/// A `minimum_bandwidth_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct MinimumBandwidthRule { + /// The direction of the traffic to which the QoS rule is applied, as seen + /// from the point of view of the `port`. Valid values are `egress` and + /// `ingress`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + /// The minimum KBPS (kilobits per second) value which should be available + /// for port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_kbps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `minimum_bandwidth_rule` object. + #[builder(setter(into))] + pub(crate) minimum_bandwidth_rule: MinimumBandwidthRule, + + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum_bandwidth_rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Bandwidth_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "minimum_bandwidth_rule", + serde_json::to_value(&self.minimum_bandwidth_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_bandwidth_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "minimum_bandwidth_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/qos/policies/{policy_id}/minimum_bandwidth_rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_bandwidth_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .minimum_bandwidth_rule(MinimumBandwidthRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule.rs b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/policy/minimum_packet_rate_rule.rs rename to sdk/network/src/v2/qos/policy/minimum_packet_rate_rule.rs diff --git a/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/create.rs b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/create.rs new file mode 100644 index 000000000..0d3c0ee13 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/create.rs @@ -0,0 +1,244 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "any")] + Any, + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct MinimumPacketRateRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_kpps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) minimum_packet_rate_rule: MinimumPacketRateRule, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "qos/policies/{policy_id}/minimum-packet-rate-rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "minimum_packet_rate_rule", + serde_json::to_value(&self.minimum_packet_rate_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_packet_rate_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "minimum_packet_rate_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/delete.rs b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/delete.rs new file mode 100644 index 000000000..9ad6b7365 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/delete.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = "id", + policy_id = "policy_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") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/get.rs b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/get.rs new file mode 100644 index 000000000..47b167248 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/get.rs @@ -0,0 +1,205 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_packet_rate_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "minimum_packet_rate_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/list.rs b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/list.rs new file mode 100644 index 000000000..8307dd4c0 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/list.rs @@ -0,0 +1,278 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// direction query parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules API + #[builder(default, setter(into))] + direction: Option>, + + /// id query parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// min_kpps query parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules API + #[builder(default)] + min_kpps: Option, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + policy_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "qos/policies/{policy_id}/minimum-packet-rate-rules", + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("min_kpps", self.min_kpps); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_packet_rate_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "minimum_packet_rate_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rules": {} })); + }); + + let endpoint = Request::builder().policy_id("policy_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rules": {} })); + }); + + let endpoint = Request::builder() + .policy_id("policy_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/set.rs b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/set.rs new file mode 100644 index 000000000..6a07024e4 --- /dev/null +++ b/sdk/network/src/v2/qos/policy/minimum_packet_rate_rule/set.rs @@ -0,0 +1,254 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "any")] + Any, + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct MinimumPacketRateRule { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_kpps: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) minimum_packet_rate_rule: MinimumPacketRateRule, + + /// id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// policy_id parameter for + /// /v2.0/qos/policies/{policy_id}/minimum-packet-rate-rules/{id} API + #[builder(default, setter(into))] + policy_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 Minimum_Packet_Rate_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = self.id.as_ref(), + policy_id = self.policy_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "minimum_packet_rate_rule", + serde_json::to_value(&self.minimum_packet_rate_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("minimum_packet_rate_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "minimum_packet_rate_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = "id", + policy_id = "policy_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/qos/policies/{policy_id}/minimum-packet-rate-rules/{id}", + id = "id", + policy_id = "policy_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "minimum_packet_rate_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy_id("policy_id") + .minimum_packet_rate_rule(MinimumPacketRateRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/policy/set.rs b/sdk/network/src/v2/qos/policy/set.rs new file mode 100644 index 000000000..c0da543ef --- /dev/null +++ b/sdk/network/src/v2/qos/policy/set.rs @@ -0,0 +1,243 @@ +// 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`. + +//! Updates a QoS policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A QoS `policy` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Policy<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// If `true`, the QoS `policy` is the default policy. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_default: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Set to `true` to share this policy with other projects. Default is + /// `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A QoS `policy` object. + #[builder(setter(into))] + pub(crate) policy: Policy<'a>, + + /// id parameter for /v2.0/qos/policies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("qos/policies/{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("policy", serde_json::to_value(&self.policy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .policy(PolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .policy(PolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/policies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy(PolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/policies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .policy(PolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/qos/rule_type.rs b/sdk/network/src/v2/qos/rule_type.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/qos/rule_type.rs rename to sdk/network/src/v2/qos/rule_type.rs diff --git a/sdk/network/src/v2/qos/rule_type/create.rs b/sdk/network/src/v2/qos/rule_type/create.rs new file mode 100644 index 000000000..35974c4a5 --- /dev/null +++ b/sdk/network/src/v2/qos/rule_type/create.rs @@ -0,0 +1,214 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RuleType { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) all_rules: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) all_supported: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(into))] + pub(crate) rule_type: RuleType, + + #[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 Rule_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/rule-types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("rule_type", serde_json::to_value(&self.rule_type)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rule_type".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "rule_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/rule-types".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_type": {} })); + }); + + let endpoint = Request::builder() + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/qos/rule-types".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_type": {} })); + }); + + let endpoint = Request::builder() + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/rule_type/delete.rs b/sdk/network/src/v2/qos/rule_type/delete.rs new file mode 100644 index 000000000..3fdf25bb0 --- /dev/null +++ b/sdk/network/src/v2/qos/rule_type/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/rule-types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Rule_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos/rule-types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/rule-types/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/qos/rule-types/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/rule_type/get.rs b/sdk/network/src/v2/qos/rule_type/get.rs new file mode 100644 index 000000000..c76120bdf --- /dev/null +++ b/sdk/network/src/v2/qos/rule_type/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for an available QoS rule type. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/qos/rule-types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Rule_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("qos/rule-types/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rule_type".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "rule_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/rule-types/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_type": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/qos/rule-types/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/rule_type/list.rs b/sdk/network/src/v2/qos/rule_type/list.rs new file mode 100644 index 000000000..6654bc1fc --- /dev/null +++ b/sdk/network/src/v2/qos/rule_type/list.rs @@ -0,0 +1,274 @@ +// 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`. + +//! Lists available qos rule types. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// all_rules query parameter for /v2.0/qos/rule-types API + #[builder(default)] + all_rules: Option, + + /// all_supported query parameter for /v2.0/qos/rule-types API + #[builder(default)] + all_supported: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Rule_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "qos/rule-types".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("all_rules", self.all_rules); + params.push_opt("all_supported", self.all_supported); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rule_types".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "rule_types" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/rule-types".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_types": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/qos/rule-types".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_types": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/qos/rule_type/set.rs b/sdk/network/src/v2/qos/rule_type/set.rs new file mode 100644 index 000000000..7835e0776 --- /dev/null +++ b/sdk/network/src/v2/qos/rule_type/set.rs @@ -0,0 +1,221 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RuleType { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) all_rules: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) all_supported: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) rule_type: RuleType, + + /// id parameter for /v2.0/qos/rule-types/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Rule_Type. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("qos/rule-types/{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("rule_type", serde_json::to_value(&self.rule_type)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rule_type".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "rule_type" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/rule-types/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/qos/rule-types/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rule_type": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .rule_type(RuleTypeBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/quota.rs b/sdk/network/src/v2/quota.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/quota.rs rename to sdk/network/src/v2/quota.rs diff --git a/sdk/network/src/v2/quota/defaults.rs b/sdk/network/src/v2/quota/defaults.rs new file mode 100644 index 000000000..17c2578bf --- /dev/null +++ b/sdk/network/src/v2/quota/defaults.rs @@ -0,0 +1,201 @@ +// 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`. + +//! Lists default quotas for a project. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/quotas/{id}/default 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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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}/default", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("quota".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{id}/default", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{id}/default", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/quota/delete.rs b/sdk/network/src/v2/quota/delete.rs new file mode 100644 index 000000000..300e9db3d --- /dev/null +++ b/sdk/network/src/v2/quota/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Resets quotas to default values for a project. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/quotas/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/quota/details.rs b/sdk/network/src/v2/quota/details.rs new file mode 100644 index 000000000..3586cec99 --- /dev/null +++ b/sdk/network/src/v2/quota/details.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/quotas/{id}/details 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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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}/details", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("quota".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{id}/details", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/quotas/{id}/details", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/quota/get.rs b/sdk/network/src/v2/quota/get.rs new file mode 100644 index 000000000..5bd42ba60 --- /dev/null +++ b/sdk/network/src/v2/quota/get.rs @@ -0,0 +1,201 @@ +// 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`. + +//! Lists quotas for a project. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/quotas/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::Network + } + + fn response_key(&self) -> Option> { + Some("quota".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quota" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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!({ "quota": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/quota/list.rs b/sdk/network/src/v2/quota/list.rs new file mode 100644 index 000000000..47ae20655 --- /dev/null +++ b/sdk/network/src/v2/quota/list.rs @@ -0,0 +1,264 @@ +// 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`. + +//! Lists quotas for projects with non-default quota values. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "quotas" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/quota/set.rs b/sdk/network/src/v2/quota/set.rs new file mode 100644 index 000000000..9a229da14 --- /dev/null +++ b/sdk/network/src/v2/quota/set.rs @@ -0,0 +1,280 @@ +// 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`. + +//! Updates quotas for a project. Use when non-default quotas are desired. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `quota` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Quota<'a> { + /// The number of floating IP addresses allowed for each project. A value + /// of `-1` means no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) floatingip: Option, + + /// The number of networks allowed for each project. A value of `-1` means + /// no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) network: Option, + + /// The number of ports allowed for each project. A value of `-1` means no + /// limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port: Option, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The number of role-based access control (RBAC) policies for each + /// project. A value of `-1` means no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) rbac_policy: Option, + + /// The number of routers allowed for each project. A value of `-1` means + /// no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) router: Option, + + /// The number of security groups allowed for each project. A value of `-1` + /// means no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_group: Option, + + /// The number of security group rules allowed for each project. A value of + /// `-1` means no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_group_rule: Option, + + /// The number of subnets allowed for each project. A value of `-1` means + /// no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet: Option, + + /// The number of subnet pools allowed for each project. A value of `-1` + /// means no limit. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnetpool: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `quota` object. + #[builder(setter(into))] + pub(crate) quota: Quota<'a>, + + /// id parameter for /v2.0/quotas/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Quota. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("quotas/{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("quota", serde_json::to_value(&self.quota)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("quota".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota(QuotaBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .quota(QuotaBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "quota" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/quotas/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota(QuotaBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .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!({ "quota": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota(QuotaBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/rbac_policy.rs b/sdk/network/src/v2/rbac_policy.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/rbac_policy.rs rename to sdk/network/src/v2/rbac_policy.rs diff --git a/sdk/network/src/v2/rbac_policy/create.rs b/sdk/network/src/v2/rbac_policy/create.rs new file mode 100644 index 000000000..39cfd802f --- /dev/null +++ b/sdk/network/src/v2/rbac_policy/create.rs @@ -0,0 +1,250 @@ +// 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 RBAC policy for given tenant. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RbacPolicy<'a> { + /// Action for the RBAC policy which is `access_as_external` or + /// `access_as_shared`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) action: Option>, + + /// The ID of the `object_type` resource. An `object_type` of `network` + /// returns a network ID, an `object_type` of `qos-policy` returns a QoS + /// policy ID, an `object_type` of `security-group` returns a security + /// group ID, an `object_type` of `address-scope` returns a address scope + /// ID, an `object_type` of `subnetpool` returns a subnetpool ID and an + /// `object_type` of `address-group` returns an address group ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) object_id: Option>, + + /// The type of the object that the RBAC policy affects. Types include + /// `qos-policy`, `network`, `security-group`, `address-scope`, + /// `subnetpool` or `address-group`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) object_type: Option>, + + /// The ID of the tenant to which the RBAC policy will be enforced. Please + /// note that Neutron does not perform any type of validation that the + /// value provided is actually the ID of the existing project. If, for + /// example, the name of the project is provided here, it will be accepted + /// by the Neutron API, but the RBAC rule created will not work as + /// expected. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) target_tenant: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) rbac_policy: RbacPolicy<'a>, + + #[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 Rbac_Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "rbac-policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("rbac_policy", serde_json::to_value(&self.rbac_policy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rbac_policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "rbac_policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/rbac-policies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policy": {} })); + }); + + let endpoint = Request::builder() + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/rbac-policies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policy": {} })); + }); + + let endpoint = Request::builder() + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/rbac_policy/delete.rs b/sdk/network/src/v2/rbac_policy/delete.rs new file mode 100644 index 000000000..227442d16 --- /dev/null +++ b/sdk/network/src/v2/rbac_policy/delete.rs @@ -0,0 +1,185 @@ +// 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 an RBAC policy. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/rbac-policies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Rbac_Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("rbac-policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/rbac-policies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/rbac-policies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/rbac_policy/get.rs b/sdk/network/src/v2/rbac_policy/get.rs new file mode 100644 index 000000000..5e20f531b --- /dev/null +++ b/sdk/network/src/v2/rbac_policy/get.rs @@ -0,0 +1,191 @@ +// 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 details for a given RBAC policy. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/rbac-policies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Rbac_Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("rbac-policies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rbac_policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "rbac_policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/rbac-policies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policy": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/rbac-policies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/rbac_policy/list.rs b/sdk/network/src/v2/rbac_policy/list.rs new file mode 100644 index 000000000..2a266f5c5 --- /dev/null +++ b/sdk/network/src/v2/rbac_policy/list.rs @@ -0,0 +1,294 @@ +// 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 RBAC policies that belong to a given tenant. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// action query parameter for /v2.0/rbac-policies API + #[builder(default, setter(into))] + action: Option>, + + /// id query parameter for /v2.0/rbac-policies API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// object_id query parameter for /v2.0/rbac-policies API + #[builder(default, setter(into))] + object_id: Option>, + + /// object_type query parameter for /v2.0/rbac-policies API + #[builder(default, setter(into))] + object_type: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// target_tenant query parameter for /v2.0/rbac-policies API + #[builder(default, setter(into))] + target_tenant: Option>, + + /// tenant_id query parameter for /v2.0/rbac-policies API + #[builder(default, setter(into))] + tenant_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Rbac_Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "rbac-policies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("action", self.action.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("object_id", self.object_id.as_ref()); + params.push_opt("object_type", self.object_type.as_ref()); + params.push_opt("target_tenant", self.target_tenant.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rbac_policies".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "rbac_policies" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/rbac-policies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policies": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/rbac-policies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policies": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/rbac_policy/set.rs b/sdk/network/src/v2/rbac_policy/set.rs new file mode 100644 index 000000000..e94d63c54 --- /dev/null +++ b/sdk/network/src/v2/rbac_policy/set.rs @@ -0,0 +1,229 @@ +// 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 RBAC policy for given tenant. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct RbacPolicy<'a> { + /// The ID of the tenant to which the RBAC policy will be enforced. Please + /// note that Neutron does not perform any type of validation that the + /// value provided is actually the ID of the existing project. If, for + /// example, the name of the project is provided here, it will be accepted + /// by the Neutron API, but the RBAC rule created will not work as + /// expected. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) target_tenant: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) rbac_policy: RbacPolicy<'a>, + + /// id parameter for /v2.0/rbac-policies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Rbac_Policy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("rbac-policies/{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("rbac_policy", serde_json::to_value(&self.rbac_policy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("rbac_policy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "rbac_policy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/rbac-policies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/rbac-policies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "rbac_policy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .rbac_policy(RbacPolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/router.rs b/sdk/network/src/v2/router.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/router.rs rename to sdk/network/src/v2/router.rs diff --git a/openstack_sdk/src/api/network/v2/router/add_external_gateways.rs b/sdk/network/src/v2/router/add_external_gateways.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/router/add_external_gateways.rs rename to sdk/network/src/v2/router/add_external_gateways.rs index e1572e03a..aa6c646a9 100644 --- a/openstack_sdk/src/api/network/v2/router/add_external_gateways.rs +++ b/sdk/network/src/v2/router/add_external_gateways.rs @@ -200,7 +200,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/router/add_extraroutes.rs b/sdk/network/src/v2/router/add_extraroutes.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/router/add_extraroutes.rs rename to sdk/network/src/v2/router/add_extraroutes.rs index b15c81098..0d9a8a15e 100644 --- a/openstack_sdk/src/api/network/v2/router/add_extraroutes.rs +++ b/sdk/network/src/v2/router/add_extraroutes.rs @@ -170,7 +170,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/router/add_router_interface.rs b/sdk/network/src/v2/router/add_router_interface.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/router/add_router_interface.rs rename to sdk/network/src/v2/router/add_router_interface.rs index 8a51d957a..cffbfcc28 100644 --- a/openstack_sdk/src/api/network/v2/router/add_router_interface.rs +++ b/sdk/network/src/v2/router/add_router_interface.rs @@ -161,7 +161,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/router/conntrack_helper.rs b/sdk/network/src/v2/router/conntrack_helper.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/router/conntrack_helper.rs rename to sdk/network/src/v2/router/conntrack_helper.rs diff --git a/sdk/network/src/v2/router/conntrack_helper/create.rs b/sdk/network/src/v2/router/conntrack_helper/create.rs new file mode 100644 index 000000000..1cfd640d8 --- /dev/null +++ b/sdk/network/src/v2/router/conntrack_helper/create.rs @@ -0,0 +1,269 @@ +// 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`. + +//! Creates a router conntrack helper. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Protocol { + #[serde(rename = "dccp")] + Dccp, + #[serde(rename = "icmp")] + Icmp, + #[serde(rename = "ipv6-icmp")] + Ipv6Icmp, + #[serde(rename = "sctp")] + Sctp, + #[serde(rename = "tcp")] + Tcp, + #[serde(rename = "udp")] + Udp, +} + +/// A router `conntrack helper` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ConntrackHelper<'a> { + /// The netfilter conntrack helper module. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) helper: Option>, + + /// The network port for the netfilter conntrack target rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) project_id: Option>, + + /// The network protocol for the netfilter conntrack target rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A router `conntrack helper` object. + #[builder(setter(into))] + pub(crate) conntrack_helper: ConntrackHelper<'a>, + + /// router_id parameter for + /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + router_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 Conntrack_Helper. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "routers/{router_id}/conntrack_helpers", + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "conntrack_helper", + serde_json::to_value(&self.conntrack_helper)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("conntrack_helper".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "conntrack_helper" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/routers/{router_id}/conntrack_helpers", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helper": {} })); + }); + + let endpoint = Request::builder() + .router_id("router_id") + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/routers/{router_id}/conntrack_helpers", + router_id = "router_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helper": {} })); + }); + + let endpoint = Request::builder() + .router_id("router_id") + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/conntrack_helper/delete.rs b/sdk/network/src/v2/router/conntrack_helper/delete.rs new file mode 100644 index 000000000..66396a7c6 --- /dev/null +++ b/sdk/network/src/v2/router/conntrack_helper/delete.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`. + +//! Deletes a router conntrack helper. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for + /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + router_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 Conntrack_Helper. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/conntrack_helpers/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/routers/{router_id}/conntrack_helpers/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/routers/{router_id}/conntrack_helpers/{id}", + id = "id", + router_id = "router_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") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/conntrack_helper/find.rs b/sdk/network/src/v2/router/conntrack_helper/find.rs new file mode 100644 index 000000000..53eb441bd --- /dev/null +++ b/sdk/network/src/v2/router/conntrack_helper/find.rs @@ -0,0 +1,118 @@ +// 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 tracing::trace; + +use crate::api::find::Findable; +use crate::api::rest_endpoint_prelude::*; + +use crate::api::{ApiError, RestClient}; + +use crate::v2::router::conntrack_helper::{get as Get, list as List}; + +/// Find for router/conntrack_helper by nameOrId. +#[derive(Debug, Builder, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into), default)] + id: Cow<'a, str>, + #[builder(default, setter(into))] + router_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 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<'a>; + fn get_ep(&self) -> Get::Request<'a> { + let mut ep = Get::Request::builder(); + ep.id(self.id.clone()); + ep.router_id(self.router_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<'a> { + let mut ep = List::Request::builder(); + ep.router_id(self.router_id.clone()); + if let Some(headers) = &self._headers { + ep.headers(headers.iter().map(|(k, v)| (Some(k.clone()), v.clone()))); + } + ep.build().unwrap() + } + /// Locate router/conntrack_helper in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // router/conntrack_helper 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/sdk/network/src/v2/router/conntrack_helper/get.rs b/sdk/network/src/v2/router/conntrack_helper/get.rs new file mode 100644 index 000000000..0cab22c98 --- /dev/null +++ b/sdk/network/src/v2/router/conntrack_helper/get.rs @@ -0,0 +1,213 @@ +// 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`. + +//! Shows information for a router conntrack helper. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for + /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + router_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 Conntrack_Helper. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/conntrack_helpers/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("conntrack_helper".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "conntrack_helper" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/routers/{router_id}/conntrack_helpers/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helper": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/routers/{router_id}/conntrack_helpers/{id}", + id = "id", + router_id = "router_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helper": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/conntrack_helper/list.rs b/sdk/network/src/v2/router/conntrack_helper/list.rs new file mode 100644 index 000000000..55e406221 --- /dev/null +++ b/sdk/network/src/v2/router/conntrack_helper/list.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`. + +//! Lists router conntrack helpers associated with a router. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// helper query parameter for /v2.0/routers/{router_id}/conntrack_helpers + /// API + #[builder(default, setter(into))] + helper: Option>, + + /// id query parameter for /v2.0/routers/{router_id}/conntrack_helpers API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// port query parameter for /v2.0/routers/{router_id}/conntrack_helpers + /// API + #[builder(default)] + port: Option, + + /// protocol query parameter for + /// /v2.0/routers/{router_id}/conntrack_helpers API + #[builder(default, setter(into))] + protocol: Option>, + + /// router_id parameter for + /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + router_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Conntrack_Helper. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/conntrack_helpers", + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("helper", self.helper.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("port", self.port); + params.push_opt("protocol", self.protocol.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("conntrack_helpers".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "conntrack_helpers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/routers/{router_id}/conntrack_helpers", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helpers": {} })); + }); + + let endpoint = Request::builder().router_id("router_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/routers/{router_id}/conntrack_helpers", + router_id = "router_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helpers": {} })); + }); + + let endpoint = Request::builder() + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/conntrack_helper/set.rs b/sdk/network/src/v2/router/conntrack_helper/set.rs new file mode 100644 index 000000000..f3c755ebf --- /dev/null +++ b/sdk/network/src/v2/router/conntrack_helper/set.rs @@ -0,0 +1,272 @@ +// 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`. + +//! Updates a router conntrack helper. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Protocol { + #[serde(rename = "dccp")] + Dccp, + #[serde(rename = "icmp")] + Icmp, + #[serde(rename = "ipv6-icmp")] + Ipv6Icmp, + #[serde(rename = "sctp")] + Sctp, + #[serde(rename = "tcp")] + Tcp, + #[serde(rename = "udp")] + Udp, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ConntrackHelper<'a> { + /// The netfilter conntrack helper module. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) helper: Option>, + + /// The network port for the netfilter conntrack target rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port: Option, + + /// The network protocol for the netfilter conntrack target rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) protocol: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) conntrack_helper: ConntrackHelper<'a>, + + /// id parameter for /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for + /// /v2.0/routers/{router_id}/conntrack_helpers/{id} API + #[builder(default, setter(into))] + router_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 Conntrack_Helper. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "routers/{router_id}/conntrack_helpers/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "conntrack_helper", + serde_json::to_value(&self.conntrack_helper)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("conntrack_helper".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "conntrack_helper" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/routers/{router_id}/conntrack_helpers/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helper": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/routers/{router_id}/conntrack_helpers/{id}", + id = "id", + router_id = "router_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "conntrack_helper": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .conntrack_helper(ConntrackHelperBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/create.rs b/sdk/network/src/v2/router/create.rs new file mode 100644 index 000000000..aa8a70c76 --- /dev/null +++ b/sdk/network/src/v2/router/create.rs @@ -0,0 +1,324 @@ +// 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`. + +//! Creates a logical router. +//! +//! This operation creates a logical router. The logical router does not have +//! any internal interface and it is not associated with any subnet. You can +//! optionally specify an external gateway for a router at create time. The +//! external gateway for the router must be plugged into an external network. +//! An external network has its `router:external` extended field set to `true`. +//! To specify an external gateway, the ID of the external network must be +//! passed in the `network_id` parameter of the `external_gateway_info` +//! attribute in the request body. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ExternalFixedIps<'a> { + /// IP Address + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>, + + /// The subnet ID from which the IP address is assigned + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, +} + +/// The external gateway information of the router. If the router has an +/// external gateway, this would be a dict with `network_id`, `enable_snat`, +/// `external_fixed_ips` and `qos_policy_id`. Otherwise, this would be `null`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ExternalGatewayInfo<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enable_snat: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_fixed_ips: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) network_id: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, +} + +/// A `router` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Router<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). Default is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// The availability zone candidates for the router. It is available when + /// `router_availability_zone` extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone_hints: Option>>, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// `true` indicates a distributed router. It is available when `dvr` + /// extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) distributed: Option>, + + /// Enable NDP proxy attribute. Default is `false`, To persist this + /// attribute value, set the `enable_ndp_proxy_by_default` option in the + /// `neutron.conf` file. It is available when `router-extend-ndp-proxy` + /// extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enable_ndp_proxy: Option>, + + /// The external gateway information of the router. If the router has an + /// external gateway, this would be a dict with `network_id`, + /// `enable_snat`, `external_fixed_ips` and `qos_policy_id`. Otherwise, + /// this would be `null`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_gateway_info: Option>>, + + /// The ID of the flavor associated with the router. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) flavor_id: Option>, + + /// `true` indicates a highly-available router. It is available when + /// `l3-ha` extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ha: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `router` object. + #[builder(setter(into))] + pub(crate) router: Router<'a>, + + #[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 Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "routers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("router", serde_json::to_value(&self.router)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("router".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .router(RouterBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .router(RouterBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "router" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/routers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "router": {} })); + }); + + let endpoint = Request::builder() + .router(RouterBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/routers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "router": {} })); + }); + + let endpoint = Request::builder() + .router(RouterBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/delete.rs b/sdk/network/src/v2/router/delete.rs new file mode 100644 index 000000000..73e2cd3b9 --- /dev/null +++ b/sdk/network/src/v2/router/delete.rs @@ -0,0 +1,189 @@ +// 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`. + +//! Deletes a logical router and, if present, its external gateway interface. +//! +//! This operation fails if the router has attached interfaces. Use the remove +//! router interface operation to remove all router interfaces before you +//! delete the router. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("routers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/routers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/routers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/find.rs b/sdk/network/src/v2/router/find.rs new file mode 100644 index 000000000..68727190e --- /dev/null +++ b/sdk/network/src/v2/router/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::router::{get as Get, list as List}; + +/// Find for router 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/router/get.rs b/sdk/network/src/v2/router/get.rs new file mode 100644 index 000000000..dd5c7a9f7 --- /dev/null +++ b/sdk/network/src/v2/router/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for a router. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("routers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("router".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "router" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/routers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "router": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/routers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "router": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/router/l3_agent.rs b/sdk/network/src/v2/router/l3_agent.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/router/l3_agent.rs rename to sdk/network/src/v2/router/l3_agent.rs diff --git a/sdk/network/src/v2/router/l3_agent/create.rs b/sdk/network/src/v2/router/l3_agent/create.rs new file mode 100644 index 000000000..7ff8f4f35 --- /dev/null +++ b/sdk/network/src/v2/router/l3_agent/create.rs @@ -0,0 +1,215 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + router_id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +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 L3_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "routers/{router_id}/l3-agents", + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/routers/{router_id}/l3-agents", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().router_id("router_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/routers/{router_id}/l3-agents", + router_id = "router_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() + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/l3_agent/delete.rs b/sdk/network/src/v2/router/l3_agent/delete.rs new file mode 100644 index 000000000..e91bd6fb6 --- /dev/null +++ b/sdk/network/src/v2/router/l3_agent/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + router_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 L3_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/l3-agents/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/routers/{router_id}/l3-agents/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/routers/{router_id}/l3-agents/{id}", + id = "id", + router_id = "router_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") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/l3_agent/get.rs b/sdk/network/src/v2/router/l3_agent/get.rs new file mode 100644 index 000000000..c5aa2d40e --- /dev/null +++ b/sdk/network/src/v2/router/l3_agent/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + router_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 L3_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/l3-agents/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/routers/{router_id}/l3-agents/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/routers/{router_id}/l3-agents/{id}", + id = "id", + router_id = "router_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") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/l3_agent/list.rs b/sdk/network/src/v2/router/l3_agent/list.rs new file mode 100644 index 000000000..b7c474761 --- /dev/null +++ b/sdk/network/src/v2/router/l3_agent/list.rs @@ -0,0 +1,275 @@ +// 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`. + +//! Lists l3 agents hosting a specific router. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + router_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the L3_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/l3-agents", + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/routers/{router_id}/l3-agents", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().router_id("router_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/routers/{router_id}/l3-agents", + router_id = "router_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() + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/l3_agent/set.rs b/sdk/network/src/v2/router/l3_agent/set.rs new file mode 100644 index 000000000..65e73f639 --- /dev/null +++ b/sdk/network/src/v2/router/l3_agent/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for /v2.0/routers/{router_id}/l3-agents/{id} API + #[builder(default, setter(into))] + router_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 L3_Agent. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "routers/{router_id}/l3-agents/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/routers/{router_id}/l3-agents/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/routers/{router_id}/l3-agents/{id}", + id = "id", + router_id = "router_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") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/list.rs b/sdk/network/src/v2/router/list.rs new file mode 100644 index 000000000..9bd328d3a --- /dev/null +++ b/sdk/network/src/v2/router/list.rs @@ -0,0 +1,376 @@ +// 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`. + +//! Lists logical routers that the project who submits the request can access. +//! +//! Default policy settings return only those routers that the project who +//! submits the request owns, unless an administrative user submits the +//! request. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// admin_state_up query parameter for /v2.0/routers API + #[builder(default)] + admin_state_up: Option, + + /// description query parameter for /v2.0/routers API + #[builder(default, setter(into))] + description: Option>, + + /// enable_ndp_proxy query parameter for /v2.0/routers API + #[builder(default)] + enable_ndp_proxy: Option, + + /// id query parameter for /v2.0/routers API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/routers API + #[builder(default, setter(into))] + name: Option>, + + /// not-tags query parameter for /v2.0/routers API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/routers API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// revision_number query parameter for /v2.0/routers API + #[builder(default, setter(into))] + revision_number: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tags query parameter for /v2.0/routers API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/routers API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/routers API + #[builder(default, setter(into))] + tenant_id: 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> { + /// not-tags query parameter for /v2.0/routers API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/routers API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/routers API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/routers API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "routers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("admin_state_up", self.admin_state_up); + params.push_opt("description", self.description.as_ref()); + params.push_opt("enable_ndp_proxy", self.enable_ndp_proxy); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("routers".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "routers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/routers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "routers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/routers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "routers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/router/remove_external_gateways.rs b/sdk/network/src/v2/router/remove_external_gateways.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/router/remove_external_gateways.rs rename to sdk/network/src/v2/router/remove_external_gateways.rs index e559c1e2f..28f5b1df2 100644 --- a/openstack_sdk/src/api/network/v2/router/remove_external_gateways.rs +++ b/sdk/network/src/v2/router/remove_external_gateways.rs @@ -179,7 +179,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/router/remove_extraroutes.rs b/sdk/network/src/v2/router/remove_extraroutes.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/router/remove_extraroutes.rs rename to sdk/network/src/v2/router/remove_extraroutes.rs index 6cbc0ec25..3b8e62a1d 100644 --- a/openstack_sdk/src/api/network/v2/router/remove_extraroutes.rs +++ b/sdk/network/src/v2/router/remove_extraroutes.rs @@ -172,7 +172,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/router/remove_router_interface.rs b/sdk/network/src/v2/router/remove_router_interface.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/router/remove_router_interface.rs rename to sdk/network/src/v2/router/remove_router_interface.rs index 81ebaabd2..03d449522 100644 --- a/openstack_sdk/src/api/network/v2/router/remove_router_interface.rs +++ b/sdk/network/src/v2/router/remove_router_interface.rs @@ -160,7 +160,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/network/src/v2/router/set.rs b/sdk/network/src/v2/router/set.rs new file mode 100644 index 000000000..a6067d62b --- /dev/null +++ b/sdk/network/src/v2/router/set.rs @@ -0,0 +1,326 @@ +// 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`. + +//! Updates a logical router. +//! +//! This operation does not enable the update of router interfaces. To update a +//! router interface, use the add router interface and remove router interface +//! operations. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ExternalFixedIps<'a> { + /// IP Address + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ip_address: Option>, + + /// The subnet ID from which the IP address is assigned + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>, +} + +/// The external gateway information of the router. If the router has an +/// external gateway, this would be a dict with `network_id`, `enable_snat`, +/// `external_fixed_ips` and `qos_policy_id`. Otherwise, this would be `null`. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ExternalGatewayInfo<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enable_snat: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_fixed_ips: Option>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) network_id: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) qos_policy_id: Option>>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Routes<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) destination: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) nexthop: Option>, +} + +/// A `router` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Router<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// `true` indicates a distributed router. It is available when `dvr` + /// extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) distributed: Option>, + + /// Enable NDP proxy attribute. Default is `false`, To persist this + /// attribute value, set the `enable_ndp_proxy_by_default` option in the + /// `neutron.conf` file. It is available when `router-extend-ndp-proxy` + /// extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enable_ndp_proxy: Option>, + + /// The external gateway information of the router. If the router has an + /// external gateway, this would be a dict with `network_id`, + /// `enable_snat`, `external_fixed_ips` and `qos_policy_id`. Otherwise, + /// this would be `null`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) external_gateway_info: Option>>, + + /// `true` indicates a highly-available router. It is available when + /// `l3-ha` extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ha: Option>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The extra routes configuration for L3 router. A list of dictionaries + /// with `destination` and `nexthop` parameters. It is available when + /// `extraroute` extension is enabled. Default is an empty list (`[]`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) routes: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `router` object. + #[builder(setter(into))] + pub(crate) router: Router<'a>, + + /// id parameter for /v2.0/routers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Router. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("routers/{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("router", serde_json::to_value(&self.router)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("router".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .router(RouterBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .router(RouterBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "router" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/routers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "router": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router(RouterBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/routers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "router": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router(RouterBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/router/tag.rs b/sdk/network/src/v2/router/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/router/tag.rs rename to sdk/network/src/v2/router/tag.rs diff --git a/sdk/network/src/v2/router/tag/delete.rs b/sdk/network/src/v2/router/tag/delete.rs new file mode 100644 index 000000000..8a23c3bfd --- /dev/null +++ b/sdk/network/src/v2/router/tag/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + router_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/tags/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/routers/{router_id}/tags/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/routers/{router_id}/tags/{id}", + id = "id", + router_id = "router_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") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/tag/delete_all.rs b/sdk/network/src/v2/router/tag/delete_all.rs new file mode 100644 index 000000000..2c7d76e31 --- /dev/null +++ b/sdk/network/src/v2/router/tag/delete_all.rs @@ -0,0 +1,188 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + router_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/tags", + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/routers/{router_id}/tags", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().router_id("router_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/routers/{router_id}/tags", + router_id = "router_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() + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/tag/get.rs b/sdk/network/src/v2/router/tag/get.rs new file mode 100644 index 000000000..c915bf63a --- /dev/null +++ b/sdk/network/src/v2/router/tag/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + router_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/tags/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/routers/{router_id}/tags/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/routers/{router_id}/tags/{id}", + id = "id", + router_id = "router_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") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/tag/list.rs b/sdk/network/src/v2/router/tag/list.rs new file mode 100644 index 000000000..0ba2a6de9 --- /dev/null +++ b/sdk/network/src/v2/router/tag/list.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + router_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "routers/{router_id}/tags", + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/routers/{router_id}/tags", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().router_id("router_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/routers/{router_id}/tags", + router_id = "router_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/tag/replace.rs b/sdk/network/src/v2/router/tag/replace.rs new file mode 100644 index 000000000..053d6462f --- /dev/null +++ b/sdk/network/src/v2/router/tag/replace.rs @@ -0,0 +1,216 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + router_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "routers/{router_id}/tags", + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/routers/{router_id}/tags", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .router_id("router_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/routers/{router_id}/tags", + router_id = "router_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .router_id("router_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/router/tag/set.rs b/sdk/network/src/v2/router/tag/set.rs new file mode 100644 index 000000000..8c58cb219 --- /dev/null +++ b/sdk/network/src/v2/router/tag/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// router_id parameter for /v2.0/routers/{router_id}/tags/{id} API + #[builder(default, setter(into))] + router_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "routers/{router_id}/tags/{id}", + id = self.id.as_ref(), + router_id = self.router_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/routers/{router_id}/tags/{id}", + id = "id", + router_id = "router_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .router_id("router_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/routers/{router_id}/tags/{id}", + id = "id", + router_id = "router_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") + .router_id("router_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/router/update_external_gateways.rs b/sdk/network/src/v2/router/update_external_gateways.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/router/update_external_gateways.rs rename to sdk/network/src/v2/router/update_external_gateways.rs index eaff6f1fb..1a97d035c 100644 --- a/openstack_sdk/src/api/network/v2/router/update_external_gateways.rs +++ b/sdk/network/src/v2/router/update_external_gateways.rs @@ -200,7 +200,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/security_group.rs b/sdk/network/src/v2/security_group.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/security_group.rs rename to sdk/network/src/v2/security_group.rs diff --git a/sdk/network/src/v2/security_group/create.rs b/sdk/network/src/v2/security_group/create.rs new file mode 100644 index 000000000..7b9cfdbb9 --- /dev/null +++ b/sdk/network/src/v2/security_group/create.rs @@ -0,0 +1,242 @@ +// 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`. + +//! Creates an OpenStack Networking security group. +//! +//! This operation creates a security group with default security group rules +//! for the IPv4 and IPv6 ether types. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `security_group` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SecurityGroup<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Indicates if the security group is stateful or stateless. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) stateful: Option, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `security_group` object. + #[builder(setter(into))] + pub(crate) security_group: SecurityGroup<'a>, + + #[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 Security_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "security-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "security_group", + serde_json::to_value(&self.security_group)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "security_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/security-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group": {} })); + }); + + let endpoint = Request::builder() + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/security-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group": {} })); + }); + + let endpoint = Request::builder() + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/delete.rs b/sdk/network/src/v2/security_group/delete.rs new file mode 100644 index 000000000..e17501afc --- /dev/null +++ b/sdk/network/src/v2/security_group/delete.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Deletes an OpenStack Networking security group. +//! +//! This operation deletes an OpenStack Networking security group and its +//! associated security group rules, provided that a port is not associated +//! with the security group. If a port is associated with the security group +//! 409 (Conflict) is returned. +//! +//! This operation does not require a request body. This operation does not +//! return a response body. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/security-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Security_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("security-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/security-groups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/security-groups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/find.rs b/sdk/network/src/v2/security_group/find.rs new file mode 100644 index 000000000..9f8024af8 --- /dev/null +++ b/sdk/network/src/v2/security_group/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::security_group::{get as Get, list as List}; + +/// Find for security_group 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/security_group/get.rs b/sdk/network/src/v2/security_group/get.rs new file mode 100644 index 000000000..57c2c9cfb --- /dev/null +++ b/sdk/network/src/v2/security_group/get.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows details for a security group. +//! +//! The associated security group rules are contained in the response. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/security-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Security_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("security-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "security_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/security-groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/security-groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/list.rs b/sdk/network/src/v2/security_group/list.rs new file mode 100644 index 000000000..a73682dcb --- /dev/null +++ b/sdk/network/src/v2/security_group/list.rs @@ -0,0 +1,370 @@ +// 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`. + +//! Lists OpenStack Networking security groups to which the project has access. +//! +//! The response is an array of `security_group` objects which contains a list +//! of `security_group_rules` objects. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/security-groups API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/security-groups API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/security-groups API + #[builder(default, setter(into))] + name: Option>, + + /// not-tags query parameter for /v2.0/security-groups API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/security-groups API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// revision_number query parameter for /v2.0/security-groups API + #[builder(default, setter(into))] + revision_number: Option>, + + /// shared query parameter for /v2.0/security-groups API + #[builder(default)] + shared: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tags query parameter for /v2.0/security-groups API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/security-groups API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/security-groups API + #[builder(default, setter(into))] + tenant_id: 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> { + /// not-tags query parameter for /v2.0/security-groups API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/security-groups API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/security-groups API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/security-groups API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Security_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "security-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("shared", self.shared); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_groups".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "security_groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/security-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/security-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/set.rs b/sdk/network/src/v2/security_group/set.rs new file mode 100644 index 000000000..ab203309f --- /dev/null +++ b/sdk/network/src/v2/security_group/set.rs @@ -0,0 +1,239 @@ +// 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`. + +//! Updates a security group. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `security_group` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SecurityGroup<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) stateful: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `security_group` object. + #[builder(setter(into))] + pub(crate) security_group: SecurityGroup<'a>, + + /// id parameter for /v2.0/security-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Security_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("security-groups/{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( + "security_group", + serde_json::to_value(&self.security_group)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "security_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/security-groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/security-groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .security_group(SecurityGroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/security_group/tag.rs b/sdk/network/src/v2/security_group/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/security_group/tag.rs rename to sdk/network/src/v2/security_group/tag.rs diff --git a/sdk/network/src/v2/security_group/tag/delete.rs b/sdk/network/src/v2/security_group/tag/delete.rs new file mode 100644 index 000000000..523ce8588 --- /dev/null +++ b/sdk/network/src/v2/security_group/tag/delete.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/security-groups/{security_group_id}/tags/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// security_group_id parameter for + /// /v2.0/security-groups/{security_group_id}/tags/{id} API + #[builder(default, setter(into))] + security_group_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "security-groups/{security_group_id}/tags/{id}", + id = self.id.as_ref(), + security_group_id = self.security_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/security-groups/{security_group_id}/tags/{id}", + id = "id", + security_group_id = "security_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .security_group_id("security_group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/security-groups/{security_group_id}/tags/{id}", + id = "id", + security_group_id = "security_group_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") + .security_group_id("security_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/tag/delete_all.rs b/sdk/network/src/v2/security_group/tag/delete_all.rs new file mode 100644 index 000000000..6c9d34ae0 --- /dev/null +++ b/sdk/network/src/v2/security_group/tag/delete_all.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// security_group_id parameter for + /// /v2.0/security-groups/{security_group_id}/tags/{id} API + #[builder(default, setter(into))] + security_group_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "security-groups/{security_group_id}/tags", + security_group_id = self.security_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/security-groups/{security_group_id}/tags", + security_group_id = "security_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .security_group_id("security_group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/security-groups/{security_group_id}/tags", + security_group_id = "security_group_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() + .security_group_id("security_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/tag/get.rs b/sdk/network/src/v2/security_group/tag/get.rs new file mode 100644 index 000000000..08c32caa2 --- /dev/null +++ b/sdk/network/src/v2/security_group/tag/get.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/security-groups/{security_group_id}/tags/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// security_group_id parameter for + /// /v2.0/security-groups/{security_group_id}/tags/{id} API + #[builder(default, setter(into))] + security_group_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "security-groups/{security_group_id}/tags/{id}", + id = self.id.as_ref(), + security_group_id = self.security_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/security-groups/{security_group_id}/tags/{id}", + id = "id", + security_group_id = "security_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .security_group_id("security_group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/security-groups/{security_group_id}/tags/{id}", + id = "id", + security_group_id = "security_group_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") + .security_group_id("security_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/tag/list.rs b/sdk/network/src/v2/security_group/tag/list.rs new file mode 100644 index 000000000..db8047ab7 --- /dev/null +++ b/sdk/network/src/v2/security_group/tag/list.rs @@ -0,0 +1,263 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// security_group_id parameter for + /// /v2.0/security-groups/{security_group_id}/tags/{id} API + #[builder(default, setter(into))] + security_group_id: Cow<'a, str>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "security-groups/{security_group_id}/tags", + security_group_id = self.security_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/security-groups/{security_group_id}/tags", + security_group_id = "security_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .security_group_id("security_group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/security-groups/{security_group_id}/tags", + security_group_id = "security_group_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .security_group_id("security_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/tag/replace.rs b/sdk/network/src/v2/security_group/tag/replace.rs new file mode 100644 index 000000000..ee34edcde --- /dev/null +++ b/sdk/network/src/v2/security_group/tag/replace.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// security_group_id parameter for + /// /v2.0/security-groups/{security_group_id}/tags/{id} API + #[builder(default, setter(into))] + security_group_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "security-groups/{security_group_id}/tags", + security_group_id = self.security_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/security-groups/{security_group_id}/tags", + security_group_id = "security_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .security_group_id("security_group_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/security-groups/{security_group_id}/tags", + security_group_id = "security_group_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .security_group_id("security_group_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group/tag/set.rs b/sdk/network/src/v2/security_group/tag/set.rs new file mode 100644 index 000000000..314304305 --- /dev/null +++ b/sdk/network/src/v2/security_group/tag/set.rs @@ -0,0 +1,202 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/security-groups/{security_group_id}/tags/{id} + /// API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// security_group_id parameter for + /// /v2.0/security-groups/{security_group_id}/tags/{id} API + #[builder(default, setter(into))] + security_group_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "security-groups/{security_group_id}/tags/{id}", + id = self.id.as_ref(), + security_group_id = self.security_group_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/security-groups/{security_group_id}/tags/{id}", + id = "id", + security_group_id = "security_group_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .security_group_id("security_group_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/security-groups/{security_group_id}/tags/{id}", + id = "id", + security_group_id = "security_group_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") + .security_group_id("security_group_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/security_group_rule.rs b/sdk/network/src/v2/security_group_rule.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/security_group_rule.rs rename to sdk/network/src/v2/security_group_rule.rs diff --git a/sdk/network/src/v2/security_group_rule/create.rs b/sdk/network/src/v2/security_group_rule/create.rs new file mode 100644 index 000000000..be3f208b9 --- /dev/null +++ b/sdk/network/src/v2/security_group_rule/create.rs @@ -0,0 +1,308 @@ +// 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`. + +//! Creates an OpenStack Networking security group rule. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Direction { + #[serde(rename = "egress")] + Egress, + #[serde(rename = "ingress")] + Ingress, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Ethertype { + #[serde(rename = "IPv4")] + Ipv4, + #[serde(rename = "IPv6")] + Ipv6, +} + +/// A `security_group_rule` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SecurityGroupRule<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Ingress or egress, which is the direction in which the security group + /// rule is applied. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) direction: Option, + + /// Must be IPv4 or IPv6, and addresses represented in CIDR must match the + /// ingress or egress rules. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) ethertype: Option, + + /// The maximum port number in the range that is matched by the security + /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this + /// value must be greater than or equal to the `port_range_min` attribute + /// value. If the protocol is ICMP, this value must be an ICMP code. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_range_max: Option>, + + /// The minimum port number in the range that is matched by the security + /// group rule. If the protocol is TCP, UDP, DCCP, SCTP or UDP-Lite this + /// value must be less than or equal to the `port_range_max` attribute + /// value. If the protocol is ICMP, this value must be an ICMP type. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) port_range_min: Option>, + + /// The IP protocol can be represented by a string, an integer, or `null`. + /// Valid string or integer values are `any` or `0`, `ah` or `51`, `dccp` + /// or `33`, `egp` or `8`, `esp` or `50`, `gre` or `47`, `icmp` or `1`, + /// `icmpv6` or `58`, `igmp` or `2`, `ipip` or `4`, `ipv6-encap` or `41`, + /// `ipv6-frag` or `44`, `ipv6-icmp` or `58`, `ipv6-nonxt` or `59`, + /// `ipv6-opts` or `60`, `ipv6-route` or `43`, `ospf` or `89`, `pgm` or + /// `113`, `rsvp` or `46`, `sctp` or `132`, `tcp` or `6`, `udp` or `17`, + /// `udplite` or `136`, `vrrp` or `112`. Additionally, any integer value + /// between [0-255] is also valid. The string `any` (or integer `0`) means + /// `all` IP protocols. See the constants in `neutron_lib.constants` for + /// the most up-to-date list of supported strings. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) protocol: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_address_group_id: Option>, + + /// The remote group UUID to associate with this security group rule. You + /// can specify either the `remote_group_id` or `remote_ip_prefix` + /// attribute in the request body. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_group_id: Option>, + + /// The remote IP prefix that is matched by this security group rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) remote_ip_prefix: Option>, + + /// The security group ID to associate with this security group rule. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) security_group_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `security_group_rule` object. + #[builder(setter(into))] + pub(crate) security_group_rule: SecurityGroupRule<'a>, + + #[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 Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "security-group-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "security_group_rule", + serde_json::to_value(&self.security_group_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_group_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "security_group_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/security-group-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/security-group-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group_rule/delete.rs b/sdk/network/src/v2/security_group_rule/delete.rs new file mode 100644 index 000000000..2ecf20862 --- /dev/null +++ b/sdk/network/src/v2/security_group_rule/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a rule from an OpenStack Networking security group. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/security-group-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("security-group-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/security-group-rules/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/security-group-rules/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group_rule/get.rs b/sdk/network/src/v2/security_group_rule/get.rs new file mode 100644 index 000000000..01dac50a3 --- /dev/null +++ b/sdk/network/src/v2/security_group_rule/get.rs @@ -0,0 +1,194 @@ +// 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`. + +//! Shows detailed information for a security group rule. +//! +//! The response body contains the following information about the security +//! group rule: +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/security-group-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("security-group-rules/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_group_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "security_group_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/security-group-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rule": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/security-group-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group_rule/list.rs b/sdk/network/src/v2/security_group_rule/list.rs new file mode 100644 index 000000000..45df0bf81 --- /dev/null +++ b/sdk/network/src/v2/security_group_rule/list.rs @@ -0,0 +1,347 @@ +// 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`. + +//! Lists a summary of all OpenStack Networking security group rules that the +//! project can access. +//! +//! The list provides the ID for each security group rule. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// belongs_to_default_sg query parameter for /v2.0/security-group-rules + /// API + #[builder(default)] + belongs_to_default_sg: Option, + + /// description query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + description: Option>, + + /// direction query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + direction: Option>, + + /// ethertype query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + ethertype: Option>, + + /// id query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// normalized_cidr query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + normalized_cidr: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// port_range_max query parameter for /v2.0/security-group-rules API + #[builder(default)] + port_range_max: Option, + + /// port_range_min query parameter for /v2.0/security-group-rules API + #[builder(default)] + port_range_min: Option, + + /// protocol query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + protocol: Option>, + + /// remote_address_group_id query parameter for /v2.0/security-group-rules + /// API + #[builder(default, setter(into))] + remote_address_group_id: Option>, + + /// remote_group_id query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + remote_group_id: Option>, + + /// remote_ip_prefix query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + remote_ip_prefix: Option>, + + /// revision_number query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + revision_number: Option>, + + /// security_group_id query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + security_group_id: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tenant_id query parameter for /v2.0/security-group-rules API + #[builder(default, setter(into))] + tenant_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "security-group-rules".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("belongs_to_default_sg", self.belongs_to_default_sg); + params.push_opt("description", self.description.as_ref()); + params.push_opt("direction", self.direction.as_ref()); + params.push_opt("ethertype", self.ethertype.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("normalized_cidr", self.normalized_cidr.as_ref()); + params.push_opt("port_range_max", self.port_range_max); + params.push_opt("port_range_min", self.port_range_min); + params.push_opt("protocol", self.protocol.as_ref()); + params.push_opt( + "remote_address_group_id", + self.remote_address_group_id.as_ref(), + ); + params.push_opt("remote_group_id", self.remote_group_id.as_ref()); + params.push_opt("remote_ip_prefix", self.remote_ip_prefix.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("security_group_id", self.security_group_id.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_group_rules".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "security_group_rules" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/security-group-rules".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rules": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/security-group-rules".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rules": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/security_group_rule/set.rs b/sdk/network/src/v2/security_group_rule/set.rs new file mode 100644 index 000000000..3d7c78d95 --- /dev/null +++ b/sdk/network/src/v2/security_group_rule/set.rs @@ -0,0 +1,220 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct SecurityGroupRule<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) security_group_rule: SecurityGroupRule<'a>, + + /// id parameter for /v2.0/security-group-rules/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Security_Group_Rule. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("security-group-rules/{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( + "security_group_rule", + serde_json::to_value(&self.security_group_rule)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("security_group_rule".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "security_group_rule" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/security-group-rules/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/security-group-rules/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "security_group_rule": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .security_group_rule(SecurityGroupRuleBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/segment.rs b/sdk/network/src/v2/segment.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/segment.rs rename to sdk/network/src/v2/segment.rs diff --git a/sdk/network/src/v2/segment/create.rs b/sdk/network/src/v2/segment/create.rs new file mode 100644 index 000000000..f8989ef4d --- /dev/null +++ b/sdk/network/src/v2/segment/create.rs @@ -0,0 +1,253 @@ +// 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`. + +//! Creates a segment. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Segment<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the segment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// The ID of the attached network. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) network_id: Option>, + + /// The type of physical network that maps to this network resource. For + /// example, `flat`, `vlan`, `vxlan`, or `gre`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) network_type: Option>, + + /// The physical network where this network/segment is implemented. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) physical_network: Option>, + + /// The ID of the isolated segment on the physical network. The + /// `network_type` attribute defines the segmentation model. For example, + /// if the `network_type` value is vlan, this ID is a vlan identifier. If + /// the `network_type` value is gre, this ID is a gre key. `Note` that only + /// the segmentation-id of VLAN type networks can be changed! + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) segmentation_id: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) segment: Segment<'a>, + + #[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 Segment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "segments".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("segment", serde_json::to_value(&self.segment)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("segment".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .segment(SegmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .segment(SegmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "segment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/segments".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segment": {} })); + }); + + let endpoint = Request::builder() + .segment(SegmentBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/segments".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segment": {} })); + }); + + let endpoint = Request::builder() + .segment(SegmentBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/segment/delete.rs b/sdk/network/src/v2/segment/delete.rs new file mode 100644 index 000000000..9503cf2fa --- /dev/null +++ b/sdk/network/src/v2/segment/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Deletes a segment and its associated resources. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/segments/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Segment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("segments/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/segments/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/segments/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/segment/find.rs b/sdk/network/src/v2/segment/find.rs new file mode 100644 index 000000000..9ba5b717d --- /dev/null +++ b/sdk/network/src/v2/segment/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::segment::{get as Get, list as List}; + +/// Find for segment 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/segment/get.rs b/sdk/network/src/v2/segment/get.rs new file mode 100644 index 000000000..4358c0c9c --- /dev/null +++ b/sdk/network/src/v2/segment/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for a segment. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/segments/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Segment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("segments/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("segment".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "segment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/segments/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segment": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/segments/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/segment/list.rs b/sdk/network/src/v2/segment/list.rs new file mode 100644 index 000000000..b757e21e8 --- /dev/null +++ b/sdk/network/src/v2/segment/list.rs @@ -0,0 +1,299 @@ +// 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`. + +//! Lists segments to which the project has access. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/segments API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/segments API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/segments API + #[builder(default, setter(into))] + name: Option>, + + /// network_id query parameter for /v2.0/segments API + #[builder(default, setter(into))] + network_id: Option>, + + /// network_type query parameter for /v2.0/segments API + #[builder(default, setter(into))] + network_type: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// physical_network query parameter for /v2.0/segments API + #[builder(default, setter(into))] + physical_network: Option>, + + /// revision_number query parameter for /v2.0/segments API + #[builder(default, setter(into))] + revision_number: Option>, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Segment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "segments".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("network_id", self.network_id.as_ref()); + params.push_opt("network_type", self.network_type.as_ref()); + params.push_opt("physical_network", self.physical_network.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("segments".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "segments" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/segments".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segments": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/segments".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segments": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/segment/set.rs b/sdk/network/src/v2/segment/set.rs new file mode 100644 index 000000000..3b8ab5c42 --- /dev/null +++ b/sdk/network/src/v2/segment/set.rs @@ -0,0 +1,230 @@ +// 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`. + +//! Updates a segment. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Segment<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the segment. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) segment: Segment<'a>, + + /// id parameter for /v2.0/segments/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Segment. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("segments/{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("segment", serde_json::to_value(&self.segment)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("segment".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .segment(SegmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .segment(SegmentBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "segment" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/segments/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .segment(SegmentBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/segments/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "segment": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .segment(SegmentBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/service_profile.rs b/sdk/network/src/v2/service_profile.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/service_profile.rs rename to sdk/network/src/v2/service_profile.rs diff --git a/sdk/network/src/v2/service_profile/create.rs b/sdk/network/src/v2/service_profile/create.rs new file mode 100644 index 000000000..619e24b78 --- /dev/null +++ b/sdk/network/src/v2/service_profile/create.rs @@ -0,0 +1,257 @@ +// 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`. + +//! Creates a service profile. +//! +//! This operation establishes a new service profile that can be associated +//! with one or more flavors. +//! +//! Either metadata or a driver is required. +//! +//! If a driver is specified but does not exist, call will return a +//! `Not found 404` error with the response body explaining that the driver +//! could not be found. +//! +//! Creation currently limited to administrators. Other users will receive a +//! `Forbidden 403` response code with a response body NeutronError message +//! expressing that creation is disallowed by policy. +//! +//! If the API cannot fulfill the request due to insufficient data or data that +//! is not valid, the service returns the HTTP `Bad Request (400)` response +//! code with information about the failure in the response body. Validation +//! errors require that you correct the error and submit the request again. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `service_profile` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ServiceProfile<'a> { + /// The human-readable description for the service profile. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Provider driver to use for this profile. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) driver: Option>, + + /// Indicates whether this service profile is enabled or not. Default is + /// `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option>, + + /// JSON-formatted meta information of the service profile. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) metainfo: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `service_profile` object. + #[builder(setter(into))] + pub(crate) service_profile: ServiceProfile<'a>, + + #[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 Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "service_profiles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "service_profile", + serde_json::to_value(&self.service_profile)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/service_profiles".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/service_profiles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_profile/delete.rs b/sdk/network/src/v2/service_profile/delete.rs new file mode 100644 index 000000000..44d44008c --- /dev/null +++ b/sdk/network/src/v2/service_profile/delete.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Deletes a service profile. +//! +//! Attempting to delete a service profile that is currently associated with a +//! flavor will return a `Conflict 409` with a response body containing an in +//! use message. +//! +//! Either metadata or a driver is required. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("service_profiles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/service_profiles/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/service_profiles/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_profile/get.rs b/sdk/network/src/v2/service_profile/get.rs new file mode 100644 index 000000000..6b7a09e3a --- /dev/null +++ b/sdk/network/src/v2/service_profile/get.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Shows details for a service profile. +//! +//! This operation returns a service profile object by ID. If you are not an +//! administrative user and the object is not visible to your tenant account, +//! the service returns the HTTP `Forbidden (403)` response code. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("service_profiles/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/service_profiles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/service_profiles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_profile/list.rs b/sdk/network/src/v2/service_profile/list.rs new file mode 100644 index 000000000..20daa7898 --- /dev/null +++ b/sdk/network/src/v2/service_profile/list.rs @@ -0,0 +1,286 @@ +// 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`. + +//! Lists all service profiles visible for the tenant account. +//! +//! The list can be empty. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// description query parameter for /v2.0/service_profiles API + #[builder(default, setter(into))] + description: Option>, + + /// driver query parameter for /v2.0/service_profiles API + #[builder(default, setter(into))] + driver: Option>, + + /// enabled query parameter for /v2.0/service_profiles API + #[builder(default)] + enabled: Option, + + /// id query parameter for /v2.0/service_profiles API + #[builder(default, setter(into))] + id: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "service_profiles".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + params.push_opt("description", self.description.as_ref()); + params.push_opt("driver", self.driver.as_ref()); + params.push_opt("enabled", self.enabled); + params.push_opt("id", self.id.as_ref()); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profiles".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_profiles" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/service_profiles".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profiles": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/service_profiles".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profiles": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_profile/set.rs b/sdk/network/src/v2/service_profile/set.rs new file mode 100644 index 000000000..a3e9dc7a9 --- /dev/null +++ b/sdk/network/src/v2/service_profile/set.rs @@ -0,0 +1,245 @@ +// 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`. + +//! Updates a service profile. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `service_profile` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ServiceProfile<'a> { + /// The human-readable description for the service profile. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// Provider driver to use for this profile. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) driver: Option>, + + /// Indicates whether this service profile is enabled or not. Default is + /// `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enabled: Option>, + + /// JSON-formatted meta information of the service profile. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) metainfo: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `service_profile` object. + #[builder(setter(into))] + pub(crate) service_profile: ServiceProfile<'a>, + + /// id parameter for /v2.0/flavors/{flavor_id}/service_profiles/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Profile. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("service_profiles/{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( + "service_profile", + serde_json::to_value(&self.service_profile)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_profile".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_profile" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/service_profiles/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/service_profiles/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_profile": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_profile(ServiceProfileBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/service_provider.rs b/sdk/network/src/v2/service_provider.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/service_provider.rs rename to sdk/network/src/v2/service_provider.rs diff --git a/sdk/network/src/v2/service_provider/create.rs b/sdk/network/src/v2/service_provider/create.rs new file mode 100644 index 000000000..1836cbcc8 --- /dev/null +++ b/sdk/network/src/v2/service_provider/create.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_service_provider"))] + pub(crate) service_provider: BTreeMap, Value>, + + #[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 service_provider(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.service_provider + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "service-providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "service_provider", + serde_json::to_value(&self.service_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_provider".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/service-providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .service_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/service-providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .service_provider(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_provider/delete.rs b/sdk/network/src/v2/service_provider/delete.rs new file mode 100644 index 000000000..bbf950d7d --- /dev/null +++ b/sdk/network/src/v2/service_provider/delete.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/service-providers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("service-providers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/service-providers/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/service-providers/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_provider/get.rs b/sdk/network/src/v2/service_provider/get.rs new file mode 100644 index 000000000..52fa6a22d --- /dev/null +++ b/sdk/network/src/v2/service_provider/get.rs @@ -0,0 +1,182 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/service-providers/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("service-providers/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_provider".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/service-providers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/service-providers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_provider/list.rs b/sdk/network/src/v2/service_provider/list.rs new file mode 100644 index 000000000..c1b8d5a30 --- /dev/null +++ b/sdk/network/src/v2/service_provider/list.rs @@ -0,0 +1,264 @@ +// 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`. + +//! Lists service providers and their associated service types. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "service-providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_providers".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "service_providers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/service-providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_providers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/service-providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_providers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/service_provider/set.rs b/sdk/network/src/v2/service_provider/set.rs new file mode 100644 index 000000000..9f9970d92 --- /dev/null +++ b/sdk/network/src/v2/service_provider/set.rs @@ -0,0 +1,224 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(into, name = "_service_provider"))] + pub(crate) service_provider: BTreeMap, Value>, + + /// id parameter for /v2.0/service-providers/{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<'a> RequestBuilder<'a> { + pub fn service_provider(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.service_provider + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Service_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("service-providers/{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( + "service_provider", + serde_json::to_value(&self.service_provider)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("service_provider".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .service_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .service_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .unwrap(), + "service_provider" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/service-providers/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_provider(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/service-providers/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "service_provider": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .service_provider(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/subnet.rs b/sdk/network/src/v2/subnet.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/subnet.rs rename to sdk/network/src/v2/subnet.rs diff --git a/sdk/network/src/v2/subnet/create.rs b/sdk/network/src/v2/subnet/create.rs new file mode 100644 index 000000000..4b690fbff --- /dev/null +++ b/sdk/network/src/v2/subnet/create.rs @@ -0,0 +1,429 @@ +// 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`. + +//! Creates a subnet on a network. +//! +//! OpenStack Networking does not try to derive the correct IP version from the +//! CIDR. If you do not specify the `gateway_ip` attribute, OpenStack +//! Networking allocates an address from the CIDR for the gateway for the +//! subnet. +//! +//! To specify a subnet without a gateway, set the `gateway_ip` attribute to +//! `null` in the request body. If you do not specify the `allocation_pools` +//! attribute, OpenStack Networking automatically allocates pools for covering +//! all IP addresses in the CIDR, excluding the address reserved for the subnet +//! gateway. Otherwise, you can explicitly specify allocation pools as shown in +//! the following example. +//! +//! When you specify both the `allocation_pools` and `gateway_ip` attributes, +//! you must ensure that the gateway IP does not overlap with the allocation +//! pools; otherwise, the call returns the `Conflict (409)` response code. +//! +//! A subnet can have one or more name servers and host routes. Hosts in this +//! subnet use the name servers. Devices with IP addresses from this subnet, +//! not including the local subnet route, use the host routes. +//! +//! Specify the `ipv6_ra_mode` and `ipv6_address_mode` attributes to create +//! subnets that support IPv6 configurations, such as stateless address +//! autoconfiguration (SLAAC), DHCPv6 stateful, and DHCPv6 stateless +//! configurations. +//! +//! A subnet can optionally be associated with a network segment when it is +//! created by specifying the `segment_id` of a valid segment on the specified +//! network. A network with subnets associated in this way is called a routed +//! network. On any given network, all of the subnets must be associated with +//! segments or none of them can be. Neutron enforces this invariant. +//! Currently, routed networks are only supported for provider networks. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationPools<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) end: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) start: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct HostRoutes<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) destination: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) nexthop: Option>, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Ipv6AddressMode { + #[serde(rename = "dhcpv6-stateful")] + Dhcpv6Stateful, + #[serde(rename = "dhcpv6-stateless")] + Dhcpv6Stateless, + #[serde(rename = "slaac")] + Slaac, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Ipv6RaMode { + #[serde(rename = "dhcpv6-stateful")] + Dhcpv6Stateful, + #[serde(rename = "dhcpv6-stateless")] + Dhcpv6Stateless, + #[serde(rename = "slaac")] + Slaac, +} + +/// A `subnet` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Subnet<'a> { + /// Allocation pools with `start` and `end` IP addresses for this subnet. + /// If allocation_pools are not specified, OpenStack Networking + /// automatically allocates pools for covering all IP addresses in the + /// CIDR, excluding the address reserved for the subnet gateway by default. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allocation_pools: Option>>, + + /// The CIDR of the subnet. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) cidr: Option>>, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// List of dns name servers associated with the subnet. Default is an + /// empty list. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_nameservers: Option>>, + + /// Whether to publish DNS records for IPs from this subnet. Default is + /// `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_publish_fixed_ip: Option, + + /// Indicates whether dhcp is enabled or disabled for the subnet. Default + /// is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enable_dhcp: Option, + + /// Gateway IP of this subnet. If the value is `null` that implies no + /// gateway is associated with the subnet. If the gateway_ip is not + /// specified, OpenStack Networking allocates an address from the CIDR for + /// the gateway for the subnet by default. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) gateway_ip: Option>>, + + /// Additional routes for the subnet. A list of dictionaries with + /// `destination` and `nexthop` parameters. Default value is an empty list. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host_routes: Option>>, + + /// The IP protocol version. Value is `4` or `6`. + #[serde()] + #[builder(setter(into))] + pub(crate) ip_version: i32, + + /// The IPv6 address modes specifies mechanisms for assigning IP addresses. + /// Value is `slaac`, `dhcpv6-stateful`, `dhcpv6-stateless`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) ipv6_address_mode: Option, + + /// The IPv6 router advertisement specifies whether the networking service + /// should transmit ICMPv6 packets, for a subnet. Value is `slaac`, + /// `dhcpv6-stateful`, `dhcpv6-stateless`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) ipv6_ra_mode: Option, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the network to which the subnet belongs. + #[serde()] + #[builder(setter(into))] + pub(crate) network_id: Cow<'a, str>, + + /// The prefix length to use for subnet allocation from a subnet pool. If + /// not specified, the `default_prefixlen` value of the subnet pool will be + /// used. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) prefixlen: Option, + + /// The ID of a network segment the subnet is associated with. It is + /// available when `segment` extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) segment_id: Option>>, + + /// The service types associated with the subnet. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_types: Option>>, + + /// The ID of the subnet pool associated with the subnet. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnetpool_id: Option>>, + + /// The ID of the project that owns the resource. Only administrative and + /// users with advsvc role can specify a project ID other than their own. + /// You cannot change this value through authorization policies. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// Whether to allocate this subnet from the default subnet pool. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) use_default_subnetpool: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `subnet` object. + #[builder(setter(into))] + pub(crate) subnet: Subnet<'a>, + + #[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 Subnet. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "subnets".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("subnet", serde_json::to_value(&self.subnet)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnet".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .subnet( + SubnetBuilder::default() + .ip_version(123) + .network_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .subnet( + SubnetBuilder::default() + .ip_version(123) + .network_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "subnet" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/subnets".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnet": {} })); + }); + + let endpoint = Request::builder() + .subnet( + SubnetBuilder::default() + .ip_version(123) + .network_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/subnets".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnet": {} })); + }); + + let endpoint = Request::builder() + .subnet( + SubnetBuilder::default() + .ip_version(123) + .network_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/delete.rs b/sdk/network/src/v2/subnet/delete.rs new file mode 100644 index 000000000..b67ef2cd6 --- /dev/null +++ b/sdk/network/src/v2/subnet/delete.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Deletes a subnet. +//! +//! The operation fails if subnet IP addresses are still allocated. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// subnet_id parameter for /v2.0/subnets/{subnet_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<'a> RequestBuilder<'a> { + /// Add a single header to the Subnet. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("subnets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/subnets/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/subnets/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/find.rs b/sdk/network/src/v2/subnet/find.rs new file mode 100644 index 000000000..1946da0bc --- /dev/null +++ b/sdk/network/src/v2/subnet/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::subnet::{get as Get, list as List}; + +/// Find for subnet 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/subnet/get.rs b/sdk/network/src/v2/subnet/get.rs new file mode 100644 index 000000000..dfd7ae95f --- /dev/null +++ b/sdk/network/src/v2/subnet/get.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Shows details for a subnet. +//! +//! Use the fields query parameter to filter the results. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// subnet_id parameter for /v2.0/subnets/{subnet_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<'a> RequestBuilder<'a> { + /// Add a single header to the Subnet. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("subnets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnet".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "subnet" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/subnets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnet": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/subnets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnet": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/list.rs b/sdk/network/src/v2/subnet/list.rs new file mode 100644 index 000000000..9732195bc --- /dev/null +++ b/sdk/network/src/v2/subnet/list.rs @@ -0,0 +1,422 @@ +// 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`. + +//! Lists subnets that the project has access to. +//! +//! Default policy settings return only subnets owned by the project of the +//! user submitting the request, unless the user has administrative role. You +//! can control which attributes are returned by using the fields query +//! parameter. You can filter results by using query string parameters. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// cidr query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + cidr: Option>, + + /// description query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + description: Option>, + + /// enable_dhcp query parameter for /v2.0/subnets API + #[builder(default)] + enable_dhcp: Option, + + /// gateway_ip query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + gateway_ip: Option>, + + /// id query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + id: Option>, + + /// ip_version query parameter for /v2.0/subnets API + #[builder(default)] + ip_version: Option, + + /// ipv6_address_mode query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + ipv6_address_mode: Option>, + + /// ipv6_ra_mode query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + ipv6_ra_mode: Option>, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// name query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + name: Option>, + + /// network_id query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + network_id: Option>, + + /// not-tags query parameter for /v2.0/subnets API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/subnets API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// revision_number query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + revision_number: Option>, + + /// The membership of a subnet to an external network. + #[builder(default)] + router_external: Option, + + /// segment_id query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + segment_id: Option>, + + /// shared query parameter for /v2.0/subnets API + #[builder(default)] + shared: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// subnetpool_id query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + subnetpool_id: Option>, + + /// tags query parameter for /v2.0/subnets API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/subnets API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/subnets API + #[builder(default, setter(into))] + tenant_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags query parameter for /v2.0/subnets API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/subnets API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/subnets API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/subnets API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Subnet. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "subnets".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + params.push_opt("cidr", self.cidr.as_ref()); + params.push_opt("description", self.description.as_ref()); + params.push_opt("enable_dhcp", self.enable_dhcp); + params.push_opt("gateway_ip", self.gateway_ip.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("ip_version", self.ip_version); + params.push_opt("ipv6_address_mode", self.ipv6_address_mode.as_ref()); + params.push_opt("ipv6_ra_mode", self.ipv6_ra_mode.as_ref()); + params.push_opt("name", self.name.as_ref()); + params.push_opt("network_id", self.network_id.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("router:external", self.router_external); + params.push_opt("segment_id", self.segment_id.as_ref()); + params.push_opt("shared", self.shared); + params.push_opt("subnetpool_id", self.subnetpool_id.as_ref()); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnets".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "subnets" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/subnets".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnets": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/subnets".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnets": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/set.rs b/sdk/network/src/v2/subnet/set.rs new file mode 100644 index 000000000..383d37123 --- /dev/null +++ b/sdk/network/src/v2/subnet/set.rs @@ -0,0 +1,307 @@ +// 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`. + +//! Updates a subnet. +//! +//! Some attributes, such as IP version (ip_version), CIDR (cidr), and segment +//! (segment_id) cannot be updated. Attempting to update these attributes +//! results in a `400 Bad Request` error. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationPools<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) end: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) start: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct HostRoutes<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) destination: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) nexthop: Option>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Subnet<'a> { + /// Allocation pools with `start` and `end` IP addresses for this subnet. + /// If allocation_pools are not specified, OpenStack Networking + /// automatically allocates pools for covering all IP addresses in the + /// CIDR, excluding the address reserved for the subnet gateway by default. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allocation_pools: Option>>, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// List of dns name servers associated with the subnet. Default is an + /// empty list. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_nameservers: Option>>, + + /// Whether to publish DNS records for IPs from this subnet. Default is + /// `false`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dns_publish_fixed_ip: Option, + + /// Indicates whether dhcp is enabled or disabled for the subnet. Default + /// is `true`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) enable_dhcp: Option, + + /// Gateway IP of this subnet. If the value is `null` that implies no + /// gateway is associated with the subnet. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) gateway_ip: Option>>, + + /// Additional routes for the subnet. A list of dictionaries with + /// `destination` and `nexthop` parameters. Default value is an empty list. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host_routes: Option>>, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of a network segment the subnet is associated with. It is + /// available when `segment` extension is enabled. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) segment_id: Option>>, + + /// The service types associated with the subnet. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) service_types: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) subnet: Subnet<'a>, + + /// subnet_id parameter for /v2.0/subnets/{subnet_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<'a> RequestBuilder<'a> { + /// Add a single header to the Subnet. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("subnets/{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("subnet", serde_json::to_value(&self.subnet)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnet".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .subnet(SubnetBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .subnet(SubnetBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "subnet" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/subnets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnet": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnet(SubnetBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/subnets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnet": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnet(SubnetBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/subnet/tag.rs b/sdk/network/src/v2/subnet/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/subnet/tag.rs rename to sdk/network/src/v2/subnet/tag.rs diff --git a/sdk/network/src/v2/subnet/tag/delete.rs b/sdk/network/src/v2/subnet/tag/delete.rs new file mode 100644 index 000000000..16a2b820b --- /dev/null +++ b/sdk/network/src/v2/subnet/tag/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + subnet_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnets/{subnet_id}/tags/{id}", + id = self.id.as_ref(), + subnet_id = self.subnet_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/subnets/{subnet_id}/tags/{id}", + id = "id", + subnet_id = "subnet_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnet_id("subnet_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/subnets/{subnet_id}/tags/{id}", + id = "id", + subnet_id = "subnet_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") + .subnet_id("subnet_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/tag/delete_all.rs b/sdk/network/src/v2/subnet/tag/delete_all.rs new file mode 100644 index 000000000..de899be7c --- /dev/null +++ b/sdk/network/src/v2/subnet/tag/delete_all.rs @@ -0,0 +1,188 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + subnet_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnets/{subnet_id}/tags", + subnet_id = self.subnet_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/subnets/{subnet_id}/tags", + subnet_id = "subnet_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().subnet_id("subnet_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/subnets/{subnet_id}/tags", + subnet_id = "subnet_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() + .subnet_id("subnet_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/tag/get.rs b/sdk/network/src/v2/subnet/tag/get.rs new file mode 100644 index 000000000..a5457ae14 --- /dev/null +++ b/sdk/network/src/v2/subnet/tag/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + subnet_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnets/{subnet_id}/tags/{id}", + id = self.id.as_ref(), + subnet_id = self.subnet_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/subnets/{subnet_id}/tags/{id}", + id = "id", + subnet_id = "subnet_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnet_id("subnet_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/subnets/{subnet_id}/tags/{id}", + id = "id", + subnet_id = "subnet_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") + .subnet_id("subnet_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/tag/list.rs b/sdk/network/src/v2/subnet/tag/list.rs new file mode 100644 index 000000000..0539d1b29 --- /dev/null +++ b/sdk/network/src/v2/subnet/tag/list.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + subnet_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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnets/{subnet_id}/tags", + subnet_id = self.subnet_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/subnets/{subnet_id}/tags", + subnet_id = "subnet_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().subnet_id("subnet_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/subnets/{subnet_id}/tags", + subnet_id = "subnet_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .subnet_id("subnet_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/tag/replace.rs b/sdk/network/src/v2/subnet/tag/replace.rs new file mode 100644 index 000000000..62c1426a6 --- /dev/null +++ b/sdk/network/src/v2/subnet/tag/replace.rs @@ -0,0 +1,216 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + subnet_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "subnets/{subnet_id}/tags", + subnet_id = self.subnet_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/subnets/{subnet_id}/tags", + subnet_id = "subnet_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .subnet_id("subnet_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/subnets/{subnet_id}/tags", + subnet_id = "subnet_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .subnet_id("subnet_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnet/tag/set.rs b/sdk/network/src/v2/subnet/tag/set.rs new file mode 100644 index 000000000..b5e7b06b1 --- /dev/null +++ b/sdk/network/src/v2/subnet/tag/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// subnet_id parameter for /v2.0/subnets/{subnet_id}/tags/{id} API + #[builder(default, setter(into))] + subnet_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "subnets/{subnet_id}/tags/{id}", + id = self.id.as_ref(), + subnet_id = self.subnet_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/subnets/{subnet_id}/tags/{id}", + id = "id", + subnet_id = "subnet_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnet_id("subnet_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/subnets/{subnet_id}/tags/{id}", + id = "id", + subnet_id = "subnet_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") + .subnet_id("subnet_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/subnetpool.rs b/sdk/network/src/v2/subnetpool.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/subnetpool.rs rename to sdk/network/src/v2/subnetpool.rs diff --git a/openstack_sdk/src/api/network/v2/subnetpool/add_prefixes.rs b/sdk/network/src/v2/subnetpool/add_prefixes.rs similarity index 98% rename from openstack_sdk/src/api/network/v2/subnetpool/add_prefixes.rs rename to sdk/network/src/v2/subnetpool/add_prefixes.rs index 313357447..949734ccc 100644 --- a/openstack_sdk/src/api/network/v2/subnetpool/add_prefixes.rs +++ b/sdk/network/src/v2/subnetpool/add_prefixes.rs @@ -142,7 +142,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/network/src/v2/subnetpool/create.rs b/sdk/network/src/v2/subnetpool/create.rs new file mode 100644 index 000000000..a821138f2 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/create.rs @@ -0,0 +1,285 @@ +// 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`. + +//! Creates a subnet pool. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `subnetpool` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Subnetpool<'a> { + /// An address scope to assign to the subnet pool. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) address_scope_id: Option>>, + + /// The size of the prefix to allocate when the `cidr` or `prefixlen` + /// attributes are omitted when you create the subnet. Default is + /// `min_prefixlen`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_prefixlen: Option, + + /// A per-project quota on the prefix space that can be allocated from the + /// subnet pool for project subnets. Default is no quota is enforced on + /// allocations from the subnet pool. For IPv4 subnet pools, + /// `default_quota` is measured in units of /32. For IPv6 subnet pools, + /// `default_quota` is measured units of /64. All projects that use the + /// subnet pool have the same prefix quota applied. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_quota: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The subnetpool is default pool or not. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_default: Option, + + /// The maximum prefix size that can be allocated from the subnet pool. For + /// IPv4 subnet pools, default is `32`. For IPv6 subnet pools, default is + /// `128`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_prefixlen: Option, + + /// The smallest prefix that can be allocated from a subnet pool. For IPv4 + /// subnet pools, default is `8`. For IPv6 subnet pools, default is `64`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_prefixlen: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of subnet prefixes to assign to the subnet pool. The API merges + /// adjacent prefixes and treats them as a single prefix. Each subnet + /// prefix must be unique among all subnet prefixes in all subnet pools + /// that are associated with the address scope. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) prefixes: Option>>, + + /// Indicates whether this resource is shared across all projects. By + /// default, only administrative users can change this value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) shared: Option, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `subnetpool` object. + #[builder(setter(into))] + pub(crate) subnetpool: Subnetpool<'a>, + + #[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 Subnetpool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "subnetpools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("subnetpool", serde_json::to_value(&self.subnetpool)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnetpool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "subnetpool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/subnetpools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpool": {} })); + }); + + let endpoint = Request::builder() + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/subnetpools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpool": {} })); + }); + + let endpoint = Request::builder() + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/delete.rs b/sdk/network/src/v2/subnetpool/delete.rs new file mode 100644 index 000000000..2f7b9bac1 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/delete.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Deletes a subnet pool. +//! +//! The operation fails if any subnets allocated from the subnet pool are still +//! in use. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnetpools/{id}/remove_prefixes 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<'a> RequestBuilder<'a> { + /// Add a single header to the Subnetpool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("subnetpools/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/subnetpools/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/subnetpools/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/find.rs b/sdk/network/src/v2/subnetpool/find.rs new file mode 100644 index 000000000..7d82378ef --- /dev/null +++ b/sdk/network/src/v2/subnetpool/find.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`. +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; + +use crate::v2::subnetpool::{get as Get, list as List}; + +/// Find for subnetpool 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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.name(self.id.clone()); + ep.build().map_err(ApiError::endpoint_builder) + } +} diff --git a/sdk/network/src/v2/subnetpool/get.rs b/sdk/network/src/v2/subnetpool/get.rs new file mode 100644 index 000000000..fdbd0a512 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows information for a subnet pool. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnetpools/{id}/remove_prefixes 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<'a> RequestBuilder<'a> { + /// Add a single header to the Subnetpool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("subnetpools/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnetpool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "subnetpool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/subnetpools/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpool": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/subnetpools/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/list.rs b/sdk/network/src/v2/subnetpool/list.rs new file mode 100644 index 000000000..c00de74d0 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/list.rs @@ -0,0 +1,406 @@ +// 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`. + +//! Lists subnet pools that the project has access to. +//! +//! Default policy settings return only the subnet pools owned by the project +//! of the user submitting the request, unless the user has administrative +//! role. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use openstack_sdk_core::api::common::CommaSeparatedList; +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// address_scope_id query parameter for /v2.0/subnetpools API + #[builder(default, setter(into))] + address_scope_id: Option>, + + /// default_prefixlen query parameter for /v2.0/subnetpools API + #[builder(default)] + default_prefixlen: Option, + + /// default_quota query parameter for /v2.0/subnetpools API + #[builder(default)] + default_quota: Option, + + /// description query parameter for /v2.0/subnetpools API + #[builder(default, setter(into))] + description: Option>, + + /// id query parameter for /v2.0/subnetpools API + #[builder(default, setter(into))] + id: Option>, + + /// ip_version query parameter for /v2.0/subnetpools API + #[builder(default, setter(into))] + ip_version: Option>, + + /// is_default query parameter for /v2.0/subnetpools API + #[builder(default)] + is_default: Option, + + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// max_prefixlen query parameter for /v2.0/subnetpools API + #[builder(default)] + max_prefixlen: Option, + + /// min_prefixlen query parameter for /v2.0/subnetpools API + #[builder(default)] + min_prefixlen: Option, + + /// name query parameter for /v2.0/subnetpools API + #[builder(default, setter(into))] + name: Option>, + + /// not-tags query parameter for /v2.0/subnetpools API + #[builder(default, private, setter(name = "_not_tags"))] + not_tags: Option>>, + + /// not-tags-any query parameter for /v2.0/subnetpools API + #[builder(default, private, setter(name = "_not_tags_any"))] + not_tags_any: Option>>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// revision_number query parameter for /v2.0/subnetpools API + #[builder(default, setter(into))] + revision_number: Option>, + + /// shared query parameter for /v2.0/subnetpools API + #[builder(default)] + shared: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// tags query parameter for /v2.0/subnetpools API + #[builder(default, private, setter(name = "_tags"))] + tags: Option>>, + + /// tags-any query parameter for /v2.0/subnetpools API + #[builder(default, private, setter(name = "_tags_any"))] + tags_any: Option>>, + + /// tenant_id query parameter for /v2.0/subnetpools API + #[builder(default, setter(into))] + tenant_id: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags query parameter for /v2.0/subnetpools API + pub fn not_tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// not-tags-any query parameter for /v2.0/subnetpools API + pub fn not_tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.not_tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags query parameter for /v2.0/subnetpools API + pub fn tags(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// tags-any query parameter for /v2.0/subnetpools API + pub fn tags_any(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.tags_any + .get_or_insert(None) + .get_or_insert_with(CommaSeparatedList::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Subnetpool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "subnetpools".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + params.push_opt("address_scope_id", self.address_scope_id.as_ref()); + params.push_opt("default_prefixlen", self.default_prefixlen); + params.push_opt("default_quota", self.default_quota); + params.push_opt("description", self.description.as_ref()); + params.push_opt("id", self.id.as_ref()); + params.push_opt("ip_version", self.ip_version.as_ref()); + params.push_opt("is_default", self.is_default); + params.push_opt("max_prefixlen", self.max_prefixlen); + params.push_opt("min_prefixlen", self.min_prefixlen); + params.push_opt("name", self.name.as_ref()); + params.push_opt("not-tags", self.not_tags.as_ref()); + params.push_opt("not-tags-any", self.not_tags_any.as_ref()); + params.push_opt("revision_number", self.revision_number.as_ref()); + params.push_opt("shared", self.shared); + params.push_opt("tags", self.tags.as_ref()); + params.push_opt("tags-any", self.tags_any.as_ref()); + params.push_opt("tenant_id", self.tenant_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnetpools".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "subnetpools" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/subnetpools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpools": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/subnetpools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpools": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/onboard_network_subnet.rs b/sdk/network/src/v2/subnetpool/onboard_network_subnet.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/subnetpool/onboard_network_subnet.rs rename to sdk/network/src/v2/subnetpool/onboard_network_subnet.rs diff --git a/openstack_sdk/src/api/network/v2/subnetpool/onboard_network_subnet/onboard_network_subnets.rs b/sdk/network/src/v2/subnetpool/onboard_network_subnet/onboard_network_subnets.rs similarity index 99% rename from openstack_sdk/src/api/network/v2/subnetpool/onboard_network_subnet/onboard_network_subnets.rs rename to sdk/network/src/v2/subnetpool/onboard_network_subnet/onboard_network_subnets.rs index f120a5407..04dd11f20 100644 --- a/openstack_sdk/src/api/network/v2/subnetpool/onboard_network_subnet/onboard_network_subnets.rs +++ b/sdk/network/src/v2/subnetpool/onboard_network_subnet/onboard_network_subnets.rs @@ -146,7 +146,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/network/v2/subnetpool/remove_prefixes.rs b/sdk/network/src/v2/subnetpool/remove_prefixes.rs similarity index 98% rename from openstack_sdk/src/api/network/v2/subnetpool/remove_prefixes.rs rename to sdk/network/src/v2/subnetpool/remove_prefixes.rs index 8c7c8be80..205a9c09d 100644 --- a/openstack_sdk/src/api/network/v2/subnetpool/remove_prefixes.rs +++ b/sdk/network/src/v2/subnetpool/remove_prefixes.rs @@ -142,7 +142,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/network/src/v2/subnetpool/set.rs b/sdk/network/src/v2/subnetpool/set.rs new file mode 100644 index 000000000..d86161b82 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/set.rs @@ -0,0 +1,280 @@ +// 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`. + +//! Updates a subnet pool. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 403, 404, 412 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `subnetpool` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Subnetpool<'a> { + /// An address scope to assign to the subnet pool. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) address_scope_id: Option>>, + + /// The size of the prefix to allocate when the `cidr` or `prefixlen` + /// attributes are omitted when you create the subnet. Default is + /// `min_prefixlen`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_prefixlen: Option, + + /// A per-project quota on the prefix space that can be allocated from the + /// subnet pool for project subnets. Default is no quota is enforced on + /// allocations from the subnet pool. For IPv4 subnet pools, + /// `default_quota` is measured in units of /32. For IPv6 subnet pools, + /// `default_quota` is measured units of /64. All projects that use the + /// subnet pool have the same prefix quota applied. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) default_quota: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The subnetpool is default pool or not. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) is_default: Option, + + /// The maximum prefix size that can be allocated from the subnet pool. For + /// IPv4 subnet pools, default is `32`. For IPv6 subnet pools, default is + /// `128`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_prefixlen: Option, + + /// The smallest prefix that can be allocated from a subnet pool. For IPv4 + /// subnet pools, default is `8`. For IPv6 subnet pools, default is `64`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_prefixlen: Option, + + /// Human-readable name of the resource. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// A list of subnet prefixes to assign to the subnet pool. The API merges + /// adjacent prefixes and treats them as a single prefix. Each subnet + /// prefix must be unique among all subnet prefixes in all subnet pools + /// that are associated with the address scope. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) prefixes: Option>>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `subnetpool` object. + #[builder(setter(into))] + pub(crate) subnetpool: Subnetpool<'a>, + + /// id parameter for /v2.0/subnetpools/{id}/remove_prefixes 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<'a> RequestBuilder<'a> { + /// Add a single header to the Subnetpool. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("subnetpools/{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("subnetpool", serde_json::to_value(&self.subnetpool)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("subnetpool".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "subnetpool" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/subnetpools/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/subnetpools/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "subnetpool": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnetpool(SubnetpoolBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/subnetpool/tag.rs b/sdk/network/src/v2/subnetpool/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/subnetpool/tag.rs rename to sdk/network/src/v2/subnetpool/tag.rs diff --git a/sdk/network/src/v2/subnetpool/tag/delete.rs b/sdk/network/src/v2/subnetpool/tag/delete.rs new file mode 100644 index 000000000..e8e789160 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/tag/delete.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} + /// API + #[builder(default, setter(into))] + subnetpool_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnetpools/{subnetpool_id}/tags/{id}", + id = self.id.as_ref(), + subnetpool_id = self.subnetpool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/subnetpools/{subnetpool_id}/tags/{id}", + id = "id", + subnetpool_id = "subnetpool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnetpool_id("subnetpool_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/subnetpools/{subnetpool_id}/tags/{id}", + id = "id", + subnetpool_id = "subnetpool_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") + .subnetpool_id("subnetpool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/tag/delete_all.rs b/sdk/network/src/v2/subnetpool/tag/delete_all.rs new file mode 100644 index 000000000..788b82771 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/tag/delete_all.rs @@ -0,0 +1,192 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} + /// API + #[builder(default, setter(into))] + subnetpool_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnetpools/{subnetpool_id}/tags", + subnetpool_id = self.subnetpool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/subnetpools/{subnetpool_id}/tags", + subnetpool_id = "subnetpool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .subnetpool_id("subnetpool_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/subnetpools/{subnetpool_id}/tags", + subnetpool_id = "subnetpool_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() + .subnetpool_id("subnetpool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/tag/get.rs b/sdk/network/src/v2/subnetpool/tag/get.rs new file mode 100644 index 000000000..6666c9f6a --- /dev/null +++ b/sdk/network/src/v2/subnetpool/tag/get.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} + /// API + #[builder(default, setter(into))] + subnetpool_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnetpools/{subnetpool_id}/tags/{id}", + id = self.id.as_ref(), + subnetpool_id = self.subnetpool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/subnetpools/{subnetpool_id}/tags/{id}", + id = "id", + subnetpool_id = "subnetpool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnetpool_id("subnetpool_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/subnetpools/{subnetpool_id}/tags/{id}", + id = "id", + subnetpool_id = "subnetpool_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") + .subnetpool_id("subnetpool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/tag/list.rs b/sdk/network/src/v2/subnetpool/tag/list.rs new file mode 100644 index 000000000..3e282598c --- /dev/null +++ b/sdk/network/src/v2/subnetpool/tag/list.rs @@ -0,0 +1,263 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} + /// API + #[builder(default, setter(into))] + subnetpool_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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "subnetpools/{subnetpool_id}/tags", + subnetpool_id = self.subnetpool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/subnetpools/{subnetpool_id}/tags", + subnetpool_id = "subnetpool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .subnetpool_id("subnetpool_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/subnetpools/{subnetpool_id}/tags", + subnetpool_id = "subnetpool_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .subnetpool_id("subnetpool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/tag/replace.rs b/sdk/network/src/v2/subnetpool/tag/replace.rs new file mode 100644 index 000000000..167da00d5 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/tag/replace.rs @@ -0,0 +1,217 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} + /// API + #[builder(default, setter(into))] + subnetpool_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "subnetpools/{subnetpool_id}/tags", + subnetpool_id = self.subnetpool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/subnetpools/{subnetpool_id}/tags", + subnetpool_id = "subnetpool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .subnetpool_id("subnetpool_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/subnetpools/{subnetpool_id}/tags", + subnetpool_id = "subnetpool_id", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .subnetpool_id("subnetpool_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/subnetpool/tag/set.rs b/sdk/network/src/v2/subnetpool/tag/set.rs new file mode 100644 index 000000000..28e2cb412 --- /dev/null +++ b/sdk/network/src/v2/subnetpool/tag/set.rs @@ -0,0 +1,201 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// subnetpool_id parameter for /v2.0/subnetpools/{subnetpool_id}/tags/{id} + /// API + #[builder(default, setter(into))] + subnetpool_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "subnetpools/{subnetpool_id}/tags/{id}", + id = self.id.as_ref(), + subnetpool_id = self.subnetpool_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/subnetpools/{subnetpool_id}/tags/{id}", + id = "id", + subnetpool_id = "subnetpool_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .subnetpool_id("subnetpool_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/subnetpools/{subnetpool_id}/tags/{id}", + id = "id", + subnetpool_id = "subnetpool_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") + .subnetpool_id("subnetpool_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/trunk.rs b/sdk/network/src/v2/trunk.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/trunk.rs rename to sdk/network/src/v2/trunk.rs diff --git a/openstack_sdk/src/api/network/v2/trunk/tag.rs b/sdk/network/src/v2/trunk/tag.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/trunk/tag.rs rename to sdk/network/src/v2/trunk/tag.rs diff --git a/sdk/network/src/v2/trunk/tag/delete.rs b/sdk/network/src/v2/trunk/tag/delete.rs new file mode 100644 index 000000000..89de6b992 --- /dev/null +++ b/sdk/network/src/v2/trunk/tag/delete.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + trunk_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "trunks/{trunk_id}/tags/{id}", + id = self.id.as_ref(), + trunk_id = self.trunk_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/trunks/{trunk_id}/tags/{id}", + id = "id", + trunk_id = "trunk_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .trunk_id("trunk_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/trunks/{trunk_id}/tags/{id}", + id = "id", + trunk_id = "trunk_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") + .trunk_id("trunk_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/trunk/tag/delete_all.rs b/sdk/network/src/v2/trunk/tag/delete_all.rs new file mode 100644 index 000000000..56a739b6d --- /dev/null +++ b/sdk/network/src/v2/trunk/tag/delete_all.rs @@ -0,0 +1,179 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + trunk_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("trunks/{trunk_id}/tags", trunk_id = self.trunk_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().trunk_id("trunk_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_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() + .trunk_id("trunk_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/trunk/tag/get.rs b/sdk/network/src/v2/trunk/tag/get.rs new file mode 100644 index 000000000..07d61cb15 --- /dev/null +++ b/sdk/network/src/v2/trunk/tag/get.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + trunk_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "trunks/{trunk_id}/tags/{id}", + id = self.id.as_ref(), + trunk_id = self.trunk_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/trunks/{trunk_id}/tags/{id}", + id = "id", + trunk_id = "trunk_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .trunk_id("trunk_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/trunks/{trunk_id}/tags/{id}", + id = "id", + trunk_id = "trunk_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") + .trunk_id("trunk_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/trunk/tag/list.rs b/sdk/network/src/v2/trunk/tag/list.rs new file mode 100644 index 000000000..86bff0c70 --- /dev/null +++ b/sdk/network/src/v2/trunk/tag/list.rs @@ -0,0 +1,250 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: Option>>, + + /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + trunk_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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("trunks/{trunk_id}/tags", trunk_id = self.trunk_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder().trunk_id("trunk_id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .trunk_id("trunk_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/trunk/tag/replace.rs b/sdk/network/src/v2/trunk/tag/replace.rs new file mode 100644 index 000000000..d652642e4 --- /dev/null +++ b/sdk/network/src/v2/trunk/tag/replace.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`. + +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) tags: Vec>, + + /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + trunk_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("trunks/{trunk_id}/tags", trunk_id = self.trunk_id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("tags", serde_json::to_value(&self.tags)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("tags".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .tags(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "tags" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .trunk_id("trunk_id") + .tags(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/trunks/{trunk_id}/tags", trunk_id = "trunk_id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "tags": {} })); + }); + + let endpoint = Request::builder() + .trunk_id("trunk_id") + .tags(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/trunk/tag/set.rs b/sdk/network/src/v2/trunk/tag/set.rs new file mode 100644 index 000000000..07ea5bfad --- /dev/null +++ b/sdk/network/src/v2/trunk/tag/set.rs @@ -0,0 +1,200 @@ +// 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 openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + id: Cow<'a, str>, + + /// trunk_id parameter for /v2.0/trunks/{trunk_id}/tags/{id} API + #[builder(default, setter(into))] + trunk_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 Tag. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "trunks/{trunk_id}/tags/{id}", + id = self.id.as_ref(), + trunk_id = self.trunk_id.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/trunks/{trunk_id}/tags/{id}", + id = "id", + trunk_id = "trunk_id", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .trunk_id("trunk_id") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/trunks/{trunk_id}/tags/{id}", + id = "id", + trunk_id = "trunk_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") + .trunk_id("trunk_id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/vpn.rs b/sdk/network/src/v2/vpn.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/vpn.rs rename to sdk/network/src/v2/vpn.rs diff --git a/openstack_sdk/src/api/network/v2/vpn/endpoint_group.rs b/sdk/network/src/v2/vpn/endpoint_group.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/vpn/endpoint_group.rs rename to sdk/network/src/v2/vpn/endpoint_group.rs diff --git a/sdk/network/src/v2/vpn/endpoint_group/create.rs b/sdk/network/src/v2/vpn/endpoint_group/create.rs new file mode 100644 index 000000000..0c0534d6b --- /dev/null +++ b/sdk/network/src/v2/vpn/endpoint_group/create.rs @@ -0,0 +1,262 @@ +// 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`. + +//! Creates a VPN endpoint group. +//! +//! The endpoint group contains one or more endpoints of a specific type that +//! you can use to create a VPN connections. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Type { + #[serde(rename = "cidr")] + Cidr, + #[serde(rename = "network")] + Network, + #[serde(rename = "router")] + Router, + #[serde(rename = "subnet")] + Subnet, + #[serde(rename = "vlan")] + Vlan, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct EndpointGroup<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// List of endpoints of the same type, for the endpoint group. The values + /// will depend on type. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) endpoints: Option>>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The type of the endpoints in the group. A valid value is `subnet`, + /// `cidr`, `network`, `router`, or `vlan`. Only `subnet` and `cidr` are + /// supported at this moment. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) _type: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) endpoint_group: EndpointGroup<'a>, + + #[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 Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/endpoint-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "endpoint_group", + serde_json::to_value(&self.endpoint_group)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("endpoint_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "endpoint_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/endpoint-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/endpoint-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/endpoint_group/delete.rs b/sdk/network/src/v2/vpn/endpoint_group/delete.rs new file mode 100644 index 000000000..5e5acde46 --- /dev/null +++ b/sdk/network/src/v2/vpn/endpoint_group/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Removes a VPN endpoint group. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/endpoint-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/endpoint-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/endpoint-groups/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/endpoint-groups/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/endpoint_group/find.rs b/sdk/network/src/v2/vpn/endpoint_group/find.rs new file mode 100644 index 000000000..97dcc3915 --- /dev/null +++ b/sdk/network/src/v2/vpn/endpoint_group/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::vpn::endpoint_group::{get as Get, list as List}; + +/// Find for vpn/endpoint_group 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate vpn/endpoint_group in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // vpn/endpoint_group 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/network/src/v2/vpn/endpoint_group/get.rs b/sdk/network/src/v2/vpn/endpoint_group/get.rs new file mode 100644 index 000000000..dc8816ca4 --- /dev/null +++ b/sdk/network/src/v2/vpn/endpoint_group/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for a VPN endpoint group. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/endpoint-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/endpoint-groups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("endpoint_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "endpoint_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/endpoint-groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/endpoint-groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/endpoint_group/list.rs b/sdk/network/src/v2/vpn/endpoint_group/list.rs new file mode 100644 index 000000000..23954adc4 --- /dev/null +++ b/sdk/network/src/v2/vpn/endpoint_group/list.rs @@ -0,0 +1,264 @@ +// 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`. + +//! Lists VPN endpoint groups. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/endpoint-groups".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("endpoint_groups".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "endpoint_groups" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/endpoint-groups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_groups": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/endpoint-groups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_groups": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/endpoint_group/set.rs b/sdk/network/src/v2/vpn/endpoint_group/set.rs new file mode 100644 index 000000000..c94a712e7 --- /dev/null +++ b/sdk/network/src/v2/vpn/endpoint_group/set.rs @@ -0,0 +1,233 @@ +// 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`. + +//! Updates settings for a VPN endpoint group. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct EndpointGroup<'a> { + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) endpoint_group: EndpointGroup<'a>, + + /// id parameter for /v2.0/vpn/endpoint-groups/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Endpoint_Group. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("vpn/endpoint-groups/{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( + "endpoint_group", + serde_json::to_value(&self.endpoint_group)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("endpoint_group".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "endpoint_group" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/endpoint-groups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/endpoint-groups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "endpoint_group": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .endpoint_group(EndpointGroupBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/vpn/ikepolicy.rs b/sdk/network/src/v2/vpn/ikepolicy.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/vpn/ikepolicy.rs rename to sdk/network/src/v2/vpn/ikepolicy.rs diff --git a/sdk/network/src/v2/vpn/ikepolicy/create.rs b/sdk/network/src/v2/vpn/ikepolicy/create.rs new file mode 100644 index 000000000..a08c76fb6 --- /dev/null +++ b/sdk/network/src/v2/vpn/ikepolicy/create.rs @@ -0,0 +1,404 @@ +// 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`. + +//! Creates an IKE policy. +//! +//! The IKE policy is used for phases one and two negotiation of the VPN +//! connection. You can specify both the authentication and encryption +//! algorithms for connections. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum AuthAlgorithm { + #[serde(rename = "aes-cmac")] + AesCmac, + #[serde(rename = "aes-xcbc")] + AesXcbc, + #[serde(rename = "sha1")] + Sha1, + #[serde(rename = "sha256")] + Sha256, + #[serde(rename = "sha384")] + Sha384, + #[serde(rename = "sha512")] + Sha512, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum EncryptionAlgorithm { + #[serde(rename = "3des")] + _3des, + #[serde(rename = "aes-128")] + Aes128, + #[serde(rename = "aes-128-ccm-12")] + Aes128Ccm12, + #[serde(rename = "aes-128-ccm-16")] + Aes128Ccm16, + #[serde(rename = "aes-128-ccm-8")] + Aes128Ccm8, + #[serde(rename = "aes-128-ctr")] + Aes128Ctr, + #[serde(rename = "aes-128-gcm-12")] + Aes128Gcm12, + #[serde(rename = "aes-128-gcm-16")] + Aes128Gcm16, + #[serde(rename = "aes-128-gcm-8")] + Aes128Gcm8, + #[serde(rename = "aes-192")] + Aes192, + #[serde(rename = "aes-192-ccm-12")] + Aes192Ccm12, + #[serde(rename = "aes-192-ccm-16")] + Aes192Ccm16, + #[serde(rename = "aes-192-ccm-8")] + Aes192Ccm8, + #[serde(rename = "aes-192-ctr")] + Aes192Ctr, + #[serde(rename = "aes-192-gcm-12")] + Aes192Gcm12, + #[serde(rename = "aes-192-gcm-16")] + Aes192Gcm16, + #[serde(rename = "aes-192-gcm-8")] + Aes192Gcm8, + #[serde(rename = "aes-256")] + Aes256, + #[serde(rename = "aes-256-ccm-12")] + Aes256Ccm12, + #[serde(rename = "aes-256-ccm-16")] + Aes256Ccm16, + #[serde(rename = "aes-256-ccm-8")] + Aes256Ccm8, + #[serde(rename = "aes-256-ctr")] + Aes256Ctr, + #[serde(rename = "aes-256-gcm-12")] + Aes256Gcm12, + #[serde(rename = "aes-256-gcm-16")] + Aes256Gcm16, + #[serde(rename = "aes-256-gcm-8")] + Aes256Gcm8, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum IkeVersion { + #[serde(rename = "v1")] + V1, + #[serde(rename = "v2")] + V2, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Pfs { + #[serde(rename = "group14")] + Group14, + #[serde(rename = "group15")] + Group15, + #[serde(rename = "group16")] + Group16, + #[serde(rename = "group17")] + Group17, + #[serde(rename = "group18")] + Group18, + #[serde(rename = "group19")] + Group19, + #[serde(rename = "group2")] + Group2, + #[serde(rename = "group20")] + Group20, + #[serde(rename = "group21")] + Group21, + #[serde(rename = "group22")] + Group22, + #[serde(rename = "group23")] + Group23, + #[serde(rename = "group24")] + Group24, + #[serde(rename = "group25")] + Group25, + #[serde(rename = "group26")] + Group26, + #[serde(rename = "group27")] + Group27, + #[serde(rename = "group28")] + Group28, + #[serde(rename = "group29")] + Group29, + #[serde(rename = "group30")] + Group30, + #[serde(rename = "group31")] + Group31, + #[serde(rename = "group5")] + Group5, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Phase1NegotiationMode { + #[serde(rename = "aggressive")] + Aggressive, + #[serde(rename = "main")] + Main, +} + +/// An `ikepolicy` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Ikepolicy<'a> { + /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, + /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) auth_algorithm: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The encryption algorithm. A valid value is `3des`, `aes-128`, + /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. + /// Additional values for AES CCM and GCM modes are defined (e.g. + /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length + /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is + /// `aes-128`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) encryption_algorithm: Option, + + /// The IKE version. A valid value is `v1` or `v2`. Default is `v1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) ike_version: Option, + + /// The lifetime of the security association. The lifetime consists of a + /// unit and integer value. You can omit either the unit or value portion + /// of the lifetime. Default unit is seconds and default value is 3600. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) lifetime: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, + /// `Group14` to `Group31`. Default is `Group5`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) pfs: Option, + + /// The IKE mode. A valid value is `main`, which is the default. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) phase1_negotiation_mode: Option, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `ikepolicy` object. + #[builder(setter(into))] + pub(crate) ikepolicy: Ikepolicy<'a>, + + #[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 Ikepolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/ikepolicies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("ikepolicy", serde_json::to_value(&self.ikepolicy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ikepolicy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ikepolicy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/ikepolicies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicy": {} })); + }); + + let endpoint = Request::builder() + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/ikepolicies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicy": {} })); + }); + + let endpoint = Request::builder() + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ikepolicy/delete.rs b/sdk/network/src/v2/vpn/ikepolicy/delete.rs new file mode 100644 index 000000000..dfb196c15 --- /dev/null +++ b/sdk/network/src/v2/vpn/ikepolicy/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Removes an IKE policy. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/ikepolicies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ikepolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/ikepolicies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/ikepolicies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/ikepolicies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ikepolicy/find.rs b/sdk/network/src/v2/vpn/ikepolicy/find.rs new file mode 100644 index 000000000..31736d80d --- /dev/null +++ b/sdk/network/src/v2/vpn/ikepolicy/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::vpn::ikepolicy::{get as Get, list as List}; + +/// Find for vpn/ikepolicy 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate vpn/ikepolicy in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // vpn/ikepolicy 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/network/src/v2/vpn/ikepolicy/get.rs b/sdk/network/src/v2/vpn/ikepolicy/get.rs new file mode 100644 index 000000000..9fc5e744d --- /dev/null +++ b/sdk/network/src/v2/vpn/ikepolicy/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for an IKE policy. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/ikepolicies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ikepolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/ikepolicies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ikepolicy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ikepolicy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/ikepolicies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicy": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/ikepolicies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ikepolicy/list.rs b/sdk/network/src/v2/vpn/ikepolicy/list.rs new file mode 100644 index 000000000..36d25dae9 --- /dev/null +++ b/sdk/network/src/v2/vpn/ikepolicy/list.rs @@ -0,0 +1,264 @@ +// 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`. + +//! Lists IKE policies. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Ikepolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/ikepolicies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ikepolicies".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ikepolicies" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/ikepolicies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicies": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/ikepolicies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicies": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ikepolicy/set.rs b/sdk/network/src/v2/vpn/ikepolicy/set.rs new file mode 100644 index 000000000..25cf1eeb4 --- /dev/null +++ b/sdk/network/src/v2/vpn/ikepolicy/set.rs @@ -0,0 +1,401 @@ +// 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`. + +//! Updates policy settings in an IKE policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum AuthAlgorithm { + #[serde(rename = "aes-cmac")] + AesCmac, + #[serde(rename = "aes-xcbc")] + AesXcbc, + #[serde(rename = "sha1")] + Sha1, + #[serde(rename = "sha256")] + Sha256, + #[serde(rename = "sha384")] + Sha384, + #[serde(rename = "sha512")] + Sha512, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum EncryptionAlgorithm { + #[serde(rename = "3des")] + _3des, + #[serde(rename = "aes-128")] + Aes128, + #[serde(rename = "aes-128-ccm-12")] + Aes128Ccm12, + #[serde(rename = "aes-128-ccm-16")] + Aes128Ccm16, + #[serde(rename = "aes-128-ccm-8")] + Aes128Ccm8, + #[serde(rename = "aes-128-ctr")] + Aes128Ctr, + #[serde(rename = "aes-128-gcm-12")] + Aes128Gcm12, + #[serde(rename = "aes-128-gcm-16")] + Aes128Gcm16, + #[serde(rename = "aes-128-gcm-8")] + Aes128Gcm8, + #[serde(rename = "aes-192")] + Aes192, + #[serde(rename = "aes-192-ccm-12")] + Aes192Ccm12, + #[serde(rename = "aes-192-ccm-16")] + Aes192Ccm16, + #[serde(rename = "aes-192-ccm-8")] + Aes192Ccm8, + #[serde(rename = "aes-192-ctr")] + Aes192Ctr, + #[serde(rename = "aes-192-gcm-12")] + Aes192Gcm12, + #[serde(rename = "aes-192-gcm-16")] + Aes192Gcm16, + #[serde(rename = "aes-192-gcm-8")] + Aes192Gcm8, + #[serde(rename = "aes-256")] + Aes256, + #[serde(rename = "aes-256-ccm-12")] + Aes256Ccm12, + #[serde(rename = "aes-256-ccm-16")] + Aes256Ccm16, + #[serde(rename = "aes-256-ccm-8")] + Aes256Ccm8, + #[serde(rename = "aes-256-ctr")] + Aes256Ctr, + #[serde(rename = "aes-256-gcm-12")] + Aes256Gcm12, + #[serde(rename = "aes-256-gcm-16")] + Aes256Gcm16, + #[serde(rename = "aes-256-gcm-8")] + Aes256Gcm8, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum IkeVersion { + #[serde(rename = "v1")] + V1, + #[serde(rename = "v2")] + V2, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Pfs { + #[serde(rename = "group14")] + Group14, + #[serde(rename = "group15")] + Group15, + #[serde(rename = "group16")] + Group16, + #[serde(rename = "group17")] + Group17, + #[serde(rename = "group18")] + Group18, + #[serde(rename = "group19")] + Group19, + #[serde(rename = "group2")] + Group2, + #[serde(rename = "group20")] + Group20, + #[serde(rename = "group21")] + Group21, + #[serde(rename = "group22")] + Group22, + #[serde(rename = "group23")] + Group23, + #[serde(rename = "group24")] + Group24, + #[serde(rename = "group25")] + Group25, + #[serde(rename = "group26")] + Group26, + #[serde(rename = "group27")] + Group27, + #[serde(rename = "group28")] + Group28, + #[serde(rename = "group29")] + Group29, + #[serde(rename = "group30")] + Group30, + #[serde(rename = "group31")] + Group31, + #[serde(rename = "group5")] + Group5, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Phase1NegotiationMode { + #[serde(rename = "aggressive")] + Aggressive, + #[serde(rename = "main")] + Main, +} + +/// An `ikepolicy` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Ikepolicy<'a> { + /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, + /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) auth_algorithm: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The encryption algorithm. A valid value is `3des`, `aes-128`, + /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. + /// Additional values for AES CCM and GCM modes are defined (e.g. + /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length + /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is + /// `aes-128`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) encryption_algorithm: Option, + + /// The IKE version. A valid value is `v1` or `v2`. Default is `v1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) ike_version: Option, + + /// The lifetime of the security association. The lifetime consists of a + /// unit and integer value. You can omit either the unit or value portion + /// of the lifetime. Default unit is seconds and default value is 3600. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) lifetime: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, + /// `Group14` to `Group31`. Default is `Group5`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) pfs: Option, + + /// The IKE mode. A valid value is `main`, which is the default. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) phase1_negotiation_mode: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `ikepolicy` object. + #[builder(setter(into))] + pub(crate) ikepolicy: Ikepolicy<'a>, + + /// id parameter for /v2.0/vpn/ikepolicies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ikepolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("vpn/ikepolicies/{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("ikepolicy", serde_json::to_value(&self.ikepolicy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ikepolicy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ikepolicy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/ikepolicies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/ikepolicies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ikepolicy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ikepolicy(IkepolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection.rs b/sdk/network/src/v2/vpn/ipsec_site_connection.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/vpn/ipsec_site_connection.rs rename to sdk/network/src/v2/vpn/ipsec_site_connection.rs diff --git a/sdk/network/src/v2/vpn/ipsec_site_connection/create.rs b/sdk/network/src/v2/vpn/ipsec_site_connection/create.rs new file mode 100644 index 000000000..3279ad2d4 --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsec_site_connection/create.rs @@ -0,0 +1,330 @@ +// 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`. + +//! Creates a site-to-site IPsec connection for a service. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Initiator { + #[serde(rename = "bi-directional")] + BiDirectional, + #[serde(rename = "response-only")] + ResponseOnly, +} + +/// An `ipsec_site_connection` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct IpsecSiteConnection<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// A dictionary with dead peer detection (DPD) protocol controls. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dpd: Option>, + + /// The ID of the IKE policy. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ikepolicy_id: Option>, + + /// Indicates whether this VPN can only respond to connections or both + /// respond to and initiate connections. A valid value is `response- only` + /// or `bi-directional`. Default is `bi-directional`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) initiator: Option, + + /// The ID of the IPsec policy. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) ipsecpolicy_id: Option>, + + /// The ID for the endpoint group that contains private subnets for the + /// local side of the connection. Yo must specify this parameter with the + /// `peer_ep_group_id` parameter unless in backward- compatible mode where + /// `peer_cidrs` is provided with a `subnet_id` for the VPN service. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) local_ep_group_id: Option>>, + + /// An ID to be used instead of the external IP address for a virtual + /// router used in traffic between instances on different networks in + /// east-west traffic. Most often, local ID would be domain name, email + /// address, etc. If this is not configured then the external IP address + /// will be used as the ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) local_id: Option>, + + /// The maximum transmission unit (MTU) value to address fragmentation. + /// Minimum value is 68 for IPv4, and 1280 for IPv6. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) mtu: Option, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The peer gateway public IPv4 or IPv6 address or FQDN. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_address: Option>, + + /// (Deprecated) Unique list of valid peer private CIDRs in the form \< + /// net_address > / < prefix > . + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_cidrs: Option>>, + + /// The ID for the endpoint group that contains private CIDRs in the form + /// \< net_address > / < prefix > for the peer side of the connection. You + /// must specify this parameter with the `local_ep_group_id` parameter + /// unless in backward-compatible mode where `peer_cidrs` is provided with + /// a `subnet_id` for the VPN service. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_ep_group_id: Option>>, + + /// The peer router identity for authentication. A valid value is an IPv4 + /// address, IPv6 address, e-mail address, key ID, or FQDN. Typically, this + /// value matches the `peer_address` value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_id: Option>, + + /// The pre-shared key. A valid value is any string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) psk: Option>, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The ID of the VPN service. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) vpnservice_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `ipsec_site_connection` object. + #[builder(setter(into))] + pub(crate) ipsec_site_connection: IpsecSiteConnection<'a>, + + #[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 Ipsec_Site_Connection. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/ipsec-site-connections".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "ipsec_site_connection", + serde_json::to_value(&self.ipsec_site_connection)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsec_site_connection".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ipsec_site_connection" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/ipsec-site-connections".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connection": {} })); + }); + + let endpoint = Request::builder() + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/ipsec-site-connections".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connection": {} })); + }); + + let endpoint = Request::builder() + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsec_site_connection/delete.rs b/sdk/network/src/v2/vpn/ipsec_site_connection/delete.rs new file mode 100644 index 000000000..b8107cea2 --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsec_site_connection/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Removes an IPsec connection. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/ipsec-site-connections/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ipsec_Site_Connection. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/ipsec-site-connections/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/ipsec-site-connections/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/ipsec-site-connections/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsec_site_connection/find.rs b/sdk/network/src/v2/vpn/ipsec_site_connection/find.rs new file mode 100644 index 000000000..b2da6e666 --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsec_site_connection/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::vpn::ipsec_site_connection::{get as Get, list as List}; + +/// Find for vpn/ipsec_site_connection 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate vpn/ipsec_site_connection in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // vpn/ipsec_site_connection 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/network/src/v2/vpn/ipsec_site_connection/get.rs b/sdk/network/src/v2/vpn/ipsec_site_connection/get.rs new file mode 100644 index 000000000..ed5b280ae --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsec_site_connection/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for an IPsec connection. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/ipsec-site-connections/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ipsec_Site_Connection. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/ipsec-site-connections/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsec_site_connection".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ipsec_site_connection" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connection": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connection": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsec_site_connection/list.rs b/sdk/network/src/v2/vpn/ipsec_site_connection/list.rs new file mode 100644 index 000000000..bc1c795db --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsec_site_connection/list.rs @@ -0,0 +1,264 @@ +// 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`. + +//! Lists all IPsec connections. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Ipsec_Site_Connection. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/ipsec-site-connections".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsec_site_connections".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ipsec_site_connections" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/ipsec-site-connections".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connections": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/ipsec-site-connections".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connections": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsec_site_connection/set.rs b/sdk/network/src/v2/vpn/ipsec_site_connection/set.rs new file mode 100644 index 000000000..ef7a93bb4 --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsec_site_connection/set.rs @@ -0,0 +1,316 @@ +// 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`. + +//! Updates connection settings for an IPsec connection. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Initiator { + #[serde(rename = "bi-directional")] + BiDirectional, + #[serde(rename = "response-only")] + ResponseOnly, +} + +/// An `ipsec_site_connection` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct IpsecSiteConnection<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// A dictionary with dead peer detection (DPD) protocol controls. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) dpd: Option>, + + /// Indicates whether this VPN can only respond to connections or both + /// respond to and initiate connections. A valid value is `response- only` + /// or `bi-directional`. Default is `bi-directional`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) initiator: Option, + + /// The ID for the endpoint group that contains private subnets for the + /// local side of the connection. Yo must specify this parameter with the + /// `peer_ep_group_id` parameter unless in backward- compatible mode where + /// `peer_cidrs` is provided with a `subnet_id` for the VPN service. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) local_ep_group_id: Option>>, + + /// An ID to be used instead of the external IP address for a virtual + /// router used in traffic between instances on different networks in + /// east-west traffic. Most often, local ID would be domain name, email + /// address, etc. If this is not configured then the external IP address + /// will be used as the ID. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) local_id: Option>, + + /// The maximum transmission unit (MTU) value to address fragmentation. + /// Minimum value is 68 for IPv4, and 1280 for IPv6. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) mtu: Option, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// The peer gateway public IPv4 or IPv6 address or FQDN. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_address: Option>, + + /// (Deprecated) Unique list of valid peer private CIDRs in the form \< + /// net_address > / < prefix > . + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_cidrs: Option>>, + + /// The ID for the endpoint group that contains private CIDRs in the form + /// \< net_address > / < prefix > for the peer side of the connection. You + /// must specify this parameter with the `local_ep_group_id` parameter + /// unless in backward-compatible mode where `peer_cidrs` is provided with + /// a `subnet_id` for the VPN service. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_ep_group_id: Option>>, + + /// The peer router identity for authentication. A valid value is an IPv4 + /// address, IPv6 address, e-mail address, key ID, or FQDN. Typically, this + /// value matches the `peer_address` value. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) peer_id: Option>, + + /// The pre-shared key. A valid value is any string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) psk: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `ipsec_site_connection` object. + #[builder(setter(into))] + pub(crate) ipsec_site_connection: IpsecSiteConnection<'a>, + + /// id parameter for /v2.0/vpn/ipsec-site-connections/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ipsec_Site_Connection. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("vpn/ipsec-site-connections/{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( + "ipsec_site_connection", + serde_json::to_value(&self.ipsec_site_connection)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsec_site_connection".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ipsec_site_connection" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connection": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/ipsec-site-connections/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsec_site_connection": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ipsec_site_connection(IpsecSiteConnectionBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/vpn/ipsecpolicy.rs b/sdk/network/src/v2/vpn/ipsecpolicy.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/vpn/ipsecpolicy.rs rename to sdk/network/src/v2/vpn/ipsecpolicy.rs diff --git a/sdk/network/src/v2/vpn/ipsecpolicy/create.rs b/sdk/network/src/v2/vpn/ipsecpolicy/create.rs new file mode 100644 index 000000000..d8b2e4adf --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsecpolicy/create.rs @@ -0,0 +1,407 @@ +// 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`. + +//! Creates an IP security (IPsec) policy. +//! +//! The IPsec policy specifies the authentication and encryption algorithms and +//! encapsulation mode to use for the established VPN connection. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum AuthAlgorithm { + #[serde(rename = "aes-cmac")] + AesCmac, + #[serde(rename = "aes-xcbc")] + AesXcbc, + #[serde(rename = "sha1")] + Sha1, + #[serde(rename = "sha256")] + Sha256, + #[serde(rename = "sha384")] + Sha384, + #[serde(rename = "sha512")] + Sha512, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum EncapsulationMode { + #[serde(rename = "transport")] + Transport, + #[serde(rename = "tunnel")] + Tunnel, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum EncryptionAlgorithm { + #[serde(rename = "3des")] + _3des, + #[serde(rename = "aes-128")] + Aes128, + #[serde(rename = "aes-128-ccm-12")] + Aes128Ccm12, + #[serde(rename = "aes-128-ccm-16")] + Aes128Ccm16, + #[serde(rename = "aes-128-ccm-8")] + Aes128Ccm8, + #[serde(rename = "aes-128-ctr")] + Aes128Ctr, + #[serde(rename = "aes-128-gcm-12")] + Aes128Gcm12, + #[serde(rename = "aes-128-gcm-16")] + Aes128Gcm16, + #[serde(rename = "aes-128-gcm-8")] + Aes128Gcm8, + #[serde(rename = "aes-192")] + Aes192, + #[serde(rename = "aes-192-ccm-12")] + Aes192Ccm12, + #[serde(rename = "aes-192-ccm-16")] + Aes192Ccm16, + #[serde(rename = "aes-192-ccm-8")] + Aes192Ccm8, + #[serde(rename = "aes-192-ctr")] + Aes192Ctr, + #[serde(rename = "aes-192-gcm-12")] + Aes192Gcm12, + #[serde(rename = "aes-192-gcm-16")] + Aes192Gcm16, + #[serde(rename = "aes-192-gcm-8")] + Aes192Gcm8, + #[serde(rename = "aes-256")] + Aes256, + #[serde(rename = "aes-256-ccm-12")] + Aes256Ccm12, + #[serde(rename = "aes-256-ccm-16")] + Aes256Ccm16, + #[serde(rename = "aes-256-ccm-8")] + Aes256Ccm8, + #[serde(rename = "aes-256-ctr")] + Aes256Ctr, + #[serde(rename = "aes-256-gcm-12")] + Aes256Gcm12, + #[serde(rename = "aes-256-gcm-16")] + Aes256Gcm16, + #[serde(rename = "aes-256-gcm-8")] + Aes256Gcm8, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Pfs { + #[serde(rename = "group14")] + Group14, + #[serde(rename = "group15")] + Group15, + #[serde(rename = "group16")] + Group16, + #[serde(rename = "group17")] + Group17, + #[serde(rename = "group18")] + Group18, + #[serde(rename = "group19")] + Group19, + #[serde(rename = "group2")] + Group2, + #[serde(rename = "group20")] + Group20, + #[serde(rename = "group21")] + Group21, + #[serde(rename = "group22")] + Group22, + #[serde(rename = "group23")] + Group23, + #[serde(rename = "group24")] + Group24, + #[serde(rename = "group25")] + Group25, + #[serde(rename = "group26")] + Group26, + #[serde(rename = "group27")] + Group27, + #[serde(rename = "group28")] + Group28, + #[serde(rename = "group29")] + Group29, + #[serde(rename = "group30")] + Group30, + #[serde(rename = "group31")] + Group31, + #[serde(rename = "group5")] + Group5, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum TransformProtocol { + #[serde(rename = "ah")] + Ah, + #[serde(rename = "ah-esp")] + AhEsp, + #[serde(rename = "esp")] + Esp, +} + +/// An `ipsecpolicy` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Ipsecpolicy<'a> { + /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, + /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) auth_algorithm: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The encapsulation mode. A valid value is `tunnel` or `transport`. + /// Default is `tunnel`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) encapsulation_mode: Option, + + /// The encryption algorithm. A valid value is `3des`, `aes-128`, + /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. + /// Additional values for AES CCM and GCM modes are defined (e.g. + /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length + /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is + /// `aes-128`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) encryption_algorithm: Option, + + /// The lifetime of the security association. The lifetime consists of a + /// unit and integer value. You can omit either the unit or value portion + /// of the lifetime. Default unit is seconds and default value is 3600. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) lifetime: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, + /// `Group14` to `Group31`. Default is `Group5`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) pfs: Option, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, + + /// The transform protocol. A valid value is `ESP`, `AH`, or `AH- ESP`. + /// Default is `ESP`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) transform_protocol: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `ipsecpolicy` object. + #[builder(setter(into))] + pub(crate) ipsecpolicy: Ipsecpolicy<'a>, + + #[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 Ipsecpolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/ipsecpolicies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("ipsecpolicy", serde_json::to_value(&self.ipsecpolicy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsecpolicy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ipsecpolicy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/ipsecpolicies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicy": {} })); + }); + + let endpoint = Request::builder() + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/ipsecpolicies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicy": {} })); + }); + + let endpoint = Request::builder() + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsecpolicy/delete.rs b/sdk/network/src/v2/vpn/ipsecpolicy/delete.rs new file mode 100644 index 000000000..094311159 --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsecpolicy/delete.rs @@ -0,0 +1,185 @@ +// 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`. + +//! Removes an IPsec policy. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/ipsecpolicies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ipsecpolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/ipsecpolicies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/ipsecpolicies/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/ipsecpolicies/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsecpolicy/find.rs b/sdk/network/src/v2/vpn/ipsecpolicy/find.rs new file mode 100644 index 000000000..f0b2463f3 --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsecpolicy/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::vpn::ipsecpolicy::{get as Get, list as List}; + +/// Find for vpn/ipsecpolicy 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate vpn/ipsecpolicy in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // vpn/ipsecpolicy 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/network/src/v2/vpn/ipsecpolicy/get.rs b/sdk/network/src/v2/vpn/ipsecpolicy/get.rs new file mode 100644 index 000000000..545ecee9b --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsecpolicy/get.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Shows details for an IPsec policy. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/ipsecpolicies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ipsecpolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/ipsecpolicies/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsecpolicy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ipsecpolicy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicy": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsecpolicy/list.rs b/sdk/network/src/v2/vpn/ipsecpolicy/list.rs new file mode 100644 index 000000000..238400bfb --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsecpolicy/list.rs @@ -0,0 +1,264 @@ +// 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`. + +//! Lists all IPsec policies. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Ipsecpolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/ipsecpolicies".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsecpolicies".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "ipsecpolicies" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/ipsecpolicies".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicies": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/ipsecpolicies".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicies": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/ipsecpolicy/set.rs b/sdk/network/src/v2/vpn/ipsecpolicy/set.rs new file mode 100644 index 000000000..3c3df21ee --- /dev/null +++ b/sdk/network/src/v2/vpn/ipsecpolicy/set.rs @@ -0,0 +1,405 @@ +// 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`. + +//! Updates policy settings in an IPsec policy. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum AuthAlgorithm { + #[serde(rename = "aes-cmac")] + AesCmac, + #[serde(rename = "aes-xcbc")] + AesXcbc, + #[serde(rename = "sha1")] + Sha1, + #[serde(rename = "sha256")] + Sha256, + #[serde(rename = "sha384")] + Sha384, + #[serde(rename = "sha512")] + Sha512, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum EncapsulationMode { + #[serde(rename = "transport")] + Transport, + #[serde(rename = "tunnel")] + Tunnel, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum EncryptionAlgorithm { + #[serde(rename = "3des")] + _3des, + #[serde(rename = "aes-128")] + Aes128, + #[serde(rename = "aes-128-ccm-12")] + Aes128Ccm12, + #[serde(rename = "aes-128-ccm-16")] + Aes128Ccm16, + #[serde(rename = "aes-128-ccm-8")] + Aes128Ccm8, + #[serde(rename = "aes-128-ctr")] + Aes128Ctr, + #[serde(rename = "aes-128-gcm-12")] + Aes128Gcm12, + #[serde(rename = "aes-128-gcm-16")] + Aes128Gcm16, + #[serde(rename = "aes-128-gcm-8")] + Aes128Gcm8, + #[serde(rename = "aes-192")] + Aes192, + #[serde(rename = "aes-192-ccm-12")] + Aes192Ccm12, + #[serde(rename = "aes-192-ccm-16")] + Aes192Ccm16, + #[serde(rename = "aes-192-ccm-8")] + Aes192Ccm8, + #[serde(rename = "aes-192-ctr")] + Aes192Ctr, + #[serde(rename = "aes-192-gcm-12")] + Aes192Gcm12, + #[serde(rename = "aes-192-gcm-16")] + Aes192Gcm16, + #[serde(rename = "aes-192-gcm-8")] + Aes192Gcm8, + #[serde(rename = "aes-256")] + Aes256, + #[serde(rename = "aes-256-ccm-12")] + Aes256Ccm12, + #[serde(rename = "aes-256-ccm-16")] + Aes256Ccm16, + #[serde(rename = "aes-256-ccm-8")] + Aes256Ccm8, + #[serde(rename = "aes-256-ctr")] + Aes256Ctr, + #[serde(rename = "aes-256-gcm-12")] + Aes256Gcm12, + #[serde(rename = "aes-256-gcm-16")] + Aes256Gcm16, + #[serde(rename = "aes-256-gcm-8")] + Aes256Gcm8, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Pfs { + #[serde(rename = "group14")] + Group14, + #[serde(rename = "group15")] + Group15, + #[serde(rename = "group16")] + Group16, + #[serde(rename = "group17")] + Group17, + #[serde(rename = "group18")] + Group18, + #[serde(rename = "group19")] + Group19, + #[serde(rename = "group2")] + Group2, + #[serde(rename = "group20")] + Group20, + #[serde(rename = "group21")] + Group21, + #[serde(rename = "group22")] + Group22, + #[serde(rename = "group23")] + Group23, + #[serde(rename = "group24")] + Group24, + #[serde(rename = "group25")] + Group25, + #[serde(rename = "group26")] + Group26, + #[serde(rename = "group27")] + Group27, + #[serde(rename = "group28")] + Group28, + #[serde(rename = "group29")] + Group29, + #[serde(rename = "group30")] + Group30, + #[serde(rename = "group31")] + Group31, + #[serde(rename = "group5")] + Group5, +} + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum TransformProtocol { + #[serde(rename = "ah")] + Ah, + #[serde(rename = "ah-esp")] + AhEsp, + #[serde(rename = "esp")] + Esp, +} + +/// An `ipsecpolicy` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Ipsecpolicy<'a> { + /// The authentication hash algorithm. Valid values are `sha1`, `sha256`, + /// `sha384`, `sha512`, `aes-xcbc`, `aes-cmac`. The default is `sha1`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) auth_algorithm: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The encapsulation mode. A valid value is `tunnel` or `transport`. + /// Default is `tunnel`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) encapsulation_mode: Option, + + /// The encryption algorithm. A valid value is `3des`, `aes-128`, + /// `aes-192`, `aes-256`, `aes-128-ctr`, `aes-192-ctr`, `aes-256-ctr`. + /// Additional values for AES CCM and GCM modes are defined (e.g. + /// `aes-256-ccm-16`, `aes-256-gcm-16`) for all combinations of key length + /// 128, 192, 256 bits and ICV length 8, 12, 16 octets. Default is + /// `aes-128`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) encryption_algorithm: Option, + + /// The lifetime of the security association. The lifetime consists of a + /// unit and integer value. You can omit either the unit or value portion + /// of the lifetime. Default unit is seconds and default value is 3600. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) lifetime: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + /// Perfect forward secrecy (PFS). A valid value is `Group2`, `Group5`, + /// `Group14` to `Group31`. Default is `Group5`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) pfs: Option, + + /// The transform protocol. A valid value is `ESP`, `AH`, or `AH- ESP`. + /// Default is `ESP`. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) transform_protocol: Option, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// An `ipsecpolicy` object. + #[builder(setter(into))] + pub(crate) ipsecpolicy: Ipsecpolicy<'a>, + + /// id parameter for /v2.0/vpn/ipsecpolicies/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Ipsecpolicy. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("vpn/ipsecpolicies/{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("ipsecpolicy", serde_json::to_value(&self.ipsecpolicy)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("ipsecpolicy".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "ipsecpolicy" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/ipsecpolicies/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "ipsecpolicy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .ipsecpolicy(IpsecpolicyBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/network/v2/vpn/vpnservice.rs b/sdk/network/src/v2/vpn/vpnservice.rs similarity index 100% rename from openstack_sdk/src/api/network/v2/vpn/vpnservice.rs rename to sdk/network/src/v2/vpn/vpnservice.rs diff --git a/sdk/network/src/v2/vpn/vpnservice/create.rs b/sdk/network/src/v2/vpn/vpnservice/create.rs new file mode 100644 index 000000000..1b10576bf --- /dev/null +++ b/sdk/network/src/v2/vpn/vpnservice/create.rs @@ -0,0 +1,263 @@ +// 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`. + +//! Creates a VPN service. +//! +//! The service is associated with a router. After you create the service, it +//! can contain multiple VPN connections. +//! +//! An optional `flavor_id` attribute can be passed to enable dynamic selection +//! of an appropriate provider if configured by the operator. It is only +//! available when `vpn-flavors` extension is enabled. The basic selection +//! algorithm chooses the provider in the first service profile currently +//! associated with flavor. This option can only be set in `POST` operation. +//! +//! Normal response codes: 201 +//! +//! Error response codes: 400, 401 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `vpnservice` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Vpnservice<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// The ID of the flavor. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) flavor_id: Option>>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) router_id: Option>, + + /// If you specify only a subnet UUID, OpenStack Networking allocates an + /// available IP from that subnet to the port. If you specify both a subnet + /// UUID and an IP address, OpenStack Networking tries to allocate the + /// address to the port. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) subnet_id: Option>>, + + /// The ID of the project. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) tenant_id: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `vpnservice` object. + #[builder(setter(into))] + pub(crate) vpnservice: Vpnservice<'a>, + + #[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 Vpnservice. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/vpnservices".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("vpnservice", serde_json::to_value(&self.vpnservice)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("vpnservice".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "vpnservice" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/vpnservices".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservice": {} })); + }); + + let endpoint = Request::builder() + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/vpn/vpnservices".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservice": {} })); + }); + + let endpoint = Request::builder() + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/vpnservice/delete.rs b/sdk/network/src/v2/vpn/vpnservice/delete.rs new file mode 100644 index 000000000..ca4f51797 --- /dev/null +++ b/sdk/network/src/v2/vpn/vpnservice/delete.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Removes a VPN service. +//! +//! If the service has connections, the request is rejected. +//! +//! Normal response codes: 204 +//! +//! Error response codes: 401, 404, 409 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/vpnservices/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Vpnservice. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/vpnservices/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/vpnservices/{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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/vpn/vpnservices/{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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/vpnservice/find.rs b/sdk/network/src/v2/vpn/vpnservice/find.rs new file mode 100644 index 000000000..98c573a6d --- /dev/null +++ b/sdk/network/src/v2/vpn/vpnservice/find.rs @@ -0,0 +1,115 @@ +// 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 openstack_sdk_core::api::Findable; +use openstack_sdk_core::api::rest_endpoint_prelude::*; +use openstack_sdk_core::api::{ApiError, RestClient}; +use tracing::trace; + +use crate::v2::vpn::vpnservice::{get as Get, list as List}; + +/// Find for vpn/vpnservice 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<'a> RequestBuilder<'a> { + /// Add a single header to the Volume. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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<'a>; + fn get_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + + fn list_ep(&self) -> Result, ApiError> { + 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().map_err(ApiError::endpoint_builder) + } + /// Locate vpn/vpnservice in a list + fn locate_resource_in_list( + &self, + data: Vec, + ) -> Result> { + // vpn/vpnservice 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") + && let Some(name) = name_as_val.as_str() + && 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/sdk/network/src/v2/vpn/vpnservice/get.rs b/sdk/network/src/v2/vpn/vpnservice/get.rs new file mode 100644 index 000000000..4569ca03b --- /dev/null +++ b/sdk/network/src/v2/vpn/vpnservice/get.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Shows details for a VPN service. +//! +//! If the user is not an administrative user and the VPN service object does +//! not belong to the tenant account for the user, the operation returns the +//! `Forbidden (403)` response code. +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v2.0/vpn/vpnservices/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Vpnservice. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("vpn/vpnservices/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("vpnservice".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "vpnservice" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/vpnservices/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservice": {} })); + }); + + 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/vpn/vpnservices/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservice": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/vpnservice/list.rs b/sdk/network/src/v2/vpn/vpnservice/list.rs new file mode 100644 index 000000000..105c2eb59 --- /dev/null +++ b/sdk/network/src/v2/vpn/vpnservice/list.rs @@ -0,0 +1,266 @@ +// 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`. + +//! Lists all VPN services. +//! +//! The list might be empty. +//! +//! Standard query parameters are supported on the URI. For more information, +//! see [Filtering and Column Selection](#filtering). +//! +//! Use the `fields` query parameter to control which fields are returned in +//! the response body. For more information, see [Fields](#fields). +//! +//! Pagination query parameters are supported if Neutron configuration supports +//! it by overriding `allow_pagination=false`. For more information, see +//! [Pagination](#pagination). +//! +//! Sorting query parameters are supported if Neutron configuration supports it +//! with `allow_sorting=true`. For more information, see [Sorting](#sorting). +//! +//! Normal response codes: 200 +//! +//! Error response codes: 401, 403 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + #[builder(default, setter(into))] + marker: Option>, + + /// Reverse the page direction + #[builder(default)] + page_reverse: Option, + + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + #[builder(default, private, setter(name = "_sort_dir"))] + sort_dir: Option>>, + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + #[builder(default, private, setter(name = "_sort_key"))] + sort_key: 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> { + /// Sort direction. This is an optional feature and may be silently ignored + /// by the server. + pub fn sort_dir(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_dir + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Sort results by the attribute. This is an optional feature and may be + /// silently ignored by the server. + pub fn sort_key(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.sort_key + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Vpnservice. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "vpn/vpnservices".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("page_reverse", self.page_reverse); + if let Some(val) = &self.sort_dir { + params.extend(val.iter().map(|value| ("sort_dir", value))); + } + if let Some(val) = &self.sort_key { + params.extend(val.iter().map(|value| ("sort_key", value))); + } + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("vpnservices".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(2, 0)) + } +} +impl Pageable for Request<'_> {} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "vpnservices" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/vpnservices".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservices": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/vpn/vpnservices".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservices": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/network/src/v2/vpn/vpnservice/set.rs b/sdk/network/src/v2/vpn/vpnservice/set.rs new file mode 100644 index 000000000..c0f8a64b1 --- /dev/null +++ b/sdk/network/src/v2/vpn/vpnservice/set.rs @@ -0,0 +1,241 @@ +// 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`. + +//! Updates a VPN service. +//! +//! Updates the attributes of a VPN service. You cannot update a service with a +//! `PENDING_*` status. +//! +//! Normal response codes: 200 +//! +//! Error response codes: 400, 401, 404 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +/// A `vpnservice` object. +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Vpnservice<'a> { + /// The administrative state of the resource, which is up (`true`) or down + /// (`false`). + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) admin_state_up: Option, + + /// A human-readable description for the resource. Default is an empty + /// string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>, + + /// Human-readable name of the resource. Default is an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `vpnservice` object. + #[builder(setter(into))] + pub(crate) vpnservice: Vpnservice<'a>, + + /// id parameter for /v2.0/vpn/vpnservices/{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<'a> RequestBuilder<'a> { + /// Add a single header to the Vpnservice. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("vpn/vpnservices/{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("vpnservice", serde_json::to_value(&self.vpnservice)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Network + } + + fn response_key(&self) -> Option> { + Some("vpnservice".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(2, 0)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::Network + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .build() + .unwrap() + .response_key() + .unwrap(), + "vpnservice" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/vpnservices/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservice": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/vpn/vpnservices/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "vpnservice": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .vpnservice(VpnserviceBuilder::default().build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/Cargo.toml b/sdk/object-store/Cargo.toml new file mode 100644 index 000000000..7ed592f0b --- /dev/null +++ b/sdk/object-store/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "openstack-sdk-object-store" +description = "OpenStack SDK Object Store service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +async-trait = { workspace = true, optional = true } +derive_builder.workspace = true +futures = { workspace = true, optional = true } +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["async", "sync"] +sync = [] +async = ["dep:async-trait", "dep:futures"] diff --git a/sdk/object-store/src/lib.rs b/sdk/object-store/src/lib.rs new file mode 100644 index 000000000..934a2933f --- /dev/null +++ b/sdk/object-store/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Object_store` Service bindings +pub mod v1; diff --git a/openstack_sdk/src/api/object_store/v1.rs b/sdk/object-store/src/v1.rs similarity index 100% rename from openstack_sdk/src/api/object_store/v1.rs rename to sdk/object-store/src/v1.rs diff --git a/openstack_sdk/src/api/object_store/v1/account.rs b/sdk/object-store/src/v1/account.rs similarity index 100% rename from openstack_sdk/src/api/object_store/v1/account.rs rename to sdk/object-store/src/v1/account.rs diff --git a/sdk/object-store/src/v1/account/delete.rs b/sdk/object-store/src/v1/account/delete.rs new file mode 100644 index 000000000..e2b9be43f --- /dev/null +++ b/sdk/object-store/src/v1/account/delete.rs @@ -0,0 +1,192 @@ +// 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`. + +//! Deletes the specified account when a reseller admin issues this request. +//! Accounts are only deleted by (1) having a reseller admin level auth token +//! (2) sending a DELETE to a proxy server for the account to be deleted and +//! (3) that proxy server having the allow_account_management” config option +//! set to true. Note that an issuing a DELETE request simply marks the account +//! for deletion later as outlined in the link: +//! https://docs.openstack.org/swift/latest/overview_reaper.html. Take care +//! when performing this operation because deleting an account is a one-way +//! operation that is not trivially recoverable. It''s crucial to note that in +//! an OpenStack context, you should delete an account after the project/tenant +//! has been deleted from Keystone. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: 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 Account. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + self.account.as_ref().to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/{account}", account = "account",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().account("account").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/{account}", account = "account",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/account/get.rs b/sdk/object-store/src/v1/account/get.rs new file mode 100644 index 000000000..40cccd1a2 --- /dev/null +++ b/sdk/object-store/src/v1/account/get.rs @@ -0,0 +1,240 @@ +// 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`. + +//! Shows details for an account and lists containers, sorted by name, in the +//! account. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The delimiter is a single character used to split object names to + /// present a pseudo-directory hierarchy of objects. When combined with a + /// prefix query, this enables API users to simulate and traverse the + /// objects in a container as if they were in a directory tree. + #[builder(default, setter(into))] + delimiter: Option>, + + /// For a string value, x, constrains the list to items whose names are + /// less than x. + #[builder(default, setter(into))] + end_marker: Option>, + + /// The response format. Valid values are json, xml, or plain. The default + /// is plain. If you append the format=xml or format=json query parameter + /// to the storage account URL, the response shows extended container + /// information serialized in that format. If you append the format=plain + /// query parameter, the response lists the container names separated by + /// newlines. + #[builder(default, setter(into))] + format: Option>, + + /// For an integer value n, limits the number of results to n. + #[builder(default)] + limit: Option, + + /// For a string value, x, constrains the list to items whose names are + /// greater than x. + #[builder(default, setter(into))] + marker: Option>, + + /// Only objects with this prefix will be returned. When combined with a + /// delimiter query, this enables API users to simulate and traverse the + /// objects in a container as if they were in a directory tree. + #[builder(default, setter(into))] + prefix: Option>, + + /// By default, listings are returned sorted by name, ascending. If you + /// include the reverse=true query parameter, the listing will be returned + /// sorted by name, descending. + #[builder(default)] + reverse: 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> { + /// Add a single header to the Account. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + self.account.as_ref().to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("end_marker", self.end_marker.as_ref()); + params.push_opt("format", self.format.as_ref()); + params.push_opt("prefix", self.prefix.as_ref()); + params.push_opt("delimiter", self.delimiter.as_ref()); + params.push_opt("reverse", self.reverse); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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)) + } +} +impl Pageable for Request<'_> { + fn use_keyset_pagination(&self) -> bool { + false + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/{account}", account = "account",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().account("account").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/{account}", account = "account",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/account/head.rs b/sdk/object-store/src/v1/account/head.rs new file mode 100644 index 000000000..95bdf3b45 --- /dev/null +++ b/sdk/object-store/src/v1/account/head.rs @@ -0,0 +1,181 @@ +// 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`. + +//! Shows metadata for an account. Because the storage system can store large +//! amounts of data, take care when you represent the total bytes response as +//! an integer; when possible, convert it to a 64-bit unsigned integer if your +//! platform supports that primitive type. Do not include metadata headers in +//! this request. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: 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 Account. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + self.account.as_ref().to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/{account}", account = "account",)); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder().account("account").build().unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!("/{account}", account = "account",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .account("account") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/account/set.rs b/sdk/object-store/src/v1/account/set.rs new file mode 100644 index 000000000..544bc092c --- /dev/null +++ b/sdk/object-store/src/v1/account/set.rs @@ -0,0 +1,193 @@ +// 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`. + +//! Creates, updates, or deletes account metadata. To create, update, or delete +//! custom metadata, use the X-Account-Meta-{name} request header, where {name} +//! is the name of the metadata item. Account metadata operations work +//! differently than how object metadata operations work. Depending on the +//! contents of your POST account metadata request, the Object Storage API +//! updates the metadata as shown in the following table: TODO: fill the rest +//! To delete a metadata header, send an empty value for that header, such as +//! for the X-Account-Meta-Book header. If the tool you use to communicate with +//! Object Storage, such as an older version of cURL, does not support empty +//! headers, send the X-Remove-Account- Meta-{name} header with an arbitrary +//! value. For example, X-Remove-Account-Meta-Book: x. The operation ignores +//! the arbitrary value. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: 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 Account. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + self.account.as_ref().to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/{account}", account = "account",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().account("account").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/{account}", account = "account",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/object_store/v1/container.rs b/sdk/object-store/src/v1/container.rs similarity index 100% rename from openstack_sdk/src/api/object_store/v1/container.rs rename to sdk/object-store/src/v1/container.rs diff --git a/sdk/object-store/src/v1/container/create.rs b/sdk/object-store/src/v1/container/create.rs new file mode 100644 index 000000000..27b775d9b --- /dev/null +++ b/sdk/object-store/src/v1/container/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`. + +//! Creates a container. You do not need to check whether a container already +//! exists before issuing a PUT operation because the operation is idempotent: +//! It creates a container or updates an existing container, as appropriate. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: 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 Container. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "{account}/{container}", + account = self.account.as_ref(), + container = self.container.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/container/delete.rs b/sdk/object-store/src/v1/container/delete.rs new file mode 100644 index 000000000..773bb3b25 --- /dev/null +++ b/sdk/object-store/src/v1/container/delete.rs @@ -0,0 +1,210 @@ +// 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`. + +//! Deletes an empty container. This operation fails unless the container is +//! empty. An empty container has no objects. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: 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 Container. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "{account}/{container}", + account = self.account.as_ref(), + container = self.container.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/container/get.rs b/sdk/object-store/src/v1/container/get.rs new file mode 100644 index 000000000..6b6bd3cdc --- /dev/null +++ b/sdk/object-store/src/v1/container/get.rs @@ -0,0 +1,271 @@ +// 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`. + +//! Shows details for a container and lists objects, sorted by name, in the +//! container. Specify query parameters in the request to filter the list and +//! return a subset of objects. Omit query parameters to return a list of +//! objects that are stored in the container, up to 10,000 names. The 10,000 +//! maximum value is configurable. To view the value for the cluster, issue a +//! GET /info request. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use openstack_sdk_core::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: Cow<'a, str>, + + /// The delimiter is a single character used to split object names to + /// present a pseudo-directory hierarchy of objects. When combined with a + /// prefix query, this enables API users to simulate and traverse the + /// objects in a container as if they were in a directory tree. + #[builder(default, setter(into))] + delimiter: Option>, + + /// For a string value, x, constrains the list to items whose names are + /// less than x. + #[builder(default, setter(into))] + end_marker: Option>, + + /// The response format. Valid values are json, xml, or plain. The default + /// is plain. If you append the format=xml or format=json query parameter + /// to the storage account URL, the response shows extended container + /// information serialized in that format. If you append the format=plain + /// query parameter, the response lists the container names separated by + /// newlines. + #[builder(default, setter(into))] + format: Option>, + + /// For an integer value n, limits the number of results to n. + #[builder(default)] + limit: Option, + + /// For a string value, x, constrains the list to items whose names are + /// greater than x. + #[builder(default, setter(into))] + marker: Option>, + + /// Only objects with this prefix will be returned. When combined with a + /// delimiter query, this enables API users to simulate and traverse the + /// objects in a container as if they were in a directory tree. + #[builder(default, setter(into))] + prefix: Option>, + + /// By default, listings are returned sorted by name, ascending. If you + /// include the reverse=true query parameter, the listing will be returned + /// sorted by name, descending. + #[builder(default)] + reverse: 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> { + /// Add a single header to the Container. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "{account}/{container}", + account = self.account.as_ref(), + container = self.container.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); + params.push_opt("end_marker", self.end_marker.as_ref()); + params.push_opt("format", self.format.as_ref()); + params.push_opt("prefix", self.prefix.as_ref()); + params.push_opt("delimiter", self.delimiter.as_ref()); + params.push_opt("reverse", self.reverse); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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)) + } +} +impl Pageable for Request<'_> { + fn use_keyset_pagination(&self) -> bool { + false + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/container/head.rs b/sdk/object-store/src/v1/container/head.rs new file mode 100644 index 000000000..0bdd47859 --- /dev/null +++ b/sdk/object-store/src/v1/container/head.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Shows container metadata, including the number of objects and the total +//! bytes of all objects stored in the container. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: 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 Container. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "{account}/{container}", + account = self.account.as_ref(), + container = self.container.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/object_store/v1/container/prune.rs b/sdk/object-store/src/v1/container/prune.rs similarity index 92% rename from openstack_sdk/src/api/object_store/v1/container/prune.rs rename to sdk/object-store/src/v1/container/prune.rs index 13687ea9d..dee3e13de 100644 --- a/openstack_sdk/src/api/object_store/v1/container/prune.rs +++ b/sdk/object-store/src/v1/container/prune.rs @@ -19,20 +19,15 @@ use futures::stream::{StreamExt, TryStreamExt}; use serde::Deserialize; use tracing::debug; -use crate::{OpenStackError, RestError}; +use openstack_sdk_core::{OpenStackError, RestError}; #[cfg(feature = "async")] -use crate::api::{AsyncClient, QueryAsync}; +use openstack_sdk_core::api::{AsyncClient, QueryAsync}; // #[cfg(feature = "sync")] // use crate::api::Client; -use crate::api::{ - Pagination, ignore, - object_store::v1::{ - container::get::Request as ListRequest, object::delete::Request as DeleteRequest, - }, - paged, -}; +use crate::v1::{container::get::Request as ListRequest, object::delete::Request as DeleteRequest}; +use openstack_sdk_core::api::{Pagination, ignore, paged}; /// Delete concurrency const DELETE_CONCURRENCY: usize = 4; diff --git a/sdk/object-store/src/v1/container/set.rs b/sdk/object-store/src/v1/container/set.rs new file mode 100644 index 000000000..57e724e2e --- /dev/null +++ b/sdk/object-store/src/v1/container/set.rs @@ -0,0 +1,209 @@ +// 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`. + +//! Creates, updates, or deletes custom metadata for a container. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: 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 Container. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "{account}/{container}", + account = self.account.as_ref(), + container = self.container.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/{account}/{container}", + account = "account", + container = "container", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/object_store/v1/object.rs b/sdk/object-store/src/v1/object.rs similarity index 100% rename from openstack_sdk/src/api/object_store/v1/object.rs rename to sdk/object-store/src/v1/object.rs diff --git a/sdk/object-store/src/v1/object/delete.rs b/sdk/object-store/src/v1/object/delete.rs new file mode 100644 index 000000000..609e45db5 --- /dev/null +++ b/sdk/object-store/src/v1/object/delete.rs @@ -0,0 +1,237 @@ +// 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`. + +//! Permanently deletes an object from the object store. Object deletion occurs +//! immediately at request time. Any subsequent GET, HEAD, POST, or DELETE +//! operations will return a 404 Not Found error code. For static large object +//! manifests, you can add the ?multipart- manifest=delete query parameter. +//! This operation deletes the segment objects and, if all deletions succeed, +//! this operation deletes the manifest object. A DELETE request made to a +//! symlink path will delete the symlink rather than the target object. An +//! alternative to using the DELETE operation is to use the POST operation with +//! the bulk-delete query parameter. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: Cow<'a, str>, + + /// If you include the multipart-manifest=get query parameter and the + /// object is a large object, the object contents are not returned. + /// Instead, the manifest is returned in the X-Object-Manifest response + /// header for dynamic large objects or in the response body for static + /// large objects. + #[builder(default, setter(into))] + multipart_manifest: Option>, + + /// The unique name for the object. + #[builder(default, setter(into))] + object: 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 Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "{account}/{container}/{object}", + account = self.account.as_ref(), + container = self.container.as_ref(), + object = self.object.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/object/get.rs b/sdk/object-store/src/v1/object/get.rs new file mode 100644 index 000000000..2ae9f4661 --- /dev/null +++ b/sdk/object-store/src/v1/object/get.rs @@ -0,0 +1,266 @@ +// 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`. + +//! Downloads the object content and gets the object metadata. This operation +//! returns the object metadata in the response headers and the object content +//! in the response body. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: Cow<'a, str>, + + /// Overrides the default file name. Object Storage generates a default + /// file name for GET temporary URLs that is based on the object name. + /// Object Storage returns this value in the Content-Disposition response + /// header. Browsers can interpret this file name value as a file + /// attachment to save. For more information about temporary URLs, see + /// Temporary URL middleware. + #[builder(default, setter(into))] + filename: Option>, + + /// If you include the multipart-manifest=get query parameter and the + /// object is a large object, the object contents are not returned. + /// Instead, the manifest is returned in the X-Object-Manifest response + /// header for dynamic large objects or in the response body for static + /// large objects. + #[builder(default, setter(into))] + multipart_manifest: Option>, + + /// The unique name for the object. + #[builder(default, setter(into))] + object: Cow<'a, str>, + + /// If you include the symlink=get query parameter and the object is a + /// symlink, then the response will include data and metadata from the + /// symlink itself rather than from the target. + #[builder(default, setter(into))] + symlink: Option>, + + /// The date and time in UNIX Epoch time stamp format or ISO 8601 UTC + /// timestamp when the signature for temporary URLs expires. For example, + /// 1440619048 or 2015-08-26T19:57:28Z is equivalent to Mon, Wed, 26 Aug + /// 2015 19:57:28 GMT. For more information about temporary URLs, see + /// Temporary URL middleware. + #[builder(default)] + temp_url_expires: Option, + + /// Used with temporary URLs to sign the request with an HMAC-SHA1 + /// cryptographic signature that defines the allowed HTTP method, + /// expiration date, full path to the object, and the secret key for the + /// temporary URL. For more information about temporary URLs, see Temporary + /// URL middleware. + #[builder(default, setter(into))] + temp_url_sig: 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> { + /// Add a single header to the Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "{account}/{container}/{object}", + account = self.account.as_ref(), + container = self.container.as_ref(), + object = self.object.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); + params.push_opt("temp_url_sig", self.temp_url_sig.as_ref()); + params.push_opt("temp_url_expires", self.temp_url_expires); + params.push_opt("filename", self.filename.as_ref()); + params.push_opt("symlink", self.symlink.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/object-store/src/v1/object/head.rs b/sdk/object-store/src/v1/object/head.rs new file mode 100644 index 000000000..74b6c1e63 --- /dev/null +++ b/sdk/object-store/src/v1/object/head.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`. + +//! Shows object metadata. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: Cow<'a, str>, + + /// Overrides the default file name. Object Storage generates a default + /// file name for GET temporary URLs that is based on the object name. + /// Object Storage returns this value in the Content-Disposition response + /// header. Browsers can interpret this file name value as a file + /// attachment to save. For more information about temporary URLs, see + /// Temporary URL middleware. + #[builder(default, setter(into))] + filename: Option>, + + /// If you include the multipart-manifest=get query parameter and the + /// object is a large object, the object contents are not returned. + /// Instead, the manifest is returned in the X-Object-Manifest response + /// header for dynamic large objects or in the response body for static + /// large objects. + #[builder(default, setter(into))] + multipart_manifest: Option>, + + /// The unique name for the object. + #[builder(default, setter(into))] + object: Cow<'a, str>, + + /// If you include the symlink=get query parameter and the object is a + /// symlink, then the response will include data and metadata from the + /// symlink itself rather than from the target. + #[builder(default, setter(into))] + symlink: Option>, + + /// The date and time in UNIX Epoch time stamp format or ISO 8601 UTC + /// timestamp when the signature for temporary URLs expires. For example, + /// 1440619048 or 2015-08-26T19:57:28Z is equivalent to Mon, Wed, 26 Aug + /// 2015 19:57:28 GMT. For more information about temporary URLs, see + /// Temporary URL middleware. + #[builder(default)] + temp_url_expires: Option, + + /// Used with temporary URLs to sign the request with an HMAC-SHA1 + /// cryptographic signature that defines the allowed HTTP method, + /// expiration date, full path to the object, and the secret key for the + /// temporary URL. For more information about temporary URLs, see Temporary + /// URL middleware. + #[builder(default, setter(into))] + temp_url_sig: 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> { + /// Add a single header to the Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::HEAD + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "{account}/{container}/{object}", + account = self.account.as_ref(), + container = self.container.as_ref(), + object = self.object.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); + params.push_opt("temp_url_sig", self.temp_url_sig.as_ref()); + params.push_opt("temp_url_expires", self.temp_url_expires); + params.push_opt("filename", self.filename.as_ref()); + params.push_opt("symlink", self.symlink.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::RawQuery; + use openstack_sdk_core::types::ServiceType; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD).path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )); + + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::HEAD) + .path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200).header("content-type", "application/json"); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _ = endpoint.raw_query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/object_store/v1/object/put.rs b/sdk/object-store/src/v1/object/put.rs similarity index 99% rename from openstack_sdk/src/api/object_store/v1/object/put.rs rename to sdk/object-store/src/v1/object/put.rs index 0f0e1358d..34be75366 100644 --- a/openstack_sdk/src/api/object_store/v1/object/put.rs +++ b/sdk/object-store/src/v1/object/put.rs @@ -190,7 +190,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/object-store/src/v1/object/set.rs b/sdk/object-store/src/v1/object/set.rs new file mode 100644 index 000000000..98a477da9 --- /dev/null +++ b/sdk/object-store/src/v1/object/set.rs @@ -0,0 +1,278 @@ +// 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`. + +//! Creates or updates object metadata. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The unique name for the account. An account is also known as the + /// project or tenant. + #[builder(default, setter(into))] + account: Cow<'a, str>, + + /// When the bulk-delete query parameter is present in the POST request, + /// multiple objects or containers can be deleted with a single request. + /// See Bulk Delete for how this feature is used. + #[builder(default)] + bulk_delete: Option, + + /// The unique (within an account) name for the container. The container + /// name must be from 1 to 256 characters long and can start with any + /// character and contain any pattern. Character set must be UTF-8. The + /// container name cannot contain a slash (/) character because this + /// character delimits the container and object name. For example, the path + /// /v1/account/www/pages specifies the www container, not the www/pages + /// container. + #[builder(default, setter(into))] + container: Cow<'a, str>, + + /// When the extract-archive query parameter is present in the POST + /// request, an archive (tar file) is uploaded and extracted to create + /// multiple objects. See Extract Archive for how this feature is used. + #[builder(default)] + extract_archive: Option, + + /// Overrides the default file name. Object Storage generates a default + /// file name for GET temporary URLs that is based on the object name. + /// Object Storage returns this value in the Content-Disposition response + /// header. Browsers can interpret this file name value as a file + /// attachment to save. For more information about temporary URLs, see + /// Temporary URL middleware. + #[builder(default, setter(into))] + filename: Option>, + + /// If you include the multipart-manifest=get query parameter and the + /// object is a large object, the object contents are not returned. + /// Instead, the manifest is returned in the X-Object-Manifest response + /// header for dynamic large objects or in the response body for static + /// large objects. + #[builder(default, setter(into))] + multipart_manifest: Option>, + + /// The unique name for the object. + #[builder(default, setter(into))] + object: Cow<'a, str>, + + /// If you include the symlink=get query parameter and the object is a + /// symlink, then the response will include data and metadata from the + /// symlink itself rather than from the target. + #[builder(default, setter(into))] + symlink: Option>, + + /// The date and time in UNIX Epoch time stamp format or ISO 8601 UTC + /// timestamp when the signature for temporary URLs expires. For example, + /// 1440619048 or 2015-08-26T19:57:28Z is equivalent to Mon, Wed, 26 Aug + /// 2015 19:57:28 GMT. For more information about temporary URLs, see + /// Temporary URL middleware. + #[builder(default)] + temp_url_expires: Option, + + /// Used with temporary URLs to sign the request with an HMAC-SHA1 + /// cryptographic signature that defines the allowed HTTP method, + /// expiration date, full path to the object, and the secret key for the + /// temporary URL. For more information about temporary URLs, see Temporary + /// URL middleware. + #[builder(default, setter(into))] + temp_url_sig: 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> { + /// Add a single header to the Object. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "{account}/{container}/{object}", + account = self.account.as_ref(), + container = self.container.as_ref(), + object = self.object.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("multipart-manifest", self.multipart_manifest.as_ref()); + params.push_opt("temp_url_sig", self.temp_url_sig.as_ref()); + params.push_opt("temp_url_expires", self.temp_url_expires); + params.push_opt("filename", self.filename.as_ref()); + params.push_opt("symlink", self.symlink.as_ref()); + params.push_opt("bulk-delete", self.bulk_delete); + params.push_opt("extract-archive", self.extract_archive); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::ObjectStore + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::ObjectStore + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/{account}/{container}/{object}", + account = "account", + container = "container", + object = "object", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .account("account") + .container("container") + .object("object") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/Cargo.toml b/sdk/placement/Cargo.toml new file mode 100644 index 000000000..7916478ba --- /dev/null +++ b/sdk/placement/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "openstack-sdk-placement" +description = "OpenStack SDK Placement service bindings" +version = "0.1.0" +license.workspace = true +edition.workspace = true +authors.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +derive_builder.workspace = true +http.workspace = true +openstack-sdk-core = { path = "../core/", version = "^0.22" } +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true + +[dev-dependencies] +bytes.workspace = true +httpmock.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-test.workspace = true + +[lints] +workspace = true + +[features] +default = ["sync"] +sync = [] +async = [] diff --git a/sdk/placement/src/lib.rs b/sdk/placement/src/lib.rs new file mode 100644 index 000000000..278897c67 --- /dev/null +++ b/sdk/placement/src/lib.rs @@ -0,0 +1,16 @@ +// 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 +// +//! # OpenStack SDK `Placement` Service bindings +pub mod v1; diff --git a/openstack_sdk/src/api/placement/v1.rs b/sdk/placement/src/v1.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1.rs rename to sdk/placement/src/v1.rs diff --git a/openstack_sdk/src/api/placement/v1/allocation.rs b/sdk/placement/src/v1/allocation.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/allocation.rs rename to sdk/placement/src/v1/allocation.rs diff --git a/openstack_sdk/src/api/placement/v1/allocation/create_113.rs b/sdk/placement/src/v1/allocation/create_113.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/allocation/create_113.rs rename to sdk/placement/src/v1/allocation/create_113.rs index d92c62bf9..b913e1447 100644 --- a/openstack_sdk/src/api/placement/v1/allocation/create_113.rs +++ b/sdk/placement/src/v1/allocation/create_113.rs @@ -204,7 +204,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/allocation/create_128.rs b/sdk/placement/src/v1/allocation/create_128.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/allocation/create_128.rs rename to sdk/placement/src/v1/allocation/create_128.rs index cbe6ff3ea..11b0c43fd 100644 --- a/openstack_sdk/src/api/placement/v1/allocation/create_128.rs +++ b/sdk/placement/src/v1/allocation/create_128.rs @@ -208,7 +208,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/placement/src/v1/allocation/create_134.rs b/sdk/placement/src/v1/allocation/create_134.rs new file mode 100644 index 000000000..11d72d1e4 --- /dev/null +++ b/sdk/placement/src/v1/allocation/create_134.rs @@ -0,0 +1,295 @@ +// 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, update or delete allocations for multiple consumers in a single +//! request. This allows a client to atomically set or swap allocations for +//! multiple consumers as may be required during a migration or move type +//! operation. +//! +//! The allocations for an individual consumer uuid mentioned in the request +//! can be removed by setting the allocations to an empty object (see the +//! example below). +//! +//! **Available as of microversion 1.13.** +//! +//! Normal response codes: 204 +//! +//! Error response codes: badRequest(400), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationsItem<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) generation: Option, + + #[serde()] + #[builder(private, setter(into, name = "_resources"))] + pub(crate) resources: BTreeMap, i32>, +} + +impl<'a> AllocationsItemBuilder<'a> { + pub fn resources(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.resources + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Item<'a> { + #[serde()] + #[builder(private, setter(into, name = "_allocations"))] + pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) consumer_generation: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_mappings"))] + pub(crate) mappings: Option, Vec>>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) project_id: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) user_id: Cow<'a, str>, +} + +impl<'a> ItemBuilder<'a> { + pub fn allocations(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.allocations + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn mappings(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: IntoIterator, + V1: Into>, + { + self.mappings + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Item<'a>>, +} +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 Allocation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "allocations".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + 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, 34)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/allocations".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/allocations".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/allocation/create_138.rs b/sdk/placement/src/v1/allocation/create_138.rs new file mode 100644 index 000000000..8aed8fc5d --- /dev/null +++ b/sdk/placement/src/v1/allocation/create_138.rs @@ -0,0 +1,299 @@ +// 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, update or delete allocations for multiple consumers in a single +//! request. This allows a client to atomically set or swap allocations for +//! multiple consumers as may be required during a migration or move type +//! operation. +//! +//! The allocations for an individual consumer uuid mentioned in the request +//! can be removed by setting the allocations to an empty object (see the +//! example below). +//! +//! **Available as of microversion 1.13.** +//! +//! Normal response codes: 204 +//! +//! Error response codes: badRequest(400), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationsItem<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) generation: Option, + + #[serde()] + #[builder(private, setter(into, name = "_resources"))] + pub(crate) resources: BTreeMap, i32>, +} + +impl<'a> AllocationsItemBuilder<'a> { + pub fn resources(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.resources + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Item<'a> { + #[serde()] + #[builder(private, setter(into, name = "_allocations"))] + pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) consumer_generation: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) consumer_type: Cow<'a, str>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_mappings"))] + pub(crate) mappings: Option, Vec>>>, + + #[serde()] + #[builder(setter(into))] + pub(crate) project_id: Cow<'a, str>, + + #[serde()] + #[builder(setter(into))] + pub(crate) user_id: Cow<'a, str>, +} + +impl<'a> ItemBuilder<'a> { + pub fn allocations(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.allocations + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + pub fn mappings(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: IntoIterator, + V1: Into>, + { + self.mappings + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Item<'a>>, +} +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 Allocation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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 + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl RestEndpoint for Request<'_> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "allocations".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + 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, 38)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/allocations".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/allocations".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/allocation/delete.rs b/sdk/placement/src/v1/allocation/delete.rs new file mode 100644 index 000000000..6def35e3a --- /dev/null +++ b/sdk/placement/src/v1/allocation/delete.rs @@ -0,0 +1,193 @@ +// 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 all allocation records for the consumer identified by +//! {consumer_uuid} on all resource providers it is consuming. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// consumer_uuid parameter for /allocations/{consumer_uuid} API + #[builder(default, setter(into))] + consumer_uuid: 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 Allocation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "allocations/{consumer_uuid}", + consumer_uuid = self.consumer_uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/allocations/{consumer_uuid}", + consumer_uuid = "consumer_uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consumer_uuid("consumer_uuid") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/allocations/{consumer_uuid}", + consumer_uuid = "consumer_uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consumer_uuid("consumer_uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/allocation/get.rs b/sdk/placement/src/v1/allocation/get.rs new file mode 100644 index 000000000..179b66d77 --- /dev/null +++ b/sdk/placement/src/v1/allocation/get.rs @@ -0,0 +1,191 @@ +// 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 allocation records for the consumer identified by {consumer_uuid} +//! on all the resource providers it is consuming. +//! +//! Normal Response Codes: 200 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// consumer_uuid parameter for /allocations/{consumer_uuid} API + #[builder(default, setter(into))] + consumer_uuid: 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 Allocation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "allocations/{consumer_uuid}", + consumer_uuid = self.consumer_uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/allocations/{consumer_uuid}", + consumer_uuid = "consumer_uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consumer_uuid("consumer_uuid") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/allocations/{consumer_uuid}", + consumer_uuid = "consumer_uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consumer_uuid("consumer_uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/allocation/set_10.rs b/sdk/placement/src/v1/allocation/set_10.rs new file mode 100644 index 000000000..034c19cb8 --- /dev/null +++ b/sdk/placement/src/v1/allocation/set_10.rs @@ -0,0 +1,297 @@ +// 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 or update one or more allocation records representing the +//! consumption of one or more classes of resources from one or more resource +//! providers by the consumer identified by {consumer_uuid}. If allocations +//! already exist for this consumer, they are replaced. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct ResourceProvider<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) uuid: Cow<'a, str>, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Allocations<'a> { + #[serde()] + #[builder(setter(into))] + pub(crate) resource_provider: ResourceProvider<'a>, + + #[serde()] + #[builder(private, setter(into, name = "_resources"))] + pub(crate) resources: BTreeMap, i32>, +} + +impl<'a> AllocationsBuilder<'a> { + pub fn resources(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.resources + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) allocations: Vec>, + + /// consumer_uuid parameter for /allocations/{consumer_uuid} API + #[builder(default, setter(into))] + consumer_uuid: 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 Allocation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "allocations/{consumer_uuid}", + consumer_uuid = self.consumer_uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("allocations", serde_json::to_value(&self.allocations)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .allocations(Vec::from([AllocationsBuilder::default() + .resource_provider( + ResourceProviderBuilder::default() + .uuid("foo") + .build() + .unwrap() + ) + .resources(BTreeMap::::new().into_iter()) + .build() + .unwrap()])) + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .allocations(Vec::from([AllocationsBuilder::default() + .resource_provider( + ResourceProviderBuilder::default() + .uuid("foo") + .build() + .unwrap() + ) + .resources(BTreeMap::::new().into_iter()) + .build() + .unwrap()])) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/allocations/{consumer_uuid}", + consumer_uuid = "consumer_uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consumer_uuid("consumer_uuid") + .allocations(Vec::from([AllocationsBuilder::default() + .resource_provider( + ResourceProviderBuilder::default() + .uuid("foo") + .build() + .unwrap(), + ) + .resources(BTreeMap::::new().into_iter()) + .build() + .unwrap()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/allocations/{consumer_uuid}", + consumer_uuid = "consumer_uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .consumer_uuid("consumer_uuid") + .allocations(Vec::from([AllocationsBuilder::default() + .resource_provider( + ResourceProviderBuilder::default() + .uuid("foo") + .build() + .unwrap(), + ) + .resources(BTreeMap::::new().into_iter()) + .build() + .unwrap()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/allocation/set_112.rs b/sdk/placement/src/v1/allocation/set_112.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/allocation/set_112.rs rename to sdk/placement/src/v1/allocation/set_112.rs index 7de65531f..f590cfc62 100644 --- a/openstack_sdk/src/api/placement/v1/allocation/set_112.rs +++ b/sdk/placement/src/v1/allocation/set_112.rs @@ -182,7 +182,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/allocation/set_128.rs b/sdk/placement/src/v1/allocation/set_128.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/allocation/set_128.rs rename to sdk/placement/src/v1/allocation/set_128.rs index 83dadf60c..acfc09e47 100644 --- a/openstack_sdk/src/api/placement/v1/allocation/set_128.rs +++ b/sdk/placement/src/v1/allocation/set_128.rs @@ -189,7 +189,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/allocation/set_138.rs b/sdk/placement/src/v1/allocation/set_138.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/allocation/set_138.rs rename to sdk/placement/src/v1/allocation/set_138.rs index e260646a6..b7a976b01 100644 --- a/openstack_sdk/src/api/placement/v1/allocation/set_138.rs +++ b/sdk/placement/src/v1/allocation/set_138.rs @@ -213,7 +213,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/allocation/set_18.rs b/sdk/placement/src/v1/allocation/set_18.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/allocation/set_18.rs rename to sdk/placement/src/v1/allocation/set_18.rs index 195dc1e58..066ef39a6 100644 --- a/openstack_sdk/src/api/placement/v1/allocation/set_18.rs +++ b/sdk/placement/src/v1/allocation/set_18.rs @@ -178,7 +178,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/allocation_candidate.rs b/sdk/placement/src/v1/allocation_candidate.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/allocation_candidate.rs rename to sdk/placement/src/v1/allocation_candidate.rs diff --git a/sdk/placement/src/v1/allocation_candidate/list.rs b/sdk/placement/src/v1/allocation_candidate/list.rs new file mode 100644 index 000000000..8d4e0eafc --- /dev/null +++ b/sdk/placement/src/v1/allocation_candidate/list.rs @@ -0,0 +1,384 @@ +// 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`. + +//! Returns a dictionary representing a collection of allocation requests and +//! resource provider summaries. Each allocation request has information to +//! form a `PUT /allocations/{consumer_uuid}` request to claim resources +//! against a related set of resource providers. Additional parameters might be +//! required, see [Update allocations](#update-allocations). As several +//! allocation requests are available it’s necessary to select one. To make a +//! decision, resource provider summaries are provided with the +//! inventory/capacity information. For example, this information is used by +//! nova-scheduler’s FilterScheduler to make decisions about on which compute +//! host to build a server. +//! +//! You can also find additional case studies of the request parameters in the +//! [Modeling with Provider Trees](https://docs.openstack.org/placement/latest/usage/provider-tree.html) +//! document. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: badRequest(400) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// When more than one resourcesN query parameter is supplied, group_policy + /// is required to indicate how the groups should interact. With + /// group_policy=none, separate groupings - with or without a suffix - may + /// or may not be satisfied by the same provider. With + /// group_policy=isolate, suffixed groups are guaranteed to be satisfied by + /// different providers - though there may still be overlap with the + /// suffixless group. + #[builder(default, setter(into))] + group_policy: Option>, + + /// A string representing a resource provider uuid. When supplied, it will + /// filter the returned allocation candidates to only those resource + /// providers that are in the same tree with the given resource provider. + #[builder(default, setter(into))] + in_tree: Option>, + + /// A positive integer used to limit the maximum number of allocation + /// candidates returned in the response. + #[builder(default)] + limit: Option, + + /// A string representing an aggregate uuid; or the prefix in: followed by + /// a comma-separated list of strings representing aggregate uuids. The + /// resource providers in the allocation request in the response must + /// directly or via the root provider be associated with the aggregate or + /// aggregates identified by uuid: + /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, + /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` + /// Starting from microversion 1.24 specifying multiple member_of query + /// string parameters is possible. Multiple member_of parameters will + /// result in filtering providers that are directly or via root provider + /// associated with aggregates listed in all of the member_of query string + /// values. For example, to get the providers that are associated with + /// aggregate A as well as associated with any of aggregates B or C, the + /// user could issue the following query: + /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from + /// microversion 1.32 specifying forbidden aggregates is supported in the + /// member_of query string parameter. Forbidden aggregates are prefixed + /// with a !. This negative expression can also be used in multiple + /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would + /// translate logically to “Candidate resource providers must be in AGGA + /// and not in AGGB.” We do NOT support ! on the values within in:, but we + /// support !in:. Both of the following two example queries return + /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: + /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, + /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do + /// not check if the same aggregate uuid is in both positive and negative + /// expression to return 400 BadRequest. We still return 200 for such + /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would + /// return empty allocation_requests and provider_summaries, while: + /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return + /// resource providers that are NOT in AGGA but in AGGB. + #[builder(default, private, setter(name = "_member_of"))] + member_of: Option>>, + + /// A comma-separated list of traits that a provider must have: + /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the + /// response will be for resource providers that have capacity for all + /// requested resources and the set of those resource providers will + /// collectively contain all of the required traits. These traits may be + /// satisfied by any provider in the same non-sharing tree or associated + /// via aggregate as far as that provider also contributes resource to the + /// request. Starting from microversion 1.22 traits which are forbidden + /// from any resource provider contributing resources to the request may be + /// expressed by prefixing a trait with a `!`. Starting from microversion + /// 1.39 the required query parameter can be repeated. The trait lists from + /// the repeated parameters are AND-ed together. So: + /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting + /// from microversion 1.39 the required parameter supports the syntax: + /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden + /// traits into an in: prefixed value is not supported and rejected. But + /// mixing a normal trait list and an in: prefixed trait list in two query + /// params within the same request is supported. So: + /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and + /// not T2 and (T3 or T4). + #[builder(default, private, setter(name = "_required"))] + required: Option>>, + + /// A comma-separated list of strings indicating an amount of resource of a + /// specified class that providers in each allocation request must + /// collectively have the capacity and availability to serve: + /// `resources=VCPU:4,DISK_GB:64,MEMORY_MB:2048` These resources may be + /// satisfied by any provider in the same non-sharing tree or associated + /// via aggregate. + #[builder(default, setter(into))] + resources: Option>, + + /// A comma-separated list of trait requirements that the root provider of + /// the (non-sharing) tree must satisfy: + /// `root_required=COMPUTE_SUPPORTS_MULTI_ATTACH,!CUSTOM_WINDOWS_LICENSED` + /// Allocation requests in the response will be limited to those whose + /// (non-sharing) tree’s root provider satisfies the specified trait + /// requirements. Traits which are forbidden (must not be present on the + /// root provider) are expressed by prefixing the trait with a !. + #[builder(default, setter(into))] + root_required: Option>, + + /// A comma-separated list of request group suffix strings ($S). Each must + /// exactly match a suffix on a granular group somewhere else in the + /// request. Importantly, the identified request groups need not have a + /// resources[$S]. If this is provided, at least one of the resource + /// providers satisfying a specified request group must be an ancestor of + /// the rest. The same_subtree query parameter can be repeated and each + /// repeat group is treated independently. + #[builder(default, setter(into))] + same_subtree: 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> { + /// A string representing an aggregate uuid; or the prefix in: followed by + /// a comma-separated list of strings representing aggregate uuids. The + /// resource providers in the allocation request in the response must + /// directly or via the root provider be associated with the aggregate or + /// aggregates identified by uuid: + /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, + /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` + /// Starting from microversion 1.24 specifying multiple member_of query + /// string parameters is possible. Multiple member_of parameters will + /// result in filtering providers that are directly or via root provider + /// associated with aggregates listed in all of the member_of query string + /// values. For example, to get the providers that are associated with + /// aggregate A as well as associated with any of aggregates B or C, the + /// user could issue the following query: + /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from + /// microversion 1.32 specifying forbidden aggregates is supported in the + /// member_of query string parameter. Forbidden aggregates are prefixed + /// with a !. This negative expression can also be used in multiple + /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would + /// translate logically to “Candidate resource providers must be in AGGA + /// and not in AGGB.” We do NOT support ! on the values within in:, but we + /// support !in:. Both of the following two example queries return + /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: + /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, + /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do + /// not check if the same aggregate uuid is in both positive and negative + /// expression to return 400 BadRequest. We still return 200 for such + /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would + /// return empty allocation_requests and provider_summaries, while: + /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return + /// resource providers that are NOT in AGGA but in AGGB. + pub fn member_of(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.member_of + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// A comma-separated list of traits that a provider must have: + /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the + /// response will be for resource providers that have capacity for all + /// requested resources and the set of those resource providers will + /// collectively contain all of the required traits. These traits may be + /// satisfied by any provider in the same non-sharing tree or associated + /// via aggregate as far as that provider also contributes resource to the + /// request. Starting from microversion 1.22 traits which are forbidden + /// from any resource provider contributing resources to the request may be + /// expressed by prefixing a trait with a `!`. Starting from microversion + /// 1.39 the required query parameter can be repeated. The trait lists from + /// the repeated parameters are AND-ed together. So: + /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting + /// from microversion 1.39 the required parameter supports the syntax: + /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden + /// traits into an in: prefixed value is not supported and rejected. But + /// mixing a normal trait list and an in: prefixed trait list in two query + /// params within the same request is supported. So: + /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and + /// not T2 and (T3 or T4). + pub fn required(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.required + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Allocation_Candidate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "allocation_candidates".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("group_policy", self.group_policy.as_ref()); + params.push_opt("in_tree", self.in_tree.as_ref()); + params.push_opt("limit", self.limit); + if let Some(val) = &self.member_of { + params.extend(val.iter().map(|value| ("member_of", value))); + } + if let Some(val) = &self.required { + params.extend(val.iter().map(|value| ("required", value))); + } + params.push_opt("resources", self.resources.as_ref()); + params.push_opt("root_required", self.root_required.as_ref()); + params.push_opt("same_subtree", self.same_subtree.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/allocation_candidates".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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/allocation_candidates".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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/reshaper.rs b/sdk/placement/src/v1/reshaper.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/reshaper.rs rename to sdk/placement/src/v1/reshaper.rs diff --git a/sdk/placement/src/v1/reshaper/create_134.rs b/sdk/placement/src/v1/reshaper/create_134.rs new file mode 100644 index 000000000..8889afc72 --- /dev/null +++ b/sdk/placement/src/v1/reshaper/create_134.rs @@ -0,0 +1,428 @@ +// 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`. + +//! Atomically migrate resource provider inventories and associated +//! allocations. This is used when some of the inventory needs to move from one +//! resource provider to another, such as when a class of inventory moves from +//! a parent provider to a new child provider. +//! +//! Normal Response Codes: 204 +//! +//! Error Response Codes: badRequest(400), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationsItem<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) generation: Option, + + /// A dictionary of resource records keyed by resource class name. + #[serde()] + #[builder(private, setter(into, name = "_resources"))] + pub(crate) resources: BTreeMap, i32>, +} + +impl<'a> AllocationsItemBuilder<'a> { + /// A dictionary of resource records keyed by resource class name. + pub fn resources(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.resources + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationsItemStruct<'a> { + /// A dictionary of resource allocations keyed by resource provider uuid. + /// If this is an empty object, allocations for this consumer will be + /// removed. + #[serde()] + #[builder(private, setter(into, name = "_allocations"))] + pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, + + /// The generation of the consumer. Should be set to null when indicating + /// that the caller expects the consumer does not yet exist. + #[serde()] + #[builder(setter(into))] + pub(crate) consumer_generation: Option, + + /// A dictionary associating request group suffixes with a list of uuids + /// identifying the resource providers that satisfied each group. The empty + /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent + /// when writing allocations back to the server but will be ignored; this + /// preserves symmetry between read and write representations. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_mappings"))] + pub(crate) mappings: Option, Vec>>>, + + /// The uuid of a project. + #[serde()] + #[builder(setter(into))] + pub(crate) project_id: Cow<'a, str>, + + /// The uuid of a user. + #[serde()] + #[builder(setter(into))] + pub(crate) user_id: Cow<'a, str>, +} + +impl<'a> AllocationsItemStructBuilder<'a> { + /// A dictionary of resource allocations keyed by resource provider uuid. + /// If this is an empty object, allocations for this consumer will be + /// removed. + pub fn allocations(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.allocations + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// A dictionary associating request group suffixes with a list of uuids + /// identifying the resource providers that satisfied each group. The empty + /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent + /// when writing allocations back to the server but will be ignored; this + /// preserves symmetry between read and write representations. + pub fn mappings(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: IntoIterator, + V1: Into>, + { + self.mappings + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); + self + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InventoriesItem { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allocation_ratio: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_unit: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_unit: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) reserved: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) resource_provider_generation: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) step_size: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) total: i32, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InventoriesItemStruct<'a> { + /// A dictionary of inventories keyed by resource classes. + #[serde()] + #[builder(private, setter(into, name = "_inventories"))] + pub(crate) inventories: BTreeMap, InventoriesItem>, + + /// A consistent view marker that assists with the management of concurrent + /// resource provider updates. + #[serde()] + #[builder(setter(into))] + pub(crate) resource_provider_generation: i32, +} + +impl<'a> InventoriesItemStructBuilder<'a> { + /// A dictionary of inventories keyed by resource classes. + pub fn inventories(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.inventories + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary of multiple allocations, keyed by consumer uuid. Each + /// collection of allocations describes the full set of allocations for + /// each consumer. Each consumer allocations dict is itself a dictionary of + /// resource allocations keyed by resource provider uuid. An empty + /// dictionary indicates no change in existing allocations, whereas an + /// empty `allocations` dictionary **within** a consumer dictionary + /// indicates that all allocations for that consumer should be deleted. + #[builder(private, setter(into, name = "_allocations"))] + pub(crate) allocations: BTreeMap, AllocationsItemStruct<'a>>, + + /// A dictionary of multiple inventories, keyed by resource provider uuid. + /// Each inventory describes the desired full inventory for each resource + /// provider. An empty dictionary causes the inventory for that provider to + /// be deleted. + #[builder(private, setter(into, name = "_inventories"))] + pub(crate) inventories: BTreeMap, InventoriesItemStruct<'a>>, + + #[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> { + /// A dictionary of multiple allocations, keyed by consumer uuid. Each + /// collection of allocations describes the full set of allocations for + /// each consumer. Each consumer allocations dict is itself a dictionary of + /// resource allocations keyed by resource provider uuid. An empty + /// dictionary indicates no change in existing allocations, whereas an + /// empty `allocations` dictionary **within** a consumer dictionary + /// indicates that all allocations for that consumer should be deleted. + pub fn allocations(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.allocations + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// A dictionary of multiple inventories, keyed by resource provider uuid. + /// Each inventory describes the desired full inventory for each resource + /// provider. An empty dictionary causes the inventory for that provider to + /// be deleted. + pub fn inventories(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.inventories + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Reshaper. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "reshaper".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("allocations", serde_json::to_value(&self.allocations)?); + params.push("inventories", serde_json::to_value(&self.inventories)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + 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, 34)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/reshaper".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/reshaper".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() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/reshaper/create_138.rs b/sdk/placement/src/v1/reshaper/create_138.rs new file mode 100644 index 000000000..4d392360c --- /dev/null +++ b/sdk/placement/src/v1/reshaper/create_138.rs @@ -0,0 +1,438 @@ +// 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`. + +//! Atomically migrate resource provider inventories and associated +//! allocations. This is used when some of the inventory needs to move from one +//! resource provider to another, such as when a class of inventory moves from +//! a parent provider to a new child provider. +//! +//! Normal Response Codes: 204 +//! +//! Error Response Codes: badRequest(400), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationsItem<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) generation: Option, + + /// A dictionary of resource records keyed by resource class name. + #[serde()] + #[builder(private, setter(into, name = "_resources"))] + pub(crate) resources: BTreeMap, i32>, +} + +impl<'a> AllocationsItemBuilder<'a> { + /// A dictionary of resource records keyed by resource class name. + pub fn resources(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.resources + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct AllocationsItemStruct<'a> { + /// A dictionary of resource allocations keyed by resource provider uuid. + /// If this is an empty object, allocations for this consumer will be + /// removed. + #[serde()] + #[builder(private, setter(into, name = "_allocations"))] + pub(crate) allocations: BTreeMap, AllocationsItem<'a>>, + + /// The generation of the consumer. Should be set to null when indicating + /// that the caller expects the consumer does not yet exist. + #[serde()] + #[builder(setter(into))] + pub(crate) consumer_generation: Option, + + /// A string that consists of numbers, A-Z, and _ describing what kind of + /// consumer is creating, or has created, allocations using a quantity of + /// inventory. The string is determined by the client when writing + /// allocations and it is up to the client to ensure correct choices + /// amongst collaborating services. For example, the compute service may + /// choose to type some consumers ‘INSTANCE’ and others ‘MIGRATION’. + #[serde()] + #[builder(setter(into))] + pub(crate) consumer_type: Cow<'a, str>, + + /// A dictionary associating request group suffixes with a list of uuids + /// identifying the resource providers that satisfied each group. The empty + /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent + /// when writing allocations back to the server but will be ignored; this + /// preserves symmetry between read and write representations. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(into, name = "_mappings"))] + pub(crate) mappings: Option, Vec>>>, + + /// The uuid of a project. + #[serde()] + #[builder(setter(into))] + pub(crate) project_id: Cow<'a, str>, + + /// The uuid of a user. + #[serde()] + #[builder(setter(into))] + pub(crate) user_id: Cow<'a, str>, +} + +impl<'a> AllocationsItemStructBuilder<'a> { + /// A dictionary of resource allocations keyed by resource provider uuid. + /// If this is an empty object, allocations for this consumer will be + /// removed. + pub fn allocations(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.allocations + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// A dictionary associating request group suffixes with a list of uuids + /// identifying the resource providers that satisfied each group. The empty + /// string and [a-zA-Z0-9\_-]+ are valid suffixes. This field may be sent + /// when writing allocations back to the server but will be ignored; this + /// preserves symmetry between read and write representations. + pub fn mappings(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: IntoIterator, + V1: Into>, + { + self.mappings + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into_iter().map(Into::into).collect()))); + self + } +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InventoriesItem { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allocation_ratio: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_unit: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_unit: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) reserved: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) resource_provider_generation: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) step_size: Option, + + #[serde()] + #[builder(setter(into))] + pub(crate) total: i32, +} + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InventoriesItemStruct<'a> { + /// A dictionary of inventories keyed by resource classes. + #[serde()] + #[builder(private, setter(into, name = "_inventories"))] + pub(crate) inventories: BTreeMap, InventoriesItem>, + + /// A consistent view marker that assists with the management of concurrent + /// resource provider updates. + #[serde()] + #[builder(setter(into))] + pub(crate) resource_provider_generation: i32, +} + +impl<'a> InventoriesItemStructBuilder<'a> { + /// A dictionary of inventories keyed by resource classes. + pub fn inventories(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.inventories + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary of multiple allocations, keyed by consumer uuid. Each + /// collection of allocations describes the full set of allocations for + /// each consumer. Each consumer allocations dict is itself a dictionary of + /// resource allocations keyed by resource provider uuid. An empty + /// dictionary indicates no change in existing allocations, whereas an + /// empty `allocations` dictionary **within** a consumer dictionary + /// indicates that all allocations for that consumer should be deleted. + #[builder(private, setter(into, name = "_allocations"))] + pub(crate) allocations: BTreeMap, AllocationsItemStruct<'a>>, + + /// A dictionary of multiple inventories, keyed by resource provider uuid. + /// Each inventory describes the desired full inventory for each resource + /// provider. An empty dictionary causes the inventory for that provider to + /// be deleted. + #[builder(private, setter(into, name = "_inventories"))] + pub(crate) inventories: BTreeMap, InventoriesItemStruct<'a>>, + + #[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> { + /// A dictionary of multiple allocations, keyed by consumer uuid. Each + /// collection of allocations describes the full set of allocations for + /// each consumer. Each consumer allocations dict is itself a dictionary of + /// resource allocations keyed by resource provider uuid. An empty + /// dictionary indicates no change in existing allocations, whereas an + /// empty `allocations` dictionary **within** a consumer dictionary + /// indicates that all allocations for that consumer should be deleted. + pub fn allocations(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.allocations + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// A dictionary of multiple inventories, keyed by resource provider uuid. + /// Each inventory describes the desired full inventory for each resource + /// provider. An empty dictionary causes the inventory for that provider to + /// be deleted. + pub fn inventories(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.inventories + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Reshaper. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "reshaper".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("allocations", serde_json::to_value(&self.allocations)?); + params.push("inventories", serde_json::to_value(&self.inventories)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + 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, 38)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/reshaper".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/reshaper".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() + .allocations(BTreeMap::>::new().into_iter()) + .inventories(BTreeMap::>::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/resource_class.rs b/sdk/placement/src/v1/resource_class.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/resource_class.rs rename to sdk/placement/src/v1/resource_class.rs diff --git a/sdk/placement/src/v1/resource_class/create.rs b/sdk/placement/src/v1/resource_class/create.rs new file mode 100644 index 000000000..2f575de64 --- /dev/null +++ b/sdk/placement/src/v1/resource_class/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 a new resource class. The new class must be a *custom* resource +//! class, prefixed with CUSTOM\_ and distinct from the standard resource +//! classes. +//! +//! Normal Response Codes: 201 +//! +//! Error response codes: badRequest(400), conflict(409) +//! +//! A 400 BadRequest response code will be returned if the resource class does +//! not have prefix CUSTOM\_. +//! +//! A 409 Conflict response code will be returned if another resource class +//! exists with the provided name. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The name of one resource class. + #[builder(setter(into))] + pub(crate) name: 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 Resource_Class. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "resource_classes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("name", serde_json::to_value(&self.name)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/resource_classes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().name("foo").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/resource_classes".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() + .name("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_class/delete.rs b/sdk/placement/src/v1/resource_class/delete.rs new file mode 100644 index 000000000..74e7eeee1 --- /dev/null +++ b/sdk/placement/src/v1/resource_class/delete.rs @@ -0,0 +1,186 @@ +// 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 the resource class identified by {name}. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) +//! +//! A 400 BadRequest response code will be returned if trying to delete a +//! standard resource class. +//! +//! A 409 Conflict response code will be returned if there exist inventories +//! for the resource class. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// name parameter for /resource_classes/{name} API + #[builder(default, setter(into))] + name: 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 Resource_Class. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("resource_classes/{name}", name = self.name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/resource_classes/{name}", name = "name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().name("name").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/resource_classes/{name}", name = "name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_class/get.rs b/sdk/placement/src/v1/resource_class/get.rs new file mode 100644 index 000000000..67829d654 --- /dev/null +++ b/sdk/placement/src/v1/resource_class/get.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`. + +//! Return a representation of the resource class identified by {name}. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// name parameter for /resource_classes/{name} API + #[builder(default, setter(into))] + name: 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 Resource_Class. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("resource_classes/{name}", name = self.name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_classes/{name}", name = "name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().name("name").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_classes/{name}", name = "name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_class/list.rs b/sdk/placement/src/v1/resource_class/list.rs new file mode 100644 index 000000000..1950708e4 --- /dev/null +++ b/sdk/placement/src/v1/resource_class/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`. + +//! Return a list of all resource classes. +//! +//! Normal Response Codes: 200 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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 Resource_Class. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "resource_classes".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + Some("resource_classes".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "resource_classes" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/resource_classes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_classes": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/resource_classes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_classes": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/resource_class/set_17.rs b/sdk/placement/src/v1/resource_class/set_17.rs similarity index 98% rename from openstack_sdk/src/api/placement/v1/resource_class/set_17.rs rename to sdk/placement/src/v1/resource_class/set_17.rs index 0bef1e98a..45dd32d36 100644 --- a/openstack_sdk/src/api/placement/v1/resource_class/set_17.rs +++ b/sdk/placement/src/v1/resource_class/set_17.rs @@ -120,7 +120,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/resource_provider.rs b/sdk/placement/src/v1/resource_provider.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/resource_provider.rs rename to sdk/placement/src/v1/resource_provider.rs diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/aggregate.rs b/sdk/placement/src/v1/resource_provider/aggregate.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/resource_provider/aggregate.rs rename to sdk/placement/src/v1/resource_provider/aggregate.rs diff --git a/sdk/placement/src/v1/resource_provider/aggregate/list.rs b/sdk/placement/src/v1/resource_provider/aggregate/list.rs new file mode 100644 index 000000000..0f590f887 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/aggregate/list.rs @@ -0,0 +1,195 @@ +// 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`. + +//! Return a list of aggregates associated with the resource provider +//! identified by {uuid}. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) if the provider does not exist. (If +//! the provider has no aggregates, the result is 200 with an empty aggregate +//! list.) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for /resource_providers/{uuid}/aggregates API + #[builder(default, setter(into))] + uuid: 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 Aggregate. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/aggregates", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + Some("aggregates".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "aggregates" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/resource_providers/{uuid}/aggregates", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregates": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/resource_providers/{uuid}/aggregates", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "aggregates": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/aggregate/set_11.rs b/sdk/placement/src/v1/resource_provider/aggregate/set_11.rs similarity index 98% rename from openstack_sdk/src/api/placement/v1/resource_provider/aggregate/set_11.rs rename to sdk/placement/src/v1/resource_provider/aggregate/set_11.rs index 5393d886f..f369a5e3a 100644 --- a/openstack_sdk/src/api/placement/v1/resource_provider/aggregate/set_11.rs +++ b/sdk/placement/src/v1/resource_provider/aggregate/set_11.rs @@ -120,7 +120,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/aggregate/set_119.rs b/sdk/placement/src/v1/resource_provider/aggregate/set_119.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/resource_provider/aggregate/set_119.rs rename to sdk/placement/src/v1/resource_provider/aggregate/set_119.rs index b288d2d9b..06bb4eb8b 100644 --- a/openstack_sdk/src/api/placement/v1/resource_provider/aggregate/set_119.rs +++ b/sdk/placement/src/v1/resource_provider/aggregate/set_119.rs @@ -138,7 +138,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/allocation.rs b/sdk/placement/src/v1/resource_provider/allocation.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/resource_provider/allocation.rs rename to sdk/placement/src/v1/resource_provider/allocation.rs diff --git a/sdk/placement/src/v1/resource_provider/allocation/list.rs b/sdk/placement/src/v1/resource_provider/allocation/list.rs new file mode 100644 index 000000000..2257f20da --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/allocation/list.rs @@ -0,0 +1,191 @@ +// 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`. + +//! Return a representation of all allocations made against this resource +//! provider, keyed by consumer uuid. Each allocation includes one or more +//! classes of resource and the amount consumed. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for /resource_providers/{uuid}/allocations API + #[builder(default, setter(into))] + uuid: 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 Allocation. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/allocations", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/resource_providers/{uuid}/allocations", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/resource_providers/{uuid}/allocations", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/create_10.rs b/sdk/placement/src/v1/resource_provider/create_10.rs similarity index 98% rename from openstack_sdk/src/api/placement/v1/resource_provider/create_10.rs rename to sdk/placement/src/v1/resource_provider/create_10.rs index bbe871370..12818eda9 100644 --- a/openstack_sdk/src/api/placement/v1/resource_provider/create_10.rs +++ b/sdk/placement/src/v1/resource_provider/create_10.rs @@ -134,7 +134,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/create_114.rs b/sdk/placement/src/v1/resource_provider/create_114.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/resource_provider/create_114.rs rename to sdk/placement/src/v1/resource_provider/create_114.rs index 3e14ae24b..350f4d023 100644 --- a/openstack_sdk/src/api/placement/v1/resource_provider/create_114.rs +++ b/sdk/placement/src/v1/resource_provider/create_114.rs @@ -152,7 +152,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/sdk/placement/src/v1/resource_provider/delete.rs b/sdk/placement/src/v1/resource_provider/delete.rs new file mode 100644 index 000000000..8ecdb1635 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/delete.rs @@ -0,0 +1,188 @@ +// 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 the resource provider identified by {uuid}. This will also +//! disassociate aggregates and delete inventories. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: itemNotFound(404), conflict(409) +//! +//! A 409 Conflict response code will be returned if there exist allocations +//! records for any of the inventories that would be deleted as a result of +//! removing the resource provider. +//! +//! This error code will be also returned if there are existing child resource +//! providers under the parent resource provider being deleted. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for /resource_providers/{uuid} API + #[builder(default, setter(into))] + uuid: 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 Resource_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("resource_providers/{uuid}", uuid = self.uuid.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/resource_providers/{uuid}", uuid = "uuid",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/resource_providers/{uuid}", uuid = "uuid",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/get.rs b/sdk/placement/src/v1/resource_provider/get.rs new file mode 100644 index 000000000..75bf43208 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/get.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`. + +//! Return a representation of the resource provider identified by {uuid}. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for /resource_providers/{uuid} API + #[builder(default, setter(into))] + uuid: 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 Resource_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("resource_providers/{uuid}", uuid = self.uuid.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_providers/{uuid}", uuid = "uuid",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_providers/{uuid}", uuid = "uuid",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/inventory.rs b/sdk/placement/src/v1/resource_provider/inventory.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/resource_provider/inventory.rs rename to sdk/placement/src/v1/resource_provider/inventory.rs diff --git a/sdk/placement/src/v1/resource_provider/inventory/create.rs b/sdk/placement/src/v1/resource_provider/inventory/create.rs new file mode 100644 index 000000000..ddbba28ad --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/inventory/create.rs @@ -0,0 +1,292 @@ +// 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`. + +//! POST to create one inventory. +//! +//! On success return a 201 response, a location header pointing to the newly +//! created inventory and an application/json representation of the inventory. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InventoriesItem { + /// It is used in determining whether consumption of the resource of the + /// provider can exceed physical constraints. + /// + /// For example, for a vCPU resource with: + /// + /// ```text + /// allocation_ratio = 16.0 + /// total = 8 + /// ``` + /// + /// Overall capacity is equal to 128 vCPUs. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allocation_ratio: Option, + + /// A maximum amount any single allocation against an inventory can have. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_unit: Option, + + /// A minimum amount any single allocation against an inventory can have. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_unit: Option, + + /// The amount of the resource a provider has reserved for its own use. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) reserved: Option, + + /// A representation of the divisible amount of the resource that may be + /// requested. For example, step_size = 5 means that only values divisible + /// by 5 (5, 10, 15, etc.) can be requested. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) step_size: Option, + + /// The actual amount of the resource that the provider can accommodate. + #[serde()] + #[builder(setter(into))] + pub(crate) total: i32, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary of inventories keyed by resource classes. + #[builder(private, setter(into, name = "_inventories"))] + pub(crate) inventories: BTreeMap, InventoriesItem>, + + /// A consistent view marker that assists with the management of concurrent + /// resource provider updates. + #[builder(setter(into))] + pub(crate) resource_provider_generation: i32, + + /// uuid parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + uuid: 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> { + /// A dictionary of inventories keyed by resource classes. + pub fn inventories(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.inventories + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Inventory. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + format!( + "resource_providers/{uuid}/inventories", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("inventories", serde_json::to_value(&self.inventories)?); + params.push( + "resource_provider_generation", + serde_json::to_value(self.resource_provider_generation)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST).path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/inventory/delete.rs b/sdk/placement/src/v1/resource_provider/inventory/delete.rs new file mode 100644 index 000000000..11e628de3 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/inventory/delete.rs @@ -0,0 +1,210 @@ +// 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 the inventory record of the {resource_class} for the resource +//! provider identified by {uuid}. +//! +//! See +//! [Troubleshooting](?expanded=delete-resource-provider-inventories-detail#delete-resource-provider-inventories) +//! section in `Delete resource provider inventories` for a description. In +//! addition, the request returns HTTP 409 when there are allocations for the +//! specified resource provider and resource class. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// resource_class parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + resource_class: Cow<'a, str>, + + /// uuid parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + uuid: 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 Inventory. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/inventories/{resource_class}", + resource_class = self.resource_class.as_ref(), + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/resource_providers/{uuid}/inventories/{resource_class}", + resource_class = "resource_class", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .resource_class("resource_class") + .uuid("uuid") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/resource_providers/{uuid}/inventories/{resource_class}", + resource_class = "resource_class", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .resource_class("resource_class") + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/inventory/delete_all.rs b/sdk/placement/src/v1/resource_provider/inventory/delete_all.rs new file mode 100644 index 000000000..abdc9ea2f --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/inventory/delete_all.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`. + +//! Deletes all inventory records for the resource provider identified by +//! {uuid}. +//! +//! **Troubleshooting** +//! +//! The request returns an HTTP 409 when there are allocations against the +//! provider or if the provider’s inventory is updated by another thread while +//! attempting the operation. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + uuid: 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 Inventory. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/inventories", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE).path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/inventory/get.rs b/sdk/placement/src/v1/resource_provider/inventory/get.rs new file mode 100644 index 000000000..9715e423b --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/inventory/get.rs @@ -0,0 +1,201 @@ +// 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`. + +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// resource_class parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + resource_class: Cow<'a, str>, + + /// uuid parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + uuid: 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 Inventory. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/inventories/{resource_class}", + resource_class = self.resource_class.as_ref(), + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/resource_providers/{uuid}/inventories/{resource_class}", + resource_class = "resource_class", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .resource_class("resource_class") + .uuid("uuid") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/resource_providers/{uuid}/inventories/{resource_class}", + resource_class = "resource_class", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .resource_class("resource_class") + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/inventory/list.rs b/sdk/placement/src/v1/resource_provider/inventory/list.rs new file mode 100644 index 000000000..dd6d914a2 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/inventory/list.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + uuid: 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 Inventory. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/inventories", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET).path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/inventory/replace.rs b/sdk/placement/src/v1/resource_provider/inventory/replace.rs new file mode 100644 index 000000000..c554c2cb0 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/inventory/replace.rs @@ -0,0 +1,294 @@ +// 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`. + +//! Replaces the set of inventory records for the resource provider identified +//! by {uuid}. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct InventoriesItem { + /// It is used in determining whether consumption of the resource of the + /// provider can exceed physical constraints. + /// + /// For example, for a vCPU resource with: + /// + /// ```text + /// allocation_ratio = 16.0 + /// total = 8 + /// ``` + /// + /// Overall capacity is equal to 128 vCPUs. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) allocation_ratio: Option, + + /// A maximum amount any single allocation against an inventory can have. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) max_unit: Option, + + /// A minimum amount any single allocation against an inventory can have. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) min_unit: Option, + + /// The amount of the resource a provider has reserved for its own use. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) reserved: Option, + + /// A representation of the divisible amount of the resource that may be + /// requested. For example, step_size = 5 means that only values divisible + /// by 5 (5, 10, 15, etc.) can be requested. + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) step_size: Option, + + /// The actual amount of the resource that the provider can accommodate. + #[serde()] + #[builder(setter(into))] + pub(crate) total: i32, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A dictionary of inventories keyed by resource classes. + #[builder(private, setter(into, name = "_inventories"))] + pub(crate) inventories: BTreeMap, InventoriesItem>, + + /// A consistent view marker that assists with the management of concurrent + /// resource provider updates. + #[builder(setter(into))] + pub(crate) resource_provider_generation: i32, + + /// uuid parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + uuid: 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> { + /// A dictionary of inventories keyed by resource classes. + pub fn inventories(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.inventories + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Inventory. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "resource_providers/{uuid}/inventories", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("inventories", serde_json::to_value(&self.inventories)?); + params.push( + "resource_provider_generation", + serde_json::to_value(self.resource_provider_generation)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/resource_providers/{uuid}/inventories", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .inventories(BTreeMap::::new().into_iter()) + .resource_provider_generation(123) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/inventory/set.rs b/sdk/placement/src/v1/resource_provider/inventory/set.rs new file mode 100644 index 000000000..9609a3b2e --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/inventory/set.rs @@ -0,0 +1,289 @@ +// 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`. + +//! Replace the inventory record of the {resource_class} for the resource +//! provider identified by {uuid}. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// It is used in determining whether consumption of the resource of the + /// provider can exceed physical constraints. + /// + /// For example, for a vCPU resource with: + /// + /// ```text + /// allocation_ratio = 16.0 + /// total = 8 + /// ``` + /// + /// Overall capacity is equal to 128 vCPUs. + #[builder(default, setter(into))] + pub(crate) allocation_ratio: Option, + + /// A maximum amount any single allocation against an inventory can have. + #[builder(default, setter(into))] + pub(crate) max_unit: Option, + + /// A minimum amount any single allocation against an inventory can have. + #[builder(default, setter(into))] + pub(crate) min_unit: Option, + + /// The amount of the resource a provider has reserved for its own use. + #[builder(default, setter(into))] + pub(crate) reserved: Option, + + /// A consistent view marker that assists with the management of concurrent + /// resource provider updates. + #[builder(setter(into))] + pub(crate) resource_provider_generation: i32, + + /// A representation of the divisible amount of the resource that may be + /// requested. For example, step_size = 5 means that only values divisible + /// by 5 (5, 10, 15, etc.) can be requested. + #[builder(default, setter(into))] + pub(crate) step_size: Option, + + /// The actual amount of the resource that the provider can accommodate. + #[builder(setter(into))] + pub(crate) total: i32, + + /// resource_class parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + resource_class: Cow<'a, str>, + + /// uuid parameter for + /// /resource_providers/{uuid}/inventories/{resource_class} API + #[builder(default, setter(into))] + uuid: 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 Inventory. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "resource_providers/{uuid}/inventories/{resource_class}", + resource_class = self.resource_class.as_ref(), + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.allocation_ratio { + params.push("allocation_ratio", serde_json::to_value(val)?); + } + if let Some(val) = &self.max_unit { + params.push("max_unit", serde_json::to_value(val)?); + } + if let Some(val) = &self.min_unit { + params.push("min_unit", serde_json::to_value(val)?); + } + if let Some(val) = &self.reserved { + params.push("reserved", serde_json::to_value(val)?); + } + params.push( + "resource_provider_generation", + serde_json::to_value(self.resource_provider_generation)?, + ); + if let Some(val) = &self.step_size { + params.push("step_size", serde_json::to_value(val)?); + } + params.push("total", serde_json::to_value(self.total)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .resource_provider_generation(123) + .total(123) + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .resource_provider_generation(123) + .total(123) + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT).path(format!( + "/resource_providers/{uuid}/inventories/{resource_class}", + resource_class = "resource_class", + uuid = "uuid", + )); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .resource_class("resource_class") + .uuid("uuid") + .resource_provider_generation(123) + .total(123) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!( + "/resource_providers/{uuid}/inventories/{resource_class}", + resource_class = "resource_class", + uuid = "uuid", + )) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .resource_class("resource_class") + .uuid("uuid") + .resource_provider_generation(123) + .total(123) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/list.rs b/sdk/placement/src/v1/resource_provider/list.rs new file mode 100644 index 000000000..bee80d274 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/list.rs @@ -0,0 +1,348 @@ +// 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 an optionally filtered collection of resource providers. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: badRequest(400) +//! +//! A 400 BadRequest response code will be returned if a resource class +//! specified in `resources` request parameter does not exist. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A string representing a resource provider uuid. When supplied, it will + /// filter the returned allocation candidates to only those resource + /// providers that are in the same tree with the given resource provider. + #[builder(default, setter(into))] + in_tree: Option>, + + /// A string representing an aggregate uuid; or the prefix in: followed by + /// a comma-separated list of strings representing aggregate uuids. The + /// resource providers in the allocation request in the response must + /// directly or via the root provider be associated with the aggregate or + /// aggregates identified by uuid: + /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, + /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` + /// Starting from microversion 1.24 specifying multiple member_of query + /// string parameters is possible. Multiple member_of parameters will + /// result in filtering providers that are directly or via root provider + /// associated with aggregates listed in all of the member_of query string + /// values. For example, to get the providers that are associated with + /// aggregate A as well as associated with any of aggregates B or C, the + /// user could issue the following query: + /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from + /// microversion 1.32 specifying forbidden aggregates is supported in the + /// member_of query string parameter. Forbidden aggregates are prefixed + /// with a !. This negative expression can also be used in multiple + /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would + /// translate logically to “Candidate resource providers must be in AGGA + /// and not in AGGB.” We do NOT support ! on the values within in:, but we + /// support !in:. Both of the following two example queries return + /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: + /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, + /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do + /// not check if the same aggregate uuid is in both positive and negative + /// expression to return 400 BadRequest. We still return 200 for such + /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would + /// return empty allocation_requests and provider_summaries, while: + /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return + /// resource providers that are NOT in AGGA but in AGGB. + #[builder(default, private, setter(name = "_member_of"))] + member_of: Option>>, + + /// The name of a resource provider to filter the list. + #[builder(default, setter(into))] + name: Option>, + + /// A comma-separated list of traits that a provider must have: + /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the + /// response will be for resource providers that have capacity for all + /// requested resources and the set of those resource providers will + /// collectively contain all of the required traits. These traits may be + /// satisfied by any provider in the same non-sharing tree or associated + /// via aggregate as far as that provider also contributes resource to the + /// request. Starting from microversion 1.22 traits which are forbidden + /// from any resource provider contributing resources to the request may be + /// expressed by prefixing a trait with a `!`. Starting from microversion + /// 1.39 the required query parameter can be repeated. The trait lists from + /// the repeated parameters are AND-ed together. So: + /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting + /// from microversion 1.39 the required parameter supports the syntax: + /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden + /// traits into an in: prefixed value is not supported and rejected. But + /// mixing a normal trait list and an in: prefixed trait list in two query + /// params within the same request is supported. So: + /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and + /// not T2 and (T3 or T4). + #[builder(default, private, setter(name = "_required"))] + required: Option>>, + + /// A comma-separated list of strings indicating an amount of resource of a + /// specified class that providers in each allocation request must + /// collectively have the capacity and availability to serve: + /// `resources=VCPU:4,DISK_GB:64,MEMORY_MB:2048` These resources may be + /// satisfied by any provider in the same non-sharing tree or associated + /// via aggregate. + #[builder(default, setter(into))] + resources: Option>, + + /// The uuid of a resource provider. + #[builder(default, setter(into))] + 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> { + /// A string representing an aggregate uuid; or the prefix in: followed by + /// a comma-separated list of strings representing aggregate uuids. The + /// resource providers in the allocation request in the response must + /// directly or via the root provider be associated with the aggregate or + /// aggregates identified by uuid: + /// `member_of=5e08ea53-c4c6-448e-9334-ac4953de3cfa`, + /// `member_of=in:42896e0d-205d-4fe3-bd1e-100924931787,5e08ea53-c4c6-448e-9334-ac4953de3cfa` + /// Starting from microversion 1.24 specifying multiple member_of query + /// string parameters is possible. Multiple member_of parameters will + /// result in filtering providers that are directly or via root provider + /// associated with aggregates listed in all of the member_of query string + /// values. For example, to get the providers that are associated with + /// aggregate A as well as associated with any of aggregates B or C, the + /// user could issue the following query: + /// `member_of=AGGA_UUID&member_of=in:AGGB_UUID,AGGC_UUID` Starting from + /// microversion 1.32 specifying forbidden aggregates is supported in the + /// member_of query string parameter. Forbidden aggregates are prefixed + /// with a !. This negative expression can also be used in multiple + /// member_of parameters: `member_of=AGGA_UUID&member_of=!AGGB_UUID` would + /// translate logically to “Candidate resource providers must be in AGGA + /// and not in AGGB.” We do NOT support ! on the values within in:, but we + /// support !in:. Both of the following two example queries return + /// candidate resource providers that are NOT in AGGA, AGGB, or AGGC: + /// `member_of=!in:AGGA_UUID,AGGB_UUID,AGGC_UUID`, + /// `member_of=!AGGA_UUID&member_of=!AGGB_UUID&member_of=!AGGC_UUID` We do + /// not check if the same aggregate uuid is in both positive and negative + /// expression to return 400 BadRequest. We still return 200 for such + /// cases. For example: `member_of=AGGA_UUID&member_of=!AGGA_UUID` would + /// return empty allocation_requests and provider_summaries, while: + /// `member_of=in:AGGA_UUID,AGGB_UUID&member_of=!AGGA_UUID` would return + /// resource providers that are NOT in AGGA but in AGGB. + pub fn member_of(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.member_of + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// A comma-separated list of traits that a provider must have: + /// `required=HW_CPU_X86_AVX,HW_CPU_X86_SSE` Allocation requests in the + /// response will be for resource providers that have capacity for all + /// requested resources and the set of those resource providers will + /// collectively contain all of the required traits. These traits may be + /// satisfied by any provider in the same non-sharing tree or associated + /// via aggregate as far as that provider also contributes resource to the + /// request. Starting from microversion 1.22 traits which are forbidden + /// from any resource provider contributing resources to the request may be + /// expressed by prefixing a trait with a `!`. Starting from microversion + /// 1.39 the required query parameter can be repeated. The trait lists from + /// the repeated parameters are AND-ed together. So: + /// `required=T1,!T2&required=T3` means T1 and not T2 and T3. Also starting + /// from microversion 1.39 the required parameter supports the syntax: + /// `required=in:T1,T2,T3` which means T1 or T2 or T3. Mixing forbidden + /// traits into an in: prefixed value is not supported and rejected. But + /// mixing a normal trait list and an in: prefixed trait list in two query + /// params within the same request is supported. So: + /// `required=in:T3,T4&required=T1,!T2` is supported and it means T1 and + /// not T2 and (T3 or T4). + pub fn required(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into>, + { + self.required + .get_or_insert(None) + .get_or_insert_with(Vec::new) + .extend(iter.map(Into::into)); + self + } + + /// Add a single header to the Resource_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "resource_providers".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("in_tree", self.in_tree.as_ref()); + if let Some(val) = &self.member_of { + params.extend(val.iter().map(|value| ("member_of", value))); + } + params.push_opt("name", self.name.as_ref()); + if let Some(val) = &self.required { + params.extend(val.iter().map(|value| ("required", value))); + } + params.push_opt("resources", self.resources.as_ref()); + params.push_opt("uuid", self.uuid.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + Some("resource_providers".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "resource_providers" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/resource_providers".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_providers": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/resource_providers".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "resource_providers": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/set_10.rs b/sdk/placement/src/v1/resource_provider/set_10.rs new file mode 100644 index 000000000..f8c55d81c --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/set_10.rs @@ -0,0 +1,212 @@ +// 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 the name of the resource provider identified by {uuid}. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) +//! +//! A 409 Conflict response code will be returned if another resource provider +//! exists with the provided name. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// The name of one resource provider. + #[builder(setter(into))] + pub(crate) name: Cow<'a, str>, + + /// uuid parameter for /resource_providers/{uuid} API + #[builder(default, setter(into))] + uuid: 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 Resource_Provider. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("resource_providers/{uuid}", uuid = self.uuid.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("name", serde_json::to_value(&self.name)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + 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 { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .name("foo") + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!( + Request::builder() + .name("foo") + .build() + .unwrap() + .response_key() + .is_none() + ) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/resource_providers/{uuid}", uuid = "uuid",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").name("foo").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/resource_providers/{uuid}", uuid = "uuid",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .name("foo") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/set_114.rs b/sdk/placement/src/v1/resource_provider/set_114.rs similarity index 99% rename from openstack_sdk/src/api/placement/v1/resource_provider/set_114.rs rename to sdk/placement/src/v1/resource_provider/set_114.rs index 24c03400f..89c72d2f0 100644 --- a/openstack_sdk/src/api/placement/v1/resource_provider/set_114.rs +++ b/sdk/placement/src/v1/resource_provider/set_114.rs @@ -148,7 +148,7 @@ mod tests { use openstack_sdk_core::types::ServiceType; use serde_json::json; - use crate::test::client::FakeOpenStackClient; + use openstack_sdk_core::test::client::FakeOpenStackClient; #[test] fn test_service_type() { diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/trait.rs b/sdk/placement/src/v1/resource_provider/trait.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/resource_provider/trait.rs rename to sdk/placement/src/v1/resource_provider/trait.rs diff --git a/sdk/placement/src/v1/resource_provider/trait/delete.rs b/sdk/placement/src/v1/resource_provider/trait/delete.rs new file mode 100644 index 000000000..ef6cc63f5 --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/trait/delete.rs @@ -0,0 +1,184 @@ +// 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`. + +//! Dissociate all the traits from the resource provider identified by {uuid}. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for /resource_providers/{uuid}/traits API + #[builder(default, setter(into))] + uuid: 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 Trait. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/traits", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/trait/list.rs b/sdk/placement/src/v1/resource_provider/trait/list.rs new file mode 100644 index 000000000..3362cd80e --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/trait/list.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Return a list of traits for the resource provider identified by {uuid}. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for /resource_providers/{uuid}/traits API + #[builder(default, setter(into))] + uuid: 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 Trait. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/traits", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + Some("traits".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "traits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "traits": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "traits": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/resource_provider/trait/set.rs b/sdk/placement/src/v1/resource_provider/trait/set.rs new file mode 100644 index 000000000..320a8adac --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/trait/set.rs @@ -0,0 +1,215 @@ +// 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`. + +//! Associate traits with the resource provider identified by {uuid}. All the +//! associated traits will be replaced by the traits specified in the request +//! body. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A list of traits. + #[builder(setter(into))] + pub(crate) traits: Vec>, + + /// uuid parameter for /resource_providers/{uuid}/traits API + #[builder(default, setter(into))] + uuid: 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 Trait. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!( + "resource_providers/{uuid}/traits", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("traits", serde_json::to_value(&self.traits)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + Some("traits".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .traits(Vec::from(["foo".into()])) + .build() + .unwrap() + .service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .traits(Vec::from(["foo".into()])) + .build() + .unwrap() + .response_key() + .unwrap(), + "traits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "traits": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .traits(Vec::from(["foo".into()])) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/resource_providers/{uuid}/traits", uuid = "uuid",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "traits": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .traits(Vec::from(["foo".into()])) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/resource_provider/usage.rs b/sdk/placement/src/v1/resource_provider/usage.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/resource_provider/usage.rs rename to sdk/placement/src/v1/resource_provider/usage.rs diff --git a/sdk/placement/src/v1/resource_provider/usage/get.rs b/sdk/placement/src/v1/resource_provider/usage/get.rs new file mode 100644 index 000000000..1eeb43faa --- /dev/null +++ b/sdk/placement/src/v1/resource_provider/usage/get.rs @@ -0,0 +1,187 @@ +// 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`. + +//! Return a report of usage information for resources associated with the +//! resource provider identified by {uuid}. The value is a dictionary of +//! resource classes paired with the sum of the allocations of that resource +//! class for this resource provider. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// uuid parameter for /resource_providers/{uuid}/usages API + #[builder(default, setter(into))] + uuid: 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 Usage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!( + "resource_providers/{uuid}/usages", + uuid = self.uuid.as_ref(), + ) + .into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_providers/{uuid}/usages", uuid = "uuid",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().uuid("uuid").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/resource_providers/{uuid}/usages", uuid = "uuid",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .uuid("uuid") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/trait.rs b/sdk/placement/src/v1/trait.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/trait.rs rename to sdk/placement/src/v1/trait.rs diff --git a/sdk/placement/src/v1/trait/delete.rs b/sdk/placement/src/v1/trait/delete.rs new file mode 100644 index 000000000..3aefb4cc4 --- /dev/null +++ b/sdk/placement/src/v1/trait/delete.rs @@ -0,0 +1,181 @@ +// 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 the trait specified be {name}. Note that only custom traits can be +//! deleted. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: badRequest(400), itemNotFound(404), conflict(409) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// name parameter for /traits/{name} API + #[builder(default, setter(into))] + name: 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 Trait. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("traits/{name}", name = self.name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/traits/{name}", name = "name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().name("name").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/traits/{name}", name = "name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/trait/get.rs b/sdk/placement/src/v1/trait/get.rs new file mode 100644 index 000000000..f4dcb0461 --- /dev/null +++ b/sdk/placement/src/v1/trait/get.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`. + +//! Check if a trait name exists in this cloud. +//! +//! Normal Response Codes: 204 +//! +//! Error response codes: itemNotFound(404) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// name parameter for /traits/{name} API + #[builder(default, setter(into))] + name: 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 Trait. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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!("traits/{name}", name = self.name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/traits/{name}", name = "name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().name("name").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/traits/{name}", name = "name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/trait/list.rs b/sdk/placement/src/v1/trait/list.rs new file mode 100644 index 000000000..193d394eb --- /dev/null +++ b/sdk/placement/src/v1/trait/list.rs @@ -0,0 +1,190 @@ +// 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`. + +//! Return a list of valid trait strings according to parameters specified. +//! +//! Normal Response Codes: 200 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// If this parameter has a true value, the returned traits will be those + /// that are associated with at least one resource provider. Available + /// values for the parameter are true and false. + #[builder(default)] + associated: Option, + + /// The name of a resource provider to filter the list. + #[builder(default, setter(into))] + name: 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> { + /// Add a single header to the Trait. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "traits".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("associated", self.associated); + params.push_opt("name", self.name.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + Some("traits".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "traits" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/traits".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "traits": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/traits".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "traits": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/sdk/placement/src/v1/trait/set.rs b/sdk/placement/src/v1/trait/set.rs new file mode 100644 index 000000000..8569002d2 --- /dev/null +++ b/sdk/placement/src/v1/trait/set.rs @@ -0,0 +1,188 @@ +// 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`. + +//! Insert a new custom trait. If traits already exists 204 will be returned. +//! +//! There are two kinds of traits: the standard traits and the custom traits. +//! The standard traits are interoperable across different OpenStack cloud +//! deployments. The definition of standard traits comes from the os-traits +//! library. The standard traits are read-only in the placement API which means +//! that the user can’t modify any standard traits through API. The custom +//! traits are used by admin users to manage the non-standard qualitative +//! information of resource providers. +//! +//! Normal Response Codes: 201, 204 +//! +//! Error response codes: badRequest(400) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// name parameter for /traits/{name} API + #[builder(default, setter(into))] + name: 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 Trait. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("traits/{name}", name = self.name.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams<'_> { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/traits/{name}", name = "name",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().name("name").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/traits/{name}", name = "name",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .name("name") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/usage.rs b/sdk/placement/src/v1/usage.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/usage.rs rename to sdk/placement/src/v1/usage.rs diff --git a/sdk/placement/src/v1/usage/list.rs b/sdk/placement/src/v1/usage/list.rs new file mode 100644 index 000000000..83bbb591e --- /dev/null +++ b/sdk/placement/src/v1/usage/list.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`. + +//! Return a report of usage information for resources associated with the +//! project identified by project_id and user identified by user_id. The value +//! is a dictionary of resource classes paired with the sum of the allocations +//! of that resource class for provided parameters. +//! +//! Normal Response Codes: 200 +//! +//! Error response codes: badRequest(400) +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A string that consists of numbers, A-Z, and _ describing the consumer + /// type by which to filter usage results. For example, to retrieve only + /// usage information for ‘INSTANCE’ type consumers a parameter of + /// consumer_type=INSTANCE should be provided. The all query parameter may + /// be specified to group all results under one key, all. The unknown query + /// parameter may be specified to group all results under one key, unknown. + #[builder(default, setter(into))] + consumer_type: Option>, + + /// The uuid of a project. + #[builder(default, setter(into))] + project_id: Cow<'a, str>, + + /// The uuid of a user. + #[builder(default, setter(into))] + user_id: 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> { + /// Add a single header to the Usage. + pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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> { + "usages".to_string().into() + } + + fn parameters(&self) -> QueryParams<'_> { + let mut params = QueryParams::default(); + params.push_opt("consumer_type", self.consumer_type.as_ref()); + params.push("project_id", self.project_id.as_ref()); + params.push_opt("user_id", self.user_id.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::Placement + } + + fn response_key(&self) -> Option> { + Some("usages".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder().build().unwrap().response_key().unwrap(), + "usages" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/usages".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "usages": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/usages".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "usages": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/placement/v1/version.rs b/sdk/placement/src/v1/version.rs similarity index 100% rename from openstack_sdk/src/api/placement/v1/version.rs rename to sdk/placement/src/v1/version.rs diff --git a/sdk/placement/src/v1/version/get.rs b/sdk/placement/src/v1/version/get.rs new file mode 100644 index 000000000..798296fe6 --- /dev/null +++ b/sdk/placement/src/v1/version/get.rs @@ -0,0 +1,171 @@ +// 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`. + +//! Fetch information about all known major versions of the placement API, +//! including information about the minimum and maximum microversions. +//! +//! Normal Response Codes: 200 +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use openstack_sdk_core::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: K, header_value: V) -> &mut Self + where + K: Into, + V: Into, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name.into(), header_value.into()); + 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::Placement + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use http::{HeaderName, HeaderValue}; + use httpmock::MockServer; + #[cfg(feature = "sync")] + use openstack_sdk_core::api::Query; + use openstack_sdk_core::types::ServiceType; + use serde_json::json; + + use openstack_sdk_core::test::client::FakeOpenStackClient; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::Placement + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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 server = MockServer::start(); + let client = FakeOpenStackClient::new(server.base_url()); + let mock = 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( + HeaderName::from_static("not_foo"), + HeaderValue::from_static("not_bar"), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +}